From 904335ef8984a4038b1e4c3092d99aed1fd5638a Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Tue, 20 Sep 2016 10:58:25 +0200 Subject: [PATCH 1/3] Allow not fully documented methods In out system we are gradually documenting everything, so not every method is fully documented. Its valid raml to have ```yaml /some-resource: put: get: ``` This means the method is accepted, but there is no further documentation. The current implementation does not allow this, since the value of the `put` key will be `null`. --- RamlDoc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RamlDoc.php b/RamlDoc.php index 3ee91d7..7f05ee0 100644 --- a/RamlDoc.php +++ b/RamlDoc.php @@ -103,7 +103,7 @@ public function isDefined($method, $path) { $raml = $this->getPathDefinition($path); - return isset($raml[$method]); + return array_key_exists($method, $raml); } /** From 330e1b3e31808ad585292cbae8a5d82ace4db264 Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Fri, 23 Sep 2016 15:22:40 +0200 Subject: [PATCH 2/3] Improves path matching Allows the lib to match things like: ``` /v2: /account/avatar/{id}: get: ``` by looking ahead not just for current "part" but entire left over string Needs to be improved to search for all possible matches. --- RamlDoc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RamlDoc.php b/RamlDoc.php index 7f05ee0..c759224 100644 --- a/RamlDoc.php +++ b/RamlDoc.php @@ -134,9 +134,12 @@ public function getPathDefinition($path) foreach (explode('/', substr($path, 1)) as $part) { $resource = '/' . $part; + $fullResource = '/' . strrchr($path, $part); if (isset($raml[$resource])) { $raml = $raml[$resource]; + } else if (isset($raml[$fullResource])) { + $raml = $raml[$fullResource]; } else { foreach (array_keys($raml) as $key) { if (static::isParameter($key)) { From da2d07f9499c3106aba92b1c5fe6ebe48bf5b514 Mon Sep 17 00:00:00 2001 From: Rafael Dohms Date: Fri, 23 Sep 2016 16:36:30 +0200 Subject: [PATCH 3/3] Wrong function Used the wrong function, replaced with strstr --- RamlDoc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RamlDoc.php b/RamlDoc.php index c759224..5945bfa 100644 --- a/RamlDoc.php +++ b/RamlDoc.php @@ -134,7 +134,7 @@ public function getPathDefinition($path) foreach (explode('/', substr($path, 1)) as $part) { $resource = '/' . $part; - $fullResource = '/' . strrchr($path, $part); + $fullResource = '/' . strstr($path, $part); if (isset($raml[$resource])) { $raml = $raml[$resource];