Repository navigation
Description
Summary
Write the OpenAPI documentation in the shipped API module templates as PHP attributes (#[OA\...]) instead of @OA\... annotations, and remove the abandoned doctrine/annotations package. Part of the PHP 8.1 update (#595).
Why
Composer reports doctrine/annotations as abandoned, with no replacement. It is kept only because the OpenAPI docs use annotations, and zircote/swagger-php reads annotations only when that package is installed (it is a suggestion there, not a requirement). The 3.0.3 changelog notes that it stays "on the PHP 8.0 baseline", because swagger-php's attribute scanning needs PHP 8.1. With 8.1 as the minimum, that reason is gone.
Current state
- 7 template files under
src/Module/Templates(DefaultApiandDemoApi, inControllers/OpenApi) use@OA\...annotations. None use attributes. OpenApiCommandgenerates the spec withGenerator::scan().doctrine/annotationsis required incomposer.jsonand not imported insrc.
Proposed change
- Convert the annotations in those templates to
#[OA\...]attributes. - Check that the generated spec is the same as before for the same API.
- Remove
doctrine/annotationsfromcomposer.json. - Describe the change for existing projects in the changelog and the upgrade guide.
Breaking changes
- A project whose own controllers carry
@OA\...annotations (for example generated from the earlier templates) loses its OpenAPI output oncedoctrine/annotationsis gone. It has to convert its annotations to attributes. This needs a clear upgrade note.
Out of scope
- Changing the API documentation content.
- Upgrading
zircote/swagger-php.
Acceptance criteria
- the templates use attributes only and
php qtgenerates the same OpenAPI spec as before doctrine/annotationsis no longer requiredcomposer test,composer cs:check,composer phpstanandcomposer rector:checkpass- the upgrade note explains how to convert annotations
Notes
Relevant code: src/Module/Templates/DefaultApi, src/Module/Templates/DemoApi, src/Console/Commands/OpenApiCommand.php, composer.json.
Activity
[#597] Test that the API module templates produce a valid OpenAPI spec
[#597] Write the DefaultApi OpenApiController template as attributes
[#597] Write the DefaultApi OpenApiMainController template as attributes
[#597] Write the DemoApi OpenApiController template as attributes
[#597] Update the OpenAPI documentation version of the API templates …
[#597] Write the DemoApi OpenApiCommentController template as attributes
[#597] Write the DemoApi OpenApiAccountController template as attributes
[#597] Write the DemoApi OpenApiPostController template as attributes
[#597] Write the DemoApi OpenApiAuthController template as attributes
[#597] Remove doctrine/annotations and test that the API templates us…