https://github.com/byjg/restserver-swagger
Enable to create RESTFull services with strong model schema. The routes are automatically created from a swagger.json file.
https://github.com/byjg/restserver-swagger
Last synced: 8 months ago
JSON representation
Enable to create RESTFull services with strong model schema. The routes are automatically created from a swagger.json file.
- Host: GitHub
- URL: https://github.com/byjg/restserver-swagger
- Owner: byjg
- License: mit
- Created: 2018-01-14T19:30:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-06-15T13:17:33.000Z (over 3 years ago)
- Last Synced: 2024-10-19T13:35:49.496Z (12 months ago)
- Language: PHP
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Swagger Rest Server
[](https://scrutinizer-ci.com/g/byjg/restserver-swagger/?branch=master)
[](https://travis-ci.org/byjg/restserver-swagger)## Description
Enable to create RESTFull services with strong model schema.
The routes are automatically created from a swagger.json file.## Installation
```bash
composer require "byjg/restserver-swagger=1.0.*"
```## Basic Usage
First you need to generate a swagger.json file and the "operationId" must have the
`Namespace\\Class::method` like the example below:```json
{
...
"paths": {
"/pet": {
"post": {
"summary": "Add a new pet to the store",
"description": "",
"operationId": "PetStore\\Pet::addPet"
}
}
}
...
}
```Note: If you are using the [zircote/swagger-php](https://github.com/zircote/swagger-php)
for auto generate your JSON file from PHPDocs comments, since the version 2.0.14 it can
generate the proper "operationId" for you. Just run on command line:```bash
swagger --operationid
```After you have the proper swagger.json you need to add it to your project:
```bash
composer require "byjg/restserver-swagger=1.0.*"
```and create a `app.php` file:
```php
handle();
```### Caching the Routes
It is possible to cache the route by adding any PSR-16 instance on the second parameter of the constructor:
```php