Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/open-solid/open-api-bundle
OpenAPI Symfony Bundle
https://github.com/open-solid/open-api-bundle
api-first openapi restful-api symfony-bundle
Last synced: about 1 month ago
JSON representation
OpenAPI Symfony Bundle
- Host: GitHub
- URL: https://github.com/open-solid/open-api-bundle
- Owner: open-solid
- License: mit
- Created: 2023-09-30T15:01:49.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-09T18:40:07.000Z (3 months ago)
- Last Synced: 2024-09-30T16:21:15.250Z (about 2 months ago)
- Topics: api-first, openapi, restful-api, symfony-bundle
- Language: PHP
- Homepage:
- Size: 419 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenApiBundle
Provides a tight integration of the famous [`zircote/swagger-php`](https://github.com/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.
## Installation
```bash
composer require open-solid/open-api-bundle
```Import the bundle's routes in `config/routes.yaml` to show the Swagger API documentation:
```yaml
openapi:
resource: '@OpenApiBundle/config/routes.php'
```## Basic Sample
Define your OpenAPI spec and endpoint at the same time:
```php
name, $Payload->price);
}
}
```## Main Features
- [x] Generate OpenAPI spec from PHP attributes (Mainly based on `zircote/swagger-php`)
- Automatic `Operation`, `Schema` and `Property` guessing from PHP classes and methods
- [x] Expose Swagger UI to explore the OpenAPI spec and test API endpoints
- [x] Export OpenAPI spec in JSON or YAML format (via HTTP and console command)
- [x] Import OpenAPI spec in JSON or YAML format (via config file)
- [x] Define Symfony routes and OpenAPI Paths using the same attributes:
- `#[Post]`, `#[Get]`, `#[Put]`, `#[Patch]`, `#[Delete]`
- [x] Conditional OpenAPI Path/Route definition:
- Example: `#[Get('/me', when: 'service("toggle_me").isEnabled()')]`
- [x] Symfony attributes abbreviations:
- `#[Payload]` instead of `#[MapRequestPayload]`
- `#[Query]` instead of `#[MapQueryString]`
- [x] OpenAPI attributes abbreviations:
- `#[Path]` instead of `#[PathParameter]`
- `#[Param]` instead of `#[QueryParameter]`
- [x] Symfony's validation constraints definition using OpenAPI attributes:
- Example: `#[Property(minLength: 3, maxLength: 255)]`
- [x] Automatic controller response serialization (JSON format by default)
- [ ] Generate new endpoints from API spec (WIP) (based on `open-solid/open-api-assistant-bundle`)## License
This software is published under the [MIT License](LICENSE)