Invert your workflow (contract first) using Swagger (Open API) specs and set up a Symfony REST app with minimal config.
Aimed to be lightweight, this bundle does not depend on FOSRestBundle or Twig.
HEADS UP: You are looking at the main (4.0 BETA) development line, which is PHP 7 only. SwaggerBundle 3.x is stable, maintained, and works with PHP 5.4+.
For a working example, check out https://github.com/kleijnweb/swagger-bundle-example.
We say your OpenAPI definition is your config, and strive towards 'minimal additional config'. At the core, SwaggerBundle does three things:
- Configure Symfony routing
- Validate input
- Coerce/transform in- and output
- Create an OpenAPI document, for example using http://editor.swagger.io/.
- Install and configure this bundle
- Create one or more controllers (as services)
Check out the User Documentation for more details.
SwaggerBundle 4.0 is currently in the beta stage. Much of the behavior dealing with OpenAPI documents has been moved to KleijnWeb\PhpApi\Descriptions.
Now using kleijnweb/php-api-routing-bundle with a number of small improvements.
Request matching, voting, OpenAPI configured RBAC. See docs.
Support for 3rd party serializers has been replaced by a new API Description Based (de-)hyrator. Hydrating of untyped data is expected to be stdClass|stdClass[]
, not a combination of arrays and associative arrays as was the <4.0
default.
The new procoess has support for JSON-Schema specifics such as default values and smart NULL/undefined handling, as well as high extensibility. This allows you to hook pretty much anything you like into the (de-)hydration process, such as loading objects to be populated with request values from a data store or preserving identity of objects that occur more than once in a request.
The dependency on SwaggerAssertions
has been removed, as response validation is now facilitated by KleijnWeb\PhpApi\Descriptions
and integrated into the request cycle.
vnd.error
support has been removed in favor of simpler error responses. This also gets rid of some dependencies that were unneeded for most use cases.HttpError
now supportsAccessDeniedException
.
- Will SwaggerBundle do
x
?
If x
is any of these, the answer will probably stay 'no':
- Handle Form posts.
- Generate API documentation.
- Support Symfony sub-requests. You won't miss them.
- Support XML.
SwaggerBundle is tested against Symfony 2.8.18 and the latest release (4.x.x), at least once a week.
Go to the release page to find details about the latest release.
Pull request are very welcome, as long as:
- All automated checks were successful
- Merge would not violate semantic versioning
- When applicable, the relevant documentation is updated
KleijnWeb\SwaggerBundle is made available under the terms of the LGPL, version 3.0.