Skip to main content
Answers to common questions about using Laravel OpenAPI Generator.

General Questions

No. The package only inspects routes to generate documentation. It does not:
  • Modify route definitions
  • Change route behavior
  • Add or remove routes
  • Affect route performance
The package reads your registered routes, analyzes their metadata (controllers, middleware, FormRequests), and generates OpenAPI specifications based on that information.Your application routes remain completely unchanged.
Yes. You can disable HTTP endpoints entirely and serve static files instead.In config/openapi.php:
Then generate documentation files via CLI and serve them statically:
Access the static file at https://your-app.test/api-docs/openapi.json
This approach is recommended for production environments to avoid on-demand generation overhead.
Yes. You have multiple customization options:1. Custom endpoint metadata via config/openapi-docs.php:
2. Template customization in resources/openapi/templates/:
Then edit:
  • resources/openapi/templates/openapi.json - OpenAPI spec template
  • resources/openapi/templates/postman.json - Postman collection template
  • resources/openapi/templates/insomnia.json - Insomnia workspace template
3. Configuration overrides in config/openapi.php:
Yes. You can define and filter by multiple API types.Configuration (config/openapi.php):
Tag routes with API types:
Filter by API type when generating:
HTTP endpoints support filtering via query parameters:

Performance & Caching

Several optimization strategies are available:1. Enable caching:
2. Use API type filters:
3. Exclude unnecessary routes:
4. Generate offline and serve static files:
5. Use queue workers for generation:
For large applications (100+ routes), always prefer static file generation over on-demand HTTP generation.
Clear the OpenAPI cache when:
  • Adding new routes
  • Modifying route definitions (paths, methods, middleware)
  • Updating FormRequest validation rules
  • Changing controller docblocks
  • Modifying configuration (config/openapi.php)
  • After deployments
How to clear:
In development environments, consider setting a short cache TTL (300 seconds) or disabling caching entirely:
Impact depends on how you use the package:Minimal impact when:
  • Using cached specifications
  • Generating via CLI and serving static files
  • Generating in background jobs
⚠️ Potential impact when:
  • Generating on-demand via HTTP without caching
  • Processing 100+ routes with complex FormRequests
  • Using deep route introspection
Best practices for production:
  1. Generate during deployment:
  2. Serve static files:
  3. Enable aggressive caching:
  4. Use CDN for documentation files: Host generated JSON/YAML files on a CDN instead of serving from your application.

Compatibility

The package supports:
  • Laravel 10.x
  • Laravel 11.x
Minimum requirements:
  • PHP 8.1+
  • Composer 2.0+
Check the composer.json of the package for exact version constraints:
Yes. The package can introspect Laravel API Resources.When your controller returns a resource:
The generator will:
  1. Detect the resource class
  2. Extract the resource structure from toArray()
  3. Generate schema definitions
For better results, add docblock annotations:
Or use metadata configuration:
Yes. The package automatically detects auth middleware and adds security schemes.Sanctum (automatically detected):
Generated security definition:
Custom configuration:
The package currently generates OpenAPI 3.0.3 specifications.OpenAPI 3.1 support depends on:
  • Underlying spec library updates
  • Community demand
Key differences between 3.0 and 3.1:
  • JSON Schema 2020-12 compatibility
  • Webhooks support
  • Improved $ref handling
Most API consumers (Swagger UI, Postman, Insomnia) fully support OpenAPI 3.0.3, so compatibility is not usually an issue.
If you need OpenAPI 3.1 features, you can post-process the generated JSON with custom scripts or create a GitHub issue to request this feature.

Multi-Environment & Deployment

The package has built-in environment support:1. Define environments in config/openapi.php:
2. Generate for specific environment:
3. Access via HTTP:
4. Generate environment files for Postman:
This creates:
  • postman-env-local.json
  • postman-env-staging.json
  • postman-env-production.json
It depends on your workflow:Commit generated files if:
  • You want versioned API documentation
  • Your CI/CD doesn’t run PHP/Composer
  • You distribute specs to external teams
  • You use Git-based documentation hosting (GitHub Pages, etc.)
Don’t commit if:
  • You generate during deployment
  • Files are large and change frequently
  • You prefer build-time generation
Recommendation: Add to .gitignore:
And generate during deployment:
For multi-tenant setups where each tenant has different:
  • API endpoints
  • Server URLs
  • API titles/descriptions
Approach 1: Generate per-tenant documentation:
Approach 2: Dynamic server URLs in templates:
Approach 3: Serve different specs based on request:

Integration & Export

Yes. The package natively supports multiple formats:Generate Postman collection:
Or generate all formats:
Generated files:
  • postman-api.json - Postman collection
  • postman-env-local.json - Environment variables
  • postman-env-production.json
  • insomnia-api.json - Insomnia workspace (with environments included)
Import into Postman:
  1. Open Postman
  2. File → Import
  3. Upload postman-api.json
  4. Import each environment file (postman-env-*.json)
  5. Select environment from dropdown
Import into Insomnia:
  1. Open Insomnia
  2. Application → Import/Export → Import Data
  3. From File → Select insomnia-api.json
  4. Environments are automatically included
The Insomnia workspace includes a “Minimal API Spec” tab and automated tests, making it a complete API testing solution.
Yes. You can serve the generated OpenAPI spec with Swagger UI:Option 1: Use existing HTTP endpoint:
Option 2: Generate and serve static files:
Then host Swagger UI to read from /swagger/openapi.json.Option 3: Use a Laravel package:Install a Swagger UI package like l5-swagger or swagger-ui-php that can consume the generated spec.
Yes. You have multiple ways to add custom examples:1. Via docblock annotations (if supported by your setup):
2. Via metadata configuration (config/openapi-docs.php):
3. Via FormRequest scenarios:The package auto-generates validation examples from FormRequest rules. You can customize these by providing scenario-specific examples in your configuration.

Getting More Help

Still have questions?