Troubleshooting¶
Common issues and solutions when using REROUTE.
Flask Adapter Issues¶
Routes Not Appearing in Swagger UI¶
Symptoms:
- Swagger UI loads successfully but shows no API endpoints
- OpenAPI JSON at /docs/openapi.json has empty "paths": {}
- Routes work correctly when tested with curl or browser
- Response schemas appear in OpenAPI spec but no actual routes
Root Cause:
This issue was caused by two bugs in the Flask adapter's Spectree integration:
- Empty Path Parameter Bug: When
DOCS_PATH="/docs"in config, the adapter extracted an empty string (path='') to pass to Spectree. Spectree's route discovery filter then excluded ALL routes because: - Filter logic: Skip routes starting with
/{path}or/static - When
path='', this becomes: Skip routes starting with/ -
Since ALL routes start with
/, ALL routes were excluded from OpenAPI generation -
Closure Metadata Bug: REROUTE's closure-based request handling wrapped handlers in a way that hid Spectree's validation metadata, preventing proper OpenAPI documentation generation.
Solution (Fixed in v0.1.4):
The Flask adapter now:
- Never uses empty path: Extracts the first segment from
DOCS_PATH(e.g.,"/docs"→path="docs","/api/docs"→path="api"), ensuring Spectree's filter doesn't exclude all routes - Validates handlers early: Applies
spec.validate()to handlers BEFORE wrapping in REROUTE's closure - Copies metadata correctly: Transfers all Spectree attributes (
_decorator,tags,operation_id, etc.) from validated handler to Flask-facing closure
Updated Swagger UI Paths:
Because the path is no longer empty, Swagger UI endpoints are now at:
DOCS_PATH in config → Swagger UI URL
/docs → /docs/swagger/
/api/docs → /api/swagger/
/custom → /custom/swagger/
Migration:
If you were accessing Swagger UI at /swagger/, you now need to use /docs/swagger/ (or whatever your DOCS_PATH is configured to).
To keep the old /swagger/ URL, you can:
1. Update your bookmarks/links to /docs/swagger/
2. Or change DOCS_PATH in config.py to match your preference
Example:
# config.py
class AppConfig(Config):
class OpenAPI:
ENABLE = True
DOCS_PATH = "/docs" # Swagger UI at /docs/swagger/
JSON_PATH = "/openapi.json" # OpenAPI spec at /docs/openapi.json
IndentationError in Generated config.py¶
Symptoms:
Root Cause:
In earlier versions (before v0.1.4), the Jinja2 template had multiple configuration statements on a single line:
Solution:
Fixed in v0.1.4 - each statement is now on its own line with proper indentation.
For Existing Projects:
If your project was created before v0.1.4, manually fix your config.py:
# BEFORE (WRONG - all on one line):
REDOC_PATH = None # ReDoc disabled for Flask (broken CDN) JSON_PATH = "/openapi.json" # OpenAPI JSON spec endpoint
# AFTER (CORRECT - separate lines):
REDOC_PATH = None # ReDoc disabled for Flask (broken CDN)
JSON_PATH = "/openapi.json" # OpenAPI JSON spec endpoint
ModuleNotFoundError: spectree¶
Symptoms:
Solution:
Install all dependencies:
Or install spectree directly:
CORS Errors in Browser¶
Symptoms: - Browser console shows CORS errors - API works with curl but fails from web frontend
Solution:
Enable and configure CORS in your config.py:
class AppConfig(Config):
ENABLE_CORS = True
CORS_ALLOW_ORIGINS = ["http://localhost:3000"] # Your frontend URL
CORS_ALLOW_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]
CORS_ALLOW_HEADERS = ["*"]
CORS_ALLOW_CREDENTIALS = True
Install flask-cors:
General Issues¶
Routes Not Being Registered¶
Symptoms: - Routes return 404 errors - Route files exist but aren't accessible
Common Causes:
- Incorrect file structure: Route files must be in
app/routes/<route-name>/page.py - Missing RouteBase: Route class must inherit from
RouteBase - No HTTP methods: Class must have at least one method (get, post, put, delete)
Solution:
Ensure proper structure:
# page.py
from reroute import RouteBase
class HelloRoutes(RouteBase):
def get(self):
return {"message": "Hello"}
Port Already in Use¶
Symptoms:
Solution:
Change the port in config.py:
Or kill the process using the port:
# Windows
netstat -ano | findstr :7376
taskkill /PID <process_id> /F
# Linux/Mac
lsof -ti:7376 | xargs kill -9
Need More Help?¶
If you encounter issues not covered here:
- Check the Examples for working code
- Review the API Reference for detailed documentation
- Report bugs at GitHub Issues