Download the PHP package draw/swagger-bundle without Composer
On this page you can find all versions of the php package draw/swagger-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download draw/swagger-bundle
More information about draw/swagger-bundle
Files in draw/swagger-bundle
Package swagger-bundle
Short Description draw/swagger library integration into Symfony4.
License MIT
Informations about the package swagger-bundle
draw-swagger-bundle
Integration for draw/swagger into symfony 4 bundle
The first objective is to be able to generate a swagger documentation with minimum effort by the programmer. The draw/swagger provide a multitude of extractor to get the information where it can (PHP for example).
The integration with symfony allow you to use must of the Draw\Swagger\Schema (alias @Swagger) 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.
FOSRestBundle integration is provided by the DrawSwaggerBundle but it will be removed to reduce the scope of this bundle.
Configuration
Here is a example of the configuration:
Controller documentation
To document a controller for swagger you must use the @Swagger\Tag or @Swagger\Operation annotations.
If you plan to use the swagger codegen we recommend using the @Swagger\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\Swagger\Schema\QueryParameter to your controller. This will provide the documentation information for swagger 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\SwaggerBundle\View\View 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 View annotation is also use for the swagger 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\SwaggerBundle\View\View extends from Sensio\Bundle\FrameworkExtraBundle\Configuration\Template so you can access it the same way by using the .
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 swagger-bundle with dependencies
ext-json Version *
draw/swagger Version dev-master
draw/draw-bundle Version dev-master
doctrine/annotations Version ~1.0
symfony/config Version ~3.4|~4.3|~5.0
symfony/framework-bundle Version ^4.3
jms/serializer-bundle Version @stable