Skip to main content
The Laravel OpenAPI Generator reads environment variables through configuration files. Set these in your .env file to customize behavior without modifying config files.

Core Variables

These variables control basic API information and metadata.
string
default:"Laravel"
Your application name. Used in:
  • openapi.info.title: API documentation title
  • Placeholder replacement: ${{projectName}} in URLs
string
default:"http://localhost"
Your application’s base URL. Used in:
  • openapi.environments.base.variables.base_url: Base environment URL
  • Server definitions for local development
string
default:"1.0.0"
Your API version string. Appears in:
  • openapi.info.version: OpenAPI specification version
  • API documentation header

Contact Information

These variables define support contact details in your API documentation.
string
default:"API Support"
Support contact name displayed in API documentation.
string
default:"support@example.com"
Support contact email address.
string
default:"https://example.com/support"
URL to your support portal or documentation.

Cache Configuration

Control caching behavior for generated OpenAPI specifications.
boolean
default:"true"
Enable or disable caching of generated specifications.
Disable caching during development for immediate reflection of changes:
integer
default:"3600"
Cache time-to-live in seconds (default: 1 hour).

Route Configuration

Control HTTP endpoints that serve OpenAPI documentation.
boolean
default:"true"
Enable or disable HTTP documentation endpoints.
Set to false in production if you don’t want to expose documentation routes.
string
default:"documentation"
URL prefix for documentation routes.
Results in routes like:
  • /api-docs/openapi.json
  • /api-docs/postman/collection.json
string
default:""
Comma-separated list of middleware to apply to documentation routes.
Empty string means no middleware. Add auth to require authentication for viewing docs.

Template System

Control the JSON template engine for advanced documentation customization.
boolean
default:"true"
Enable or disable the template system.
boolean
default:"false"
Enable debug output for template rendering.
Useful for troubleshooting template rendering issues during development.
boolean
default:"true"
Validate template output against OpenAPI schema.
boolean
default:"true"
Cache rendered templates for better performance.
integer
default:"3600"
Template cache time-to-live in seconds.

Test Generation

Control test script generation for Postman and Insomnia.
boolean
default:"false"
Enable verbose logging for test generation.
Helpful for debugging test script generation issues.

Complete Example: .env File

Here’s a complete example showing all OpenAPI Generator environment variables:

Runtime vs Cached Configuration

This package uses env() directly in some runtime code (e.g., environment generation and placeholder replacement).If you use php artisan config:cache, some environment variables may not be read at runtime. Prefer overriding configuration keys in config/openapi.php instead.

Safe with config:cache

These are read once during config caching:
  • All openapi.php config values
  • All template system settings
  • Cache and route configurations

Requires runtime access

These may need runtime env() access:
  • Placeholder replacement in URLs (${{projectName}})
  • Dynamic environment variable generation
Solution: Override values directly in the published config file:
config/openapi.php

Quick Reference