The Laravel OpenAPI Generator service provider publishes two groups of assets: configuration files and template files. This guide explains what gets published, how to customize them, and best practices.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.
Configuration Files
Publish all configuration files with a single command:Published Files
This command publishes four configuration files to yourconfig/ directory:
config/openapi.php
config/openapi.php
Main configuration file containing:
- OpenAPI metadata (title, version, contact, license)
- Server definitions for different environments
- Security scheme definitions (Bearer, API Key, etc.)
- Hierarchical environments for Postman/Insomnia
- API type configurations (admin, site, mobile)
- Module scanning paths and exclusions
- Cache settings
- Output path configuration
- Model and request class paths
- Route filtering and exclusions
- Middleware to security mapping
- Default response examples
- HTTP route configuration
config/openapi.phpconfig/openapi-docs.php
config/openapi-docs.php
CRUD and entity documentation configuration containing:
- CRUD template definitions (summary, description, response templates)
- Entity metadata (singular/plural names, model classes, descriptions)
- Custom endpoint documentation
- Auto-detection settings for fields and relationships
- Field description overrides
- Field example overrides
config/openapi-docs.phpconfig/openapi-templates.php
config/openapi-templates.php
Template system configuration containing:
- Template system enable/disable toggle
- Template directory paths (generic and custom)
- Generic template mappings for actions
- Query builder documentation settings
- Auto-detection configuration for models
- Rendering options (debug, validation, caching)
- Example generation settings
- Performance limits and caching
config/openapi-templates.phpconfig/openapi-tests.php
config/openapi-tests.php
Test generation configuration containing:
- Test template definitions for CRUD actions
- Test script snippets for Postman
- Test script snippets for Insomnia
- Custom test overrides for specific endpoints
- Verbose logging settings
config/openapi-tests.phpCustomizing Configuration
After publishing, you can customize any configuration values:Configuration changes take effect immediately. If caching is enabled, you may need to clear the cache:
Template Files
Publish template files separately:Published Template Structure
Templates are published toresources/openapi/templates/ with the following structure:
Template Types
Generic Templates
Generic Templates
Location:
resources/openapi/templates/generic/Generic templates define documentation structure for common CRUD operations:index.json: List/paginated collection endpointsshow.json: Single resource retrievalstore.json: Resource creationupdate.json: Resource updatesdestroy.json: Resource deletion
generic/show.jsonCustom Templates
Custom Templates
Location:
resources/openapi/templates/custom/Custom templates allow you to define documentation for non-CRUD endpoints or override generic templates for specific resources.Example: custom/users_login.jsonTemplate Placeholders
Templates support automatic placeholder replacement:| Placeholder | Replaced With | Example |
|---|---|---|
{{model}} | Model class name | User |
{{singular}} | Singular entity name | user |
{{plural}} | Plural entity name | users |
{{table}} | Database table name | users |
{{primaryKey}} | Primary key field | id |
{{fields}} | Model fields | Auto-generated from model |
{{relationships}} | Model relationships | Auto-generated from model |
Placeholders are automatically extracted from your models using reflection and database schema inspection.
Publishing Workflow
Initial Setup
When setting up a new project:Updating Published Assets
When updating the package to a new version:File Locations Reference
Configuration Files
| File | Location | Purpose |
|---|---|---|
openapi.php | config/openapi.php | Main configuration |
openapi-docs.php | config/openapi-docs.php | CRUD and entity docs |
openapi-templates.php | config/openapi-templates.php | Template system |
openapi-tests.php | config/openapi-tests.php | Test generation |
Template Files
| Directory | Location | Purpose |
|---|---|---|
| Generic templates | resources/openapi/templates/generic/ | CRUD templates |
| Custom templates | resources/openapi/templates/custom/ | Custom endpoint templates |
Generated Output
| Type | Location | Description |
|---|---|---|
| OpenAPI specs | storage/app/public/openapi/openapi/ | JSON/YAML specifications |
| Postman collections | storage/app/public/openapi/postman/ | Postman collection files |
| Insomnia collections | storage/app/public/openapi/insomnia/ | Insomnia workspace files |
Output location can be customized via the
openapi.output_path configuration option.Advanced Customization
Custom Security Schemes
Add OAuth2, OpenID Connect, or custom authentication:config/openapi.php
Multiple API Versions
Document multiple API versions simultaneously:config/openapi.php
Custom Response Schemas
Add custom response schemas for your API:config/openapi.php
Environment-Specific Servers
Define servers for different deployment environments:config/openapi.php
Best Practices
Version Control
Version Control
Commit published files to version control:This ensures all team members use the same configuration.
Environment-Specific Overrides
Environment-Specific Overrides
Use Then set different values per environment:
.env for environment-specific values:config/openapi.php
.env.production
Selective Publishing
Selective Publishing
Publish only what you need:You don’t need to publish templates unless you’re customizing them.
Documentation
Documentation
Document your customizations:Add comments to your config files explaining custom settings:
config/openapi.php
Template Inheritance
Template Inheritance
Use custom templates sparingly:Only create custom templates when generic templates don’t fit. This reduces maintenance burden when the package is updated.Good:Avoid:
Troubleshooting
Config files not updating
Config files not updating
Problem: Changes to config files don’t take effect.Solution: Clear configuration cache:
Templates not found
Templates not found
Problem: Generator can’t find custom templates.Solution: Verify template paths in Ensure directories exist:
config/openapi-templates.php:Publishing overwrites customizations
Publishing overwrites customizations
Problem: Re-publishing overwrites your changes.Solution: Use version control and selective merging: