Download the PHP package draw/open-api-bundle without Composer
On this page you can find all versions of the php package draw/open-api-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download draw/open-api-bundle
More information about draw/open-api-bundle
Files in draw/open-api-bundle
Package open-api-bundle
Short Description draw/open-api library integration into Symfony4.
License MIT
Informations about the package open-api-bundle
Draw Open Api Bundle
Integration for draw/open-api into symfony 4 bundle
The first objective is to be able to generate a Open Api v2 documentation with minimum effort by the programmer. The draw/open-api provide a multitude of extractor to get the information where it can (PHP for example).
The integration with symfony allow you to use most of the Draw\Component\OpenApi\Schema (alias @OpenApi) as annotation above your controller method to document them.
The bundle also provide some tools to provide a rest api without the need of FOSRestBundle.
Sandbox
To install the sandbox you can run
The first argument is the version to install (E.g.: v3.52.5). By default it master.
We recommend that you add this to your composer.json scripts section before the asset:install
Configuration
Here is a example of the configuration:
Controller documentation
To document a controller for Open Api you must use the @OpenApi\Tag or @OpenApi\Operation annotations.
If you plan to use the Open Api codegen we recommend using the @OpenApi\Operation since it will give you control over the operationId, otherwise it will use the route name.
Query Parameters
If you want to inject configured query parameters in a controller you must set the convertQueryParameterToAttribute to true in the configuration.
`
You must also add the annotation Draw\Component\OpenApi\Schema\QueryParameter to your controller. This will provide the documentation information for Open Api and also configure which query parameters should be injected.
View
To allow the automatic serialization of response you must active it:
`
The will detect if the return value of your controller is not a response and will serialized it according to the Draw\Bundle\OpenApiBundle\Response\Serialization annotation.
By default if there is not annotation the serializer context will not have any value and the response will be 200. Using the view allow to override the serializer groups and version, the status code of the response. The Serialization annotation is also use for the Open Api documentation, the headers attribute is use for that.
If your controller return null the status code will be set to 204 by default (not content).
The Draw\Bundle\OpenApiBundle\Response\Serialization implement Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface with a alias draw_open_api_serialization .
Instead of putting a serializerVersion on each header you can create a listener that will set the version base on something else. Here is a example of a listener that will take from the url path /api/v{number}/....:
All versions of open-api-bundle with dependencies
ext-json Version *
doctrine/annotations Version ^1.11
draw/open-api Version ^0.7.59
jms/serializer-bundle Version ^3.7
symfony/framework-bundle Version ^4.4 || ^5.4