Provides a tight integration of the famous zircote/swagger-php
library into the Symfony full-stack framework for generating
OpenAPI spec and building Restful APIs quickly.
This bundle is especially created for API-First development.
composer require open-solid/open-api-bundle
Import the bundle's routes in config/routes.yaml
to show the Swagger API documentation:
openapi:
resource: '@OpenApiBundle/config/routes.php'
Define your OpenAPI spec and endpoint at the same time:
<?php
namespace Api\Catalog\Controller\Post;
use Api\Catalog\Model\Product;
use OpenSolid\OpenApiBundle\Attribute\Payload;
use OpenSolid\OpenApiBundle\Routing\Attribute\Post;
class PostProductAction
{
#[Post('/products')]
public function __invoke(#[Payload] PostProductPayload $Payload): Product
{
return new Product($body->name, $Payload->price);
}
}
zircote/swagger-php
)
Operation
, Schema
and Property
guessing from PHP classes and methods#[Post]
, #[Get]
, #[Put]
, #[Patch]
, #[Delete]
#[Get('/me', when: 'service("toggle_me").isEnabled()')]
#[Payload]
instead of #[MapRequestPayload]
#[Query]
instead of #[MapQueryString]
#[Path]
instead of #[PathParameter]
#[Param]
instead of #[QueryParameter]
#[Property(minLength: 3, maxLength: 255)]
open-solid/open-api-assistant-bundle
)This software is published under the MIT License