Integrations

OpenAPI

Generate OpenAPI documents of your JSON:API endpoints from the definitions of your resources.

Every resource has a public definition (PostResource::definition()): its type, the type of each value, its relationships and their related resources, links and meta. Tools read it instead of guessing.

Laravel OpenAPI Generator
Generates OpenAPI 3.0, 3.1 and 3.2 documents from a Laravel application, its routes, form requests and resources.
v1.2.0ark4ne/laravel-openapi-generator

With Laravel OpenAPI Generator installed, your resources are documented as JSON:API resource objects in application/vnd.api+json:

  • the descriptors give the types and constraints of the attributes ($this->string(), $this->date(), $this->struct()…), with their describe(), example() and deprecated();
  • the Includes and Fields rules of your form requests give the include and fields[type] parameters;
  • the relationships give the included resources and their links;
  • with JsonApi::renderErrors(), the error responses are JSON:API error documents.

With API revisions, each revision of the API is its own OpenAPI document, read at that revision.

Terminal
composer require ark4ne/laravel-openapi-generator
php artisan openapi:generate

See its JSON:API integration for the settings.