-
-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create top level Tag from Tag annotations (#2334)
Close #2333 | Q | A | |---------------|---------------------------------------------------------------------------------------------------------------------------| | Bug fix? | no | | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | | Issues | Fix #2333 <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead --> | When processing `OA\Tag` annotation inside the `OpenApiPhpDescriber`, the corresponding top level OpenApi Tag is created on the fly, so the description and the externalDocs are not lost. If the same Tag name is encountered multiple time, it is merged into the already existing top level tag. _There are 3 failing tests and 2 phpstan errors that are not related to my change. They were already there before my changes._ Co-authored-by: Noémi Salaün <[email protected]>
- Loading branch information
1 parent
61a3f8b
commit 4e66705
Showing
7 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the NelmioApiDocBundle package. | ||
* | ||
* (c) Nelmio | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; | ||
|
||
use OpenApi\Attributes as OA; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
#[OA\Tag(name: 'My tag name', description: 'My description of the tag', externalDocs: new OA\ExternalDocumentation(url: 'https://example.com'))] | ||
class OpenApiTagController | ||
{ | ||
#[Route('/some_post', methods: ['POST'])] | ||
#[OA\Response(response: '200', description: '')] | ||
public function somePost() | ||
{ | ||
} | ||
|
||
#[Route('/some_get', methods: ['GET'])] | ||
#[OA\Response(response: '200', description: '')] | ||
public function someGet() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "", | ||
"version": "0.0.0" | ||
}, | ||
"paths": { | ||
"/some_post": { | ||
"post": { | ||
"tags": [ | ||
"My tag name" | ||
], | ||
"operationId": "post_nelmio_apidoc_tests_functional_openapitag_somepost", | ||
"responses": { | ||
"200": { | ||
"description": "" | ||
} | ||
} | ||
} | ||
}, | ||
"/some_get": { | ||
"get": { | ||
"tags": [ | ||
"My tag name" | ||
], | ||
"operationId": "get_nelmio_apidoc_tests_functional_openapitag_someget", | ||
"responses": { | ||
"200": { | ||
"description": "" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"tags": [ | ||
{ | ||
"name": "My tag name", | ||
"description": "My description of the tag", | ||
"externalDocs": { | ||
"url": "https://example.com" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters