Scenario 1: Generate Admin + Mobile Docs from CLI
Goal: Produce OpenAPI + Postman + Insomnia outputs only foradmin and mobile APIs.
Setup
Define API types inconfig/openapi.php:
Execution
1
Publish configuration
config/openapi.php where you can customize API types, routes, and environments.2
Run the generator
Notes
- Filenames include the filtered API type suffix (
admin-mobile) - The generator validates that API types are enabled in config
- Both Postman and Insomnia files include embedded environment variables
Common Mistakes
Scenario 2: Serve Docs Over HTTP for Internal Tooling
Goal: Allow internal consumers (mobile apps, frontend teams, partner APIs) to fetch documentation via HTTP routes.Setup
Enable routes inconfig/openapi.php:
Execution
- OpenAPI JSON
- OpenAPI YAML
- Filtered by API Type
- Postman Collection
Notes
- HTTP endpoints use the same generation logic as the CLI
- Documentation is generated on-demand (not served from static files)
- Query parameters apply the same filters as CLI flags
Common Mistakes
Scenario 3: Custom Endpoint Documentation
Goal: Document a non-CRUD endpoint likeapi-apps.rotate with custom descriptions and request fields.
Setup
Add custom endpoint configuration inconfig/openapi-docs.php:
Execution
1
Define route with name
Ensure your route has a name matching the custom endpoint key:
2
Regenerate documentation
3
Verify in OpenAPI output
Open
storage/app/public/openapi/openapi.json and find your endpoint:Notes
- Use the
entity.actionpattern for keys - Custom endpoints override template-generated documentation
request_fieldsare merged with FormRequest validation rules
Common Mistakes
Scenario 4: Template-Driven CRUD Documentation
Goal: Standardize list/show/create/update/delete descriptions using JSON templates to avoid repetitive manual documentation.Setup
1
Publish templates
resources/openapi/templates/generic/list.jsonresources/openapi/templates/generic/show.jsonresources/openapi/templates/generic/create.jsonresources/openapi/templates/generic/update.jsonresources/openapi/templates/generic/delete.json
2
Enable template system
In
config/openapi-templates.php:3
Customize templates
Edit
resources/openapi/templates/generic/list.json:Execution
Generate documentation:GET /users→ useslist.jsonGET /users/{id}→ usesshow.jsonPOST /users→ usescreate.jsonPUT /users/{id}→ usesupdate.jsonDELETE /users/{id}→ usesdelete.json
{{entity_plural}} are replaced with users, {{entity_singular}} with user.
Notes
- Templates reduce repetitive documentation
- The generator falls back to metadata extraction when templates are disabled
- Custom endpoint documentation overrides template output
Common Mistakes
Scenario 5: Generate Postman Environments
Goal: Export Postman environments for local development, staging, and production to use in API testing.Setup
Define environments inconfig/openapi.php:
Execution
- Generate All Environments
- Specific Environment
postman-all.json- Main collectionpostman-env-artisan.jsonpostman-env-local.jsonpostman-env-production.json
Import to Postman
1
Import collection
- Open Postman
- Click File > Import
- Select
postman-all.json
2
Import environments
- Click Environments in left sidebar
- Click Import
- Select all
postman-env-*.jsonfiles
3
Select environment
- Click the environment dropdown (top right)
- Select
artisan,local, orproduction - All requests now use that environment’s base URL and variables
Notes
- The environment generator merges base + tracking variables into each sub-environment
- Tracking variables appear in all environments with empty default values
- You can set actual token values in Postman’s environment editor
Common Mistakes
Scenario 6: CI/CD Pipeline Integration
Goal: Automatically generate and publish documentation on every deployment.GitHub Actions Example
GitLab CI Example
Notes
- Always use
--no-cachein CI/CD to ensure fresh output - Consider using
--allto generate all formats - Upload to S3, CDN, or documentation hosting platform
Scenario 7: Team Workflow for API Development
Goal: Establish a workflow where backend developers generate docs, and frontend/mobile teams consume them.Workflow
1
Developer adds new endpoint
Backend developer creates a new route with FormRequest validation:
2
Generate documentation locally
3
Commit generated files
Add documentation files to version control:
4
CI/CD publishes docs
On merge to main, CI pipeline generates and publishes docs to a shared location:
5
Frontend/mobile teams consume docs
Teams import the latest Postman collection or view the OpenAPI spec in Swagger UI.
Best Practices
Next Steps
Edge Cases
Learn how to handle config caching issues, concurrent generation, large route sets, and multi-tenant deployments.
API Reference
Explore the programmatic API for advanced integration scenarios.