diff --git a/Changelog.md b/Changelog.md index 643ee7119..08943b36b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,75 +1,3 @@ # Changelog -## 2.0.11 - - - Implemented Swagger->ref(). $swagger->ref('#/info/contact') === $swagger->info->contact - - Added validation of internal refs. - - Misc typos and improved unittests #399, #402 - -## 2.0.10 - - - Fix errors when parsing php7 anonymous class #380, #390 - - Added support for linked files and directories #393 - - Added support for $ref in deserialize() #369 - - Misc documentation tweaks. - -## 2.0.9 - - - Added support for PHP 7.1 and dropped support for PHP 5.5 and below - - Added `composer test` script - - Added support for custom DocParser->setImports() #360 - -## 2.0.8 - - - Dynamic Definitions / partial support #301 - - By default only scan *.php files #350 - - Removed silence operator @, improves compatiblity custom errorhandlers #331 - - Additional datetime classes & interfaces #338 - - Fixed case of UNDEFINED constants namespaces, improves hhvm compatibility #319 - - Misc improvements to the docs - -## 2.0.7 - - - Beter validation of type="file" #305 - - Augment Operations summary and description based on the comment. #293 - - Bugfixes #300 - - Add support for xml (and externalDocs and properties) inside a @SWG\Items. #279 - - Nested properties are no longer injected into the Definition #297 - - Fixed nesting issue with verbose property notation #297 - -## 2.0.6 - - - Added Deserializer for converting json string into a Swagger Annotations object. #290 - - Various readme improvements #284 #286 - - Various PSR-2 coding standard fixes #291 - - Travis now enforces passing PHP CodeSniffer PSR-2 tests #291 - - Use badges from shields.io #288 - -## 2.0.5 - - - Removed JSON-Schema properties that are not supported in swagger. #273 - - Added ordering filenames to guarantee a consistent output #263 - -## 2.0.4 - - - Fixed minor regression #254 - - Removed format restrictions from the remaining annotations #253 - -## 2.0.3 - - - Removed format restrictions #253 - - Fixed a bug with inherited properties #250 - -## 2.0.2 - - - Added support for @SWG\Head & @SWG\Options for documenting the HEAD and OPTIONS responses - - Removed restrictions in @SWG\Items, allow @SWG\Property and other @SWG\Schema options. - -## 2.0.1 - - - Minimal support for traits (no inheritance) - -## 2.0.0 - - - Generates swagger.json with Swagger Specification v2 - - New simplified architecture (crawl -> analysis -> processors -> validation -> output) +The changelog is moved to the [releases page](https://github.com/zircote/swagger-php/releases) diff --git a/Examples/misc/misc-api.php b/Examples/misc/misc-api.php index 2cadfd75e..61552284d 100644 --- a/Examples/misc/misc-api.php +++ b/Examples/misc/misc-api.php @@ -7,7 +7,7 @@ */ /** - * @OAS\Server( + * @OAS\Server( * url="{schema}://host.dev", * description="OpenApi parameters", * @OAS\ServerVariable( @@ -15,5 +15,5 @@ * enum="['https', 'http']", * default="https" * ) -* ) -*/ \ No newline at end of file + * ) + */ diff --git a/Examples/openapi-spec/RepositoriesControler.php b/Examples/openapi-spec/RepositoriesControler.php index 754f7fa2e..10417d74e 100644 --- a/Examples/openapi-spec/RepositoriesControler.php +++ b/Examples/openapi-spec/RepositoriesControler.php @@ -4,11 +4,11 @@ class RepositoriesController { - /** * @OAS\Get(path="/2.0/repositories/{username}", * operationId="getRepositoriesByOwner", - * @OAS\Parameter(name="username", + * @OAS\Parameter( + * name="username", * in="path", * required=true, * @OAS\Schema(type="string") @@ -21,7 +21,6 @@ class RepositoriesController * @OAS\Link(link="userRepository", ref="#/components/links/UserRepository") * ) * ) - * * @OAS\Link(link="UserRepositories", * operationId="getRepositoriesByOwner", * parameters={"username"="$response.body#/username"} @@ -51,7 +50,6 @@ public function getRepositoriesByOwner($username) * ) * ) * ) - * * @OAS\Link(link="UserRepository", * operationId="getRepository", * parameters={ @@ -90,7 +88,6 @@ public function getRepository() * ) * ) * ) - * * @OAS\Link(link="RepositoryPullRequests", * operationId="getPullRequestsByRepository", * parameters={ @@ -154,7 +151,6 @@ public function getPullRequestsById() * description="the PR was successfully merged" * ) * ) - * * @OAS\Link(link="PullRequestMerge", * operationId="mergePullRequest", * parameters={ @@ -168,6 +164,7 @@ public function mergePullRequest() { } } + ?> diff --git a/Examples/using-refs/api-spec.php b/Examples/using-refs/api-spec.php index 8f6abd8f4..95397c905 100644 --- a/Examples/using-refs/api-spec.php +++ b/Examples/using-refs/api-spec.php @@ -26,7 +26,10 @@ * request="product_in_body", * required=true, * description="product_request", - * ref="#/components/schemas/Product" + * @OAS\MediaType( + * mediaType="application/json", + * @OAS\Schema(ref="#/components/schemas/Product") + * ) * ) */ ?> diff --git a/src/Annotations/Components.php b/src/Annotations/Components.php index 7c13d41c8..03fbb146c 100644 --- a/src/Annotations/Components.php +++ b/src/Annotations/Components.php @@ -46,7 +46,7 @@ class Components extends AbstractAnnotation /** * Reusable Request Bodys. * - * @var Request[] + * @var RequestBody[] */ public $requestBodies; diff --git a/src/Annotations/Header.php b/src/Annotations/Header.php index bebeb7c60..4f8ed61ca 100644 --- a/src/Annotations/Header.php +++ b/src/Annotations/Header.php @@ -1,5 +1,4 @@ validate(); } -// public function testTypeObject() -// { -// $notAllowedInQuery = $this->parseComment('@OAS\Parameter(name="param",in="query",type="array",@OAS\Items(type="object"))'); -// $this->assertSwaggerLogEntryStartsWith('@OAS\Items()->type="object" not allowed inside a @OAS\Parameter() must be "string", "number", "integer", "boolean", "array" in '); -// $notAllowedInQuery[0]->validate(); -// } + public function testRefDefinitionInProperty() + { + $analyser = new StaticAnalyser(); + $analysis = $analyser->fromFile(__DIR__ . '/Fixtures/UsingVar.php'); + $analysis->process(); + $this->assertCount(1, $analysis->openapi->components->schemas); + $this->assertEquals('UsingVar', $analysis->openapi->components->schemas[0]->schema); + $this->assertInternalType('array', $analysis->openapi->components->schemas[0]->properties); + $this->assertCount(2, $analysis->openapi->components->schemas[0]->properties); + $this->assertEquals('name', $analysis->openapi->components->schemas[0]->properties[0]->property); + $this->assertEquals('createdAt', $analysis->openapi->components->schemas[0]->properties[1]->property); + $this->assertEquals('#/components/schemas/date', $analysis->openapi->components->schemas[0]->properties[1]->ref); + } }