Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/charlietyn/openapi-generator/llms.txt

Use this file to discover all available pages before exploring further.

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.
APP_NAME
string
default:"Laravel"
Your application name. Used in:
  • openapi.info.title: API documentation title
  • Placeholder replacement: ${{projectName}} in URLs
APP_NAME="My Amazing API"
APP_URL
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
APP_URL=http://localhost:8000
API_VERSION
string
default:"1.0.0"
Your API version string. Appears in:
  • openapi.info.version: OpenAPI specification version
  • API documentation header
API_VERSION=2.1.0

Contact Information

These variables define support contact details in your API documentation.
API_CONTACT_NAME
string
default:"API Support"
Support contact name displayed in API documentation.
API_CONTACT_NAME="Engineering Team"
API_CONTACT_EMAIL
string
default:"support@example.com"
Support contact email address.
API_CONTACT_EMAIL=api-support@mycompany.com
API_CONTACT_URL
string
default:"https://example.com/support"
URL to your support portal or documentation.
API_CONTACT_URL=https://docs.mycompany.com/support

Cache Configuration

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

Route Configuration

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

Template System

Control the JSON template engine for advanced documentation customization.
OPENAPI_TEMPLATES_ENABLED
boolean
default:"true"
Enable or disable the template system.
OPENAPI_TEMPLATES_ENABLED=true
OPENAPI_TEMPLATES_DEBUG
boolean
default:"false"
Enable debug output for template rendering.
OPENAPI_TEMPLATES_DEBUG=true
Useful for troubleshooting template rendering issues during development.
OPENAPI_TEMPLATES_VALIDATE
boolean
default:"true"
Validate template output against OpenAPI schema.
OPENAPI_TEMPLATES_VALIDATE=true
OPENAPI_TEMPLATES_CACHE
boolean
default:"true"
Cache rendered templates for better performance.
OPENAPI_TEMPLATES_CACHE=true
OPENAPI_TEMPLATE_CACHE_TTL
integer
default:"3600"
Template cache time-to-live in seconds.
OPENAPI_TEMPLATE_CACHE_TTL=7200
# Full debugging with no caching
OPENAPI_TEMPLATES_ENABLED=true
OPENAPI_TEMPLATES_DEBUG=true
OPENAPI_TEMPLATES_VALIDATE=true
OPENAPI_TEMPLATES_CACHE=false

Test Generation

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

Complete Example: .env File

Here’s a complete example showing all OpenAPI Generator environment variables:
# Application
APP_NAME="My API"
APP_URL=http://localhost:8000

# API Information
API_VERSION=1.0.0
API_CONTACT_NAME="Dev Team"
API_CONTACT_EMAIL=dev@myapi.com
API_CONTACT_URL=https://docs.myapi.com

# Cache (Disabled for development)
OPENAPI_CACHE_ENABLED=false

# Routes (Open access)
OPENAPI_ROUTES_ENABLED=true
OPENAPI_ROUTES_PREFIX=docs
OPENAPI_ROUTES_MIDDLEWARE=""

# Templates (Debug mode)
OPENAPI_TEMPLATES_ENABLED=true
OPENAPI_TEMPLATES_DEBUG=true
OPENAPI_TEMPLATES_VALIDATE=true
OPENAPI_TEMPLATES_CACHE=false

# Tests
OPENAPI_TESTS_VERBOSE=true

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
'info' => [
    'title' => 'My API',  // Hard-coded instead of env('APP_NAME')
    'version' => '2.0.0', // Hard-coded instead of env('API_VERSION')
],

Quick Reference

VariableConfig KeyDefaultPurpose
APP_NAMEopenapi.info.title'Laravel'API title
APP_URLopenapi.environments.base.variables.base_url'http://localhost'Base URL
API_VERSIONopenapi.info.version'1.0.0'API version
API_CONTACT_NAMEopenapi.info.contact.name'API Support'Contact name
API_CONTACT_EMAILopenapi.info.contact.email'support@example.com'Contact email
API_CONTACT_URLopenapi.info.contact.url'https://example.com/support'Contact URL
OPENAPI_CACHE_ENABLEDopenapi.cache.enabledtrueEnable caching
OPENAPI_CACHE_TTLopenapi.cache.ttl3600Cache TTL (seconds)
OPENAPI_ROUTES_ENABLEDopenapi.routes.enabledtrueEnable routes
OPENAPI_ROUTES_PREFIXopenapi.routes.prefix'documentation'Route prefix
OPENAPI_ROUTES_MIDDLEWAREopenapi.routes.middleware''Route middleware
OPENAPI_TEMPLATES_ENABLEDopenapi-templates.enabledtrueEnable templates
OPENAPI_TEMPLATES_DEBUGopenapi-templates.rendering.debugfalseDebug templates
OPENAPI_TEMPLATES_VALIDATEopenapi-templates.rendering.validate_outputtrueValidate output
OPENAPI_TEMPLATES_CACHEopenapi-templates.rendering.cache_enabledtrueCache templates
OPENAPI_TEMPLATE_CACHE_TTLopenapi-templates.rendering.cache_ttl3600Template cache TTL
OPENAPI_TESTS_VERBOSEopenapi-tests.verbose_loggingfalseVerbose test logs