From 422e79dd012e697da702a7ec90a38c54b2b98672 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 21 Jul 2013 10:07:14 -0700 Subject: [PATCH 1/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 736164facbb2..e0cb8cf2323b 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ client codegen and ui may not work correctly. To validate an api and write output to ./swagger-errors.html: ``` -./bin/validate.sh http://petstore.swagger.wordnik.com/api/resources.json "" ./swagger-errors.html +./bin/validate.sh http://petstore.swagger.wordnik.com/api/api-docs "specia-key" ./swagger-errors.html ``` ### Generating static api documentation From 03619b19a1b33dd251766b837bc90d6c3f438df4 Mon Sep 17 00:00:00 2001 From: Russell Horton Date: Tue, 23 Jul 2013 17:50:07 -0700 Subject: [PATCH 2/2] in PHP client, add query params for all methods, not just GET --- samples/client/petstore/php/Swagger.php | 31 +++++++++--------- .../wordnik-api/php/wordnik/Swagger.php | 32 +++++++++---------- src/main/resources/php/Swagger.mustache | 31 +++++++++--------- 3 files changed, 45 insertions(+), 49 deletions(-) diff --git a/samples/client/petstore/php/Swagger.php b/samples/client/petstore/php/Swagger.php index 102d2e918fb1..473d47f968f6 100644 --- a/samples/client/petstore/php/Swagger.php +++ b/samples/client/petstore/php/Swagger.php @@ -78,24 +78,23 @@ class APIClient { curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - if ($method == self::$GET) { - if (! empty($queryParams)) { - $url = ($url . '?' . http_build_query($queryParams)); - } - } else if ($method == self::$POST) { - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PUT) { - $json_data = json_encode($postData); - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$DELETE) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else { - throw new Exception('Method ' . $method . ' is not recognized.'); + if (! empty($queryParams)) { + $url = ($url . '?' . http_build_query($queryParams)); } + if ($method == self::$POST) { + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method == self::$PUT) { + $json_data = json_encode($postData); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method == self::$DELETE) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method != self::$GET) { + throw new Exception('Method ' . $method . ' is not recognized.'); + } curl_setopt($curl, CURLOPT_URL, $url); // Make the request diff --git a/samples/client/wordnik-api/php/wordnik/Swagger.php b/samples/client/wordnik-api/php/wordnik/Swagger.php index c8fd8e2feea3..e7b7c11fbeb1 100644 --- a/samples/client/wordnik-api/php/wordnik/Swagger.php +++ b/samples/client/wordnik-api/php/wordnik/Swagger.php @@ -78,24 +78,23 @@ class APIClient { curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - if ($method == self::$GET) { - if (! empty($queryParams)) { - $url = ($url . '?' . http_build_query($queryParams)); - } - } else if ($method == self::$POST) { - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PUT) { - $json_data = json_encode($postData); - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$DELETE) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else { - throw new Exception('Method ' . $method . ' is not recognized.'); + if (! empty($queryParams)) { + $url = ($url . '?' . http_build_query($queryParams)); } + if ($method == self::$POST) { + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method == self::$PUT) { + $json_data = json_encode($postData); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method == self::$DELETE) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method != self::$GET) { + throw new Exception('Method ' . $method . ' is not recognized.'); + } curl_setopt($curl, CURLOPT_URL, $url); // Make the request @@ -240,4 +239,3 @@ class APIClient { ?> - diff --git a/src/main/resources/php/Swagger.mustache b/src/main/resources/php/Swagger.mustache index 93f8e7144fae..e7b7c11fbeb1 100644 --- a/src/main/resources/php/Swagger.mustache +++ b/src/main/resources/php/Swagger.mustache @@ -78,24 +78,23 @@ class APIClient { curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); - if ($method == self::$GET) { - if (! empty($queryParams)) { - $url = ($url . '?' . http_build_query($queryParams)); - } - } else if ($method == self::$POST) { - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$PUT) { - $json_data = json_encode($postData); - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else if ($method == self::$DELETE) { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); - } else { - throw new Exception('Method ' . $method . ' is not recognized.'); + if (! empty($queryParams)) { + $url = ($url . '?' . http_build_query($queryParams)); } + if ($method == self::$POST) { + curl_setopt($curl, CURLOPT_POST, true); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method == self::$PUT) { + $json_data = json_encode($postData); + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method == self::$DELETE) { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); + } else if ($method != self::$GET) { + throw new Exception('Method ' . $method . ' is not recognized.'); + } curl_setopt($curl, CURLOPT_URL, $url); // Make the request