Documents

Several documents

Generate several OpenAPI documents from one application, by API version, by audience or by OpenAPI version.

documents holds as many documents as you need. Each one has its own routes, version, info, security and output, and openapi:generate writes all of them.

One document per API version

config/openapi.php
'documents' => [
    'v1' => [
        'info' => ['title' => 'Shop API', 'version' => '1.4.0'],
        'routes' => ['include' => ['api/v1/*']],
    ],
    'v2' => [
        'info' => ['title' => 'Shop API', 'version' => '2.0.0'],
        'routes' => ['include' => ['api/v2/*']],
    ],
],
Terminal
php artisan openapi:generate              # every document
php artisan openapi:generate --document=v2

A key a document leaves out takes its default: here both are OpenAPI 3.1.2, and both are written with the global output.file, {document}.json: openapi/v1.json and openapi/v2.json. (The published v1 overrides its own file, openapi-{document}.json; see Output.)

One document per audience

The route masks can select by name, domain or middleware; a public document and a partner document can share the same URIs:

config/openapi.php
'documents' => [
    'public' => [
        'info' => ['title' => 'Public API', 'version' => '1.0.0'],
        'routes' => [
            'include' => ['api/*'],
            'exclude' => ['middleware' => ['partner']],
        ],
    ],
    'partners' => [
        'info' => ['title' => 'Partner API', 'version' => '1.0.0'],
        'routes' => ['include' => ['middleware' => ['partner']]],
        'security_schemes' => [
            'partnerKey' => [
                'type' => 'apiKey',
                'name' => 'X-Partner-Key',
                'in' => 'header',
            ],
        ],
        'security' => ['partnerKey'],
    ],
],

One document per OpenAPI version

The same routes written for a modern tool and for an older code generator:

config/openapi.php
'documents' => [
    'v1' => [
        'openapi' => '3.1.2',
        'info' => ['title' => 'Shop API', 'version' => '1.0.0'],
    ],
    'v1-legacy' => [
        'openapi' => '3.0.4',
        'vendor_extensions' => 'redoc',
        'info' => ['title' => 'Shop API', 'version' => '1.0.0'],
    ],
],

Each document is generated on its own: its components, its diagnostics and its samples are its own.

Settings of the integrations Since 1.2

integrations gives the settings of each integration for one document, by the key of the integration. With ark4ne/laravel-json-api 3.x, each revision of the API is a document:

config/openapi.php
'documents' => [
    'v2026-09' => [
        'info' => ['title' => 'API', 'version' => '2026-09-01'],
        'integrations' => [
            'json_api' => ['revision' => App\Http\ApiRevision::Initial],
        ],
    ],
],

A setting no available integration reads is a warning. See API revisions.