This PHP library allows you to cut and organize your HUGE openapi.yml
file, into small slices.
Versioning and deploy your OpenAPI documentation become easier.
composer require th3mouk/openapi-generator
Inside your project you can now run additional commands:
vendor/bin/openapi scaffold
vendor/bin/openapi generate
To prepare your project, run the first command scaffold
.
It will create new folders.
specs
├── components
│ ├── schemas
│ ├── responses
│ ├── parameters
│ ├── examples
│ ├── requestBodies
│ ├── headers
│ ├── securitySchemes
│ ├── links
│ └── callbacks
└── paths
I personnaly use Swagger OpenAPI specifications to write my schema.
One example of organization can be :
specs
├── components
└── paths
├── authentication
│ ├── login.yaml
│ └── register.yaml
└── unicorn
├── list.yaml
└── detail.yaml
The command vendor/bin/openapi generate
take arguments and options to generate the openapi.yml
file.
You can add a path like this vendor/bin/openapi generate /in-this-folder/sub
And it exists a --pretty-json
or -p
option to obtain a human readable file.
Feel free to improve this library.