Skip to main content
This guide covers advanced features for customizing and optimizing your documentation generation workflow.

API Type Filtering

API types allow you to segment your routes into logical groups (e.g., admin, mobile, public). Each API type can have its own prefix, folder structure, and enable/disable toggle.

Configuring API Types

Define API types in config/openapi.php:
Routes are matched by the prefix value. A route like /admin/users matches the admin API type.

Filtering at Runtime

Filenames include the API type suffix:
  • openapi-admin.json
  • postman-mobile.json

Legacy API Type Aliases

The package normalizes the legacy alias movile to mobile for backwards compatibility. You’ll see a deprecation warning if you use it:
Update your commands and scripts to use mobile.

Environment Management

Environments define base URLs, authentication tokens, and other variables for different deployment stages (local, staging, production).

Configuring Environments

Define environments in config/openapi.php:

Selecting Environments

1

Via CLI

If the specified environment doesn’t exist, the generator falls back to artisan:
2

Via HTTP

3

Environment Files

The generator creates separate environment files for Postman:
  • postman-env-artisan.json
  • postman-env-local.json
  • postman-env-production.json
Each file includes base + tracking variables merged with sub-environment values.
Tracking variables like api_token are automatically included in all environments. Define them once in tracking_variables instead of repeating them in each sub-environment.

Caching

The generator caches OpenAPI specifications to improve performance for large applications.

Cache Configuration

Disabling Cache

When to disable caching:
  • During active development with frequent route changes
  • After adding or modifying FormRequest validation rules
  • In queue workers that should always regenerate fresh documentation
  • When testing documentation accuracy
Cached output becomes stale when you add routes, modify request validation, or update custom endpoint documentation.

Cache Keys

The generator builds cache keys from:
  • API type filters
  • Environment name
  • Generation type (openapi, postman, insomnia)
This means filtering by different API types creates separate cache entries.

Custom Output Paths

Override the default output directory:
Specifies the exact file path for the OpenAPI specification.
The generator automatically creates parent directories if they don’t exist.

Template-Driven Documentation

The template system allows you to standardize descriptions, summaries, and request/response documentation across CRUD operations.

Enabling Templates

Publish and enable template processing:
Configure in config/openapi-templates.php:

Template Structure

Generic templates define reusable documentation for standard CRUD actions:

Custom Endpoint Documentation

For non-CRUD endpoints, define custom documentation in config/openapi-docs.php:
Use the pattern entity.action for keys. The generator matches these against route names like api-apps.rotate or users.export.

Template Processing Flow

1

Route Introspection

The generator extracts route metadata: path, methods, parameters, FormRequests.
2

Template Selection

  • Check for custom endpoint documentation by route name
  • If not found, match CRUD action (list, show, create, update, delete)
  • Load corresponding generic template
3

Placeholder Replacement

Replace placeholders like {{entity_singular}} and {{entity_plural}} with actual values.
4

Merge with Metadata

Combine template content with extracted FormRequest validation rules and model properties.
Template ValidationInvalid JSON in template files causes generation to fail. Enable output validation during debugging:
This adds extra validation but slows generation.

Excluding Routes

Prevent specific routes from appearing in documentation:
Patterns support wildcards. Routes matching any pattern are excluded from all generated documentation.

Programmatic Generation Advanced

For complex use cases, you can directly access generation services:
OpenApiServices
  • Route introspection and filtering
  • Caching
  • OpenAPI specification assembly
PostmanCollectionGenerator
  • Converts OpenAPI spec to Postman Collection v2.1 format
  • Embeds environment variables
InsomniaWorkspaceGenerator
  • Converts OpenAPI spec to Insomnia v4 format
  • Creates workspace with spec, collection, and test tabs
EnvironmentGenerator
  • Merges base + tracking + sub-environment variables
  • Generates environment files for Postman and Insomnia

Next Steps

Common Scenarios

Real-world examples including team workflows and CI/CD integration.

Edge Cases

Handling config caching, concurrent generation, and multi-tenant deployments.