@@ -170,11 +170,11 @@ |
||
| 170 | 170 | try { |
| 171 | 171 | $response = $this->guzzleHttpClient->send($request, ['allow_redirects' => false]); |
| 172 | 172 | $responseHeader = $response->getHeaders(); |
| 173 | - $responseBody = json_decode((string) $response->getBody(), true); |
|
| 173 | + $responseBody = json_decode((string)$response->getBody(), true); |
|
| 174 | 174 | $statusReturned = $response->getStatusCode(); |
| 175 | 175 | } catch (BadResponseException $ex) { |
| 176 | 176 | $responseHeader = $ex->getResponse()->getHeaders(); |
| 177 | - $responseBody = json_decode((string) $ex->getResponse()->getBody(), true); |
|
| 177 | + $responseBody = json_decode((string)$ex->getResponse()->getBody(), true); |
|
| 178 | 178 | $statusReturned = $ex->getResponse()->getStatusCode(); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -33,6 +33,9 @@ discard block |
||
| 33 | 33 | $this->guzzleHttpClient = new Client(['headers' => ['User-Agent' => 'Swagger Test']]); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | + /** |
|
| 37 | + * @param SwaggerSchema $schema |
|
| 38 | + */ |
|
| 36 | 39 | public function withSwaggerSchema($schema) |
| 37 | 40 | { |
| 38 | 41 | $this->swaggerSchema = $schema; |
@@ -105,6 +108,9 @@ discard block |
||
| 105 | 108 | return $this; |
| 106 | 109 | } |
| 107 | 110 | |
| 111 | + /** |
|
| 112 | + * @param integer $code |
|
| 113 | + */ |
|
| 108 | 114 | public function assertResponseCode($code) |
| 109 | 115 | { |
| 110 | 116 | $this->statusExpected = $code; |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | protected $allowNullValues; |
| 20 | 20 | protected $specificationVersion; |
| 21 | 21 | |
| 22 | - const SWAGGER_PATHS="paths"; |
|
| 23 | - const SWAGGER_PARAMETERS="parameters"; |
|
| 22 | + const SWAGGER_PATHS = "paths"; |
|
| 23 | + const SWAGGER_PARAMETERS = "parameters"; |
|
| 24 | 24 | |
| 25 | 25 | public function __construct($jsonFile, $allowNullValues = false) |
| 26 | 26 | { |
| 27 | 27 | $this->jsonFile = json_decode($jsonFile, true); |
| 28 | - $this->allowNullValues = (bool) $allowNullValues; |
|
| 28 | + $this->allowNullValues = (bool)$allowNullValues; |
|
| 29 | 29 | $this->specificationVersion = isset($this->jsonFile['swagger']) ? '2' : '3'; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function getBasePath() |
| 57 | 57 | { |
| 58 | 58 | if ($this->getSpecificationVersion() === '3') { |
| 59 | - $basePath =isset($this->jsonFile['servers']) ? explode('/', $this->jsonFile['servers'][0]['url']) : ''; |
|
| 59 | + $basePath = isset($this->jsonFile['servers']) ? explode('/', $this->jsonFile['servers'][0]['url']) : ''; |
|
| 60 | 60 | return is_array($basePath) ? '/' . end($basePath) : $basePath; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | { |
| 182 | 182 | $structure = $this->getPathDefinition($path, $method); |
| 183 | 183 | |
| 184 | - if($this->getSpecificationVersion() === '3') { |
|
| 184 | + if ($this->getSpecificationVersion() === '3') { |
|
| 185 | 185 | if (!isset($structure['requestBody'])) { |
| 186 | 186 | return new SwaggerRequestBody($this, "$method $path", []); |
| 187 | 187 | } |
@@ -234,6 +234,6 @@ discard block |
||
| 234 | 234 | */ |
| 235 | 235 | public function setAllowNullValues($value) |
| 236 | 236 | { |
| 237 | - $this->allowNullValues = (bool) $value; |
|
| 237 | + $this->allowNullValues = (bool)$value; |
|
| 238 | 238 | } |
| 239 | 239 | } |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | abstract class SwaggerBody |
| 10 | 10 | { |
| 11 | - const SWAGGER_PROPERTIES="properties"; |
|
| 12 | - const SWAGGER_REQUIRED="required"; |
|
| 11 | + const SWAGGER_PROPERTIES = "properties"; |
|
| 12 | + const SWAGGER_REQUIRED = "required"; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @var \ByJG\Swagger\SwaggerSchema |
@@ -146,27 +146,27 @@ discard block |
||
| 146 | 146 | $type = $schema['type']; |
| 147 | 147 | |
| 148 | 148 | $validators = [ |
| 149 | - function () use ($name, $body, $type) |
|
| 149 | + function() use ($name, $body, $type) |
|
| 150 | 150 | { |
| 151 | 151 | return $this->matchNull($name, $body, $type); |
| 152 | 152 | }, |
| 153 | 153 | |
| 154 | - function () use ($name, $schema, $body, $type) |
|
| 154 | + function() use ($name, $schema, $body, $type) |
|
| 155 | 155 | { |
| 156 | 156 | return $this->matchString($name, $schema, $body, $type); |
| 157 | 157 | }, |
| 158 | 158 | |
| 159 | - function () use ($name, $body, $type) |
|
| 159 | + function() use ($name, $body, $type) |
|
| 160 | 160 | { |
| 161 | 161 | return $this->matchNumber($name, $body, $type); |
| 162 | 162 | }, |
| 163 | 163 | |
| 164 | - function () use ($name, $body, $type) |
|
| 164 | + function() use ($name, $body, $type) |
|
| 165 | 165 | { |
| 166 | 166 | return $this->matchBool($name, $body, $type); |
| 167 | 167 | }, |
| 168 | 168 | |
| 169 | - function () use ($name, $schema, $body, $type) |
|
| 169 | + function() use ($name, $schema, $body, $type) |
|
| 170 | 170 | { |
| 171 | 171 | return $this->matchArray($name, $schema, $body, $type); |
| 172 | 172 | } |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | return true; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - if(!isset($schema['$ref']) && isset($schema['content'])) { |
|
| 269 | + if (!isset($schema['$ref']) && isset($schema['content'])) { |
|
| 270 | 270 | $schema['$ref'] = $schema['content'][key($schema['content'])]['schema']['$ref']; |
| 271 | 271 | } |
| 272 | 272 | |