2017 © Pedro Peláez
 

symfony-bundle swagger-bundle

Makes your Swagger definition into a routing and validation spec

image

kleijnweb/swagger-bundle

Makes your Swagger definition into a routing and validation spec

  • Thursday, April 19, 2018
  • by kleijnweb
  • Repository
  • 5 Watchers
  • 24 Stars
  • 5,139 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 17 Forks
  • 7 Open issues
  • 23 Versions
  • 11 % Grown

The README.md

This project is no longer maintained

KleijnWeb\SwaggerBundle

SensioLabsInsight, (*1)

Build Status Coverage Status Scrutinizer Code Quality Latest Unstable Version Latest Stable Version, (*2)

Invert your workflow (contract first) using Swagger (Open API) specs and set up a Symfony REST app with minimal config., (*3)

Aimed to be lightweight, this bundle does not depend on FOSRestBundle or Twig., (*4)

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+., (*5)

For a working example, check out https://github.com/kleijnweb/swagger-bundle-example., (*6)

Contract First

We say your OpenAPI definition is your config, and strive towards 'minimal additional config'. At the core, SwaggerBundle does three things:, (*7)

  1. Configure Symfony routing
  2. Validate input
  3. Coerce/transform in- and output

Usage

  1. Create an OpenAPI document, for example using http://editor.swagger.io/.
  2. Install and configure this bundle
  3. Create one or more controllers (as services)

Check out the User Documentation for more details., (*8)

What's new in 4.0?

SwaggerBundle 4.0 is currently in the beta stage. Much of the behavior dealing with OpenAPI documents has been moved to KleijnWeb\PhpApi\Descriptions., (*9)

Routing

Now using kleijnweb/php-api-routing-bundle with a number of small improvements., (*10)

Security Integration

Request matching, voting, OpenAPI configured RBAC. See docs., (*11)

Serialization/Hydration

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., (*12)

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., (*13)

Testing

The dependency on SwaggerAssertions has been removed, as response validation is now facilitated by KleijnWeb\PhpApi\Descriptions and integrated into the request cycle., (*14)

Errors And Exceptions

  • 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 supports AccessDeniedException.

FAQ

  • Will SwaggerBundle do x?, (*15)

    If x is any of these, the answer will probably stay 'no':, (*16)

  • Handle Form posts., (*17)

  • Generate API documentation.
  • Support Symfony sub-requests. You won't miss them.
  • Support XML.

Symfony Compatibility

SwaggerBundle is tested against Symfony 2.8.18 and the latest release (4.x.x), at least once a week., (*18)

Notes

Go to the release page to find details about the latest release., (*19)

Contributing

Pull request are very welcome, as long as:, (*20)

  • All automated checks were successful
  • Merge would not violate semantic versioning
  • When applicable, the relevant documentation is updated

License

KleijnWeb\SwaggerBundle is made available under the terms of the LGPL, version 3.0., (*21)

The Versions