Laravel OpenAPI Generator
Generates OpenAPI 3.0, 3.1 and 3.2 documents from a Laravel application, its routes, form requests and resources.
return [
'title' => 'required|string|max:255',
'price' => 'required|numeric|min:0',
'tags' => 'array',
'tags.*' => 'string|distinct',
];
{
"type": "object",
"required": ["title", "price"],
"properties": {
"title": { "type": "string", "maxLength": 255 },
"price": { "type": "number", "minimum": 0 },
"tags": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true
}
}
}
Why Laravel OpenAPI Generator
A hand-written OpenAPI file is out of date at the next pull request. Your application already says what its API accepts and returns; the generator reads it and writes the document, in OpenAPI 3.0, 3.1 or 3.2, one document per API or per audience.
Read from the code
Routes, middlewares, return types and PHPDoc are the documentation; attributes complete what cannot be inferred.
Bodies from the validation rules
Every rule of your form requests becomes a constraint of the schema, and the 422 is documented.
Compatibility
A Laravel package: php artisan openapi:generate writes every document of the configuration.
| Version | PHP | Laravel | Status |
|---|---|---|---|
| 1.x | ^8.3 | ^13.0 | Active |
| 0.6 | ^8.1 | ^10.0 || ^11.0 || ^12.0 || ^13.0 | End of life |
Start with Laravel OpenAPI Generator
Install it, follow the quick start, and see your first result in minutes.
Works with
ark4ne/laravel-json-api