Skip to main content
This guide covers common issues you may encounter when generating OpenAPI documentation and provides actionable solutions.

Invalid API Type Parameter

Error Message: Unknown or disabled API types: {type}. Available types: api, site, mobile, adminHTTP Response: 422 Unprocessable Entity

Cause

The requested API type is either:
  • Not defined in config/openapi.php
  • Disabled in the api_types configuration array
  • Misspelled in the command or query parameter

Solution

1

Check your configuration

Open config/openapi.php and verify the api_types array:
2

Enable the API type

Set enabled to true for the API type you want to use.
3

Clear config cache

If you’re using config caching, clear it:
4

Regenerate documentation

The legacy API type movile is automatically converted to mobile, but you should update your code to use mobile directly.

No Routes Found

Message: ⚠️ No routes found matching the specified filters

Cause

Route filtering has excluded all routes. This can happen when:
  • API type filters remove all matching routes
  • Route exclusion patterns are too broad
  • No routes are registered with the specified API type

Solution

Check your config/openapi.php for overly aggressive exclusion patterns:
Action: Remove or refine patterns that might be excluding routes you want to document.
If using --api-type, ensure your routes are tagged with that API type:
Try without filters to see all routes:
Verify routes are actually registered:
Look for routes that should be documented but might be missing the proper middleware or metadata.

HTTP 500 When Accessing Documentation Endpoint

Error: Failed to generate specificationHTTP Status: 500 Internal Server Error

Cause

Common causes include:
  • Invalid JSON in template files
  • Syntax errors in custom templates
  • Exceptions during route introspection
  • Memory limits exceeded with large route sets

Solution

1

Run generation via CLI

The CLI provides full error output:
This will show the complete stack trace and error message.
2

Validate JSON templates

Check all templates in resources/openapi/templates/:
Look for:
  • Missing commas
  • Trailing commas
  • Unclosed brackets
  • Invalid placeholder syntax
3

Enable detailed logging

Set your app to debug mode temporarily:
Then check storage/logs/laravel.log for detailed errors.
4

Test with minimal routes

Temporarily exclude most routes to isolate the problem:
Then gradually add routes back to identify which one causes the error.
For production environments, serve pre-generated static files instead of generating on-demand:
Then serve the static file instead of using the HTTP generation endpoint.

Placeholder Values Not Updating

Symptom: Changes to .env values (like APP_NAME, APP_URL) don’t appear in generated documentation

Cause

Laravel’s config cache is enabled, and some values are read using env() at runtime instead of from cached config.

Solution

1

Clear config cache

2

Clear OpenAPI cache

Or generate without cache:
3

Prefer config over env()

Instead of changing .env values, override config values in config/openapi.php:
4

Regenerate documentation

Best Practice: When using config:cache in production, always set values in config files rather than relying on runtime env() calls.

Concurrent Generation File Corruption

Symptom: Partially written or inconsistent JSON/YAML files in storage/app/public/openapi

Cause

Multiple workers or processes running openapi:generate simultaneously write to the same output files.

Solution

When running generation jobs in parallel, specify unique output files:
Use Laravel’s command locking to prevent concurrent execution:
If running generation in queued jobs, use the SerializesModels trait and ensure jobs run one at a time:

Template JSON Parsing Failures

Error: Template not found or Failed to read template or is not valid JSON

Cause

Invalid JSON syntax or missing template files in resources/openapi/templates/.

Solution

1

Verify template exists

Check that the template file exists:
Required templates:
  • openapi.json
  • postman.json
  • insomnia.json
2

Validate JSON syntax

Use a JSON validator:
Common issues:
  • Trailing commas: "key": "value",}
  • Missing quotes: {key: "value"}
  • Unclosed brackets: {"key": "value"
3

Enable validation in config

For debugging, enable output validation:
4

Test with default templates

Temporarily restore default templates from the package:

Large Route Sets Causing Timeouts

Symptom: HTTP requests to /documentation/openapi.json timeout or return 500 errors

Cause

Generating documentation for hundreds of routes with complex FormRequest validation can exceed PHP execution time limits.

Solution

Generate documentation offline and serve pre-built files:
Then configure your web server to serve the static file instead of the HTTP endpoint.
For the HTTP endpoint, increase time limits:
Reduce the number of routes processed per request:
Exclude routes that don’t need documentation:

Rate Limiting or Auth Blocking Documentation Routes

HTTP Status: 401 Unauthorized, 403 Forbidden, or 429 Too Many Requests

Cause

The middleware stack for documentation routes includes authentication or rate limiting:

Solution

1

Use dedicated middleware stack

2

Create custom middleware for docs

3

Disable HTTP routes entirely

Generate and serve static files instead:

Stale Cache in Long-Running Workers

Symptom: Queue workers serve old documentation that doesn’t reflect recent route changes

Cause

The OpenAPI cache is enabled and has a long TTL, causing workers to serve outdated specs.

Solution

Or via CLI:
Add cache clearing to your deployment script:

Getting Help

If you’re still experiencing issues:
  1. Enable verbose output:
  2. Check logs:
    • storage/logs/laravel.log
    • Laravel Telescope (if installed)
  3. Report issues with:
    • Laravel version
    • Package version
    • Full error message
    • Configuration (sanitized)