Skip to main content
This guide covers the fundamental ways to generate OpenAPI, Postman, and Insomnia documentation from your Laravel routes.

Generate via Artisan

The simplest way to generate documentation is using the openapi:generate Artisan command:
The --all flag generates OpenAPI + Postman + Insomnia for all API types in a single command.

Output Location

By default, files are written to storage/app/public/openapi/. The generator creates these files:
  • openapi.json - OpenAPI 3.0.3 specification
  • postman-all.json - Postman collection (when using --with-postman or --all)
  • insomnia-all.json - Insomnia workspace (when using --with-insomnia or --all)
  • postman-env-*.json - Environment files for artisan, local, and production

Common CLI Options

1

Generate specific formats

Use format flags to control which documentation types are generated:
2

Filter by API type

Generate documentation for specific API segments:
API types must be defined and enabled in config/openapi.php under the api_types key.
3

Choose output format

Specify JSON or YAML for the OpenAPI specification:

Expected CLI Output

When you run the command successfully, you’ll see output like this:

Generate via HTTP Routes

When openapi.routes.enabled is set to true in your configuration, the package automatically registers HTTP endpoints for on-demand documentation generation.

Available Endpoints

Returns an OpenAPI 3.0.3 specification document.

Query Parameters

Filter documentation using query parameters:
HTTP endpoints generate documentation in real-time. For large route sets, this may cause timeouts. Consider generating via CLI and serving static files instead.

Configuring HTTP Routes

Configure the HTTP endpoints in config/openapi.php:
Leave middleware empty for public documentation, or add ['auth:sanctum'] to protect endpoints.

Generate Programmatically

You can generate documentation from your own code using the OpenApiGenerator service:

Filtering Programmatically

Apply filters before generation:
  • Custom build pipelines: Generate docs during deployment
  • On-demand generation: Create documentation when certain events occur
  • Multi-tenant apps: Generate per-tenant documentation with different configurations
  • Testing: Verify documentation structure in automated tests

Validating Output

After generation, validate your OpenAPI specification:
1

Open in Swagger Editor

Visit editor.swagger.io and import your openapi.json or openapi.yaml file.
2

Import to Postman

  1. Open Postman
  2. Click File > Import
  3. Upload the generated postman-all.json
  4. Import each postman-env-*.json environment file
  5. Select an environment from the dropdown
3

Import to Insomnia

  1. Open Insomnia
  2. Click Import/Export > Import Data > From File
  3. Select the generated insomnia-all.json
  4. Environments are automatically included

Route Counting

The generator reports unique paths, not individual HTTP methods. For example:
This means 47 distinct URL patterns were found. A single path like /api/users/{id} may have multiple methods (GET, PUT, DELETE), but counts as one path.
If you see ⚠️ No routes found matching the specified filters, check your API type configuration and ensure routes exist with the expected prefixes.

Next Steps

Advanced Usage

Explore templates, caching, custom output paths, and programmatic filtering.

Common Scenarios

Real-world examples including multi-API generation and CI/CD workflows.