mirror of
https://github.com/kennethreitz/kjvstudy.org.git
synced 2026-06-05 23:00:16 +00:00
Filter API docs to only show /api endpoints
Add custom OpenAPI schema generation to filter documentation
to only include routes starting with /api/. This keeps the
API docs clean and focused on the actual API endpoints without
cluttering them with web page routes.
The /api/docs will now only show:
- /api/search
- /api/verse-of-the-day
- /api/verse/{book}/{chapter}/{verse}
- /api/verse-range/{book}/{chapter}/{start}/{end}
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -691,6 +691,27 @@ app = FastAPI(
|
||||
)
|
||||
|
||||
|
||||
# Custom OpenAPI schema to only include /api routes
|
||||
def custom_openapi():
|
||||
if app.openapi_schema:
|
||||
return app.openapi_schema
|
||||
|
||||
openapi_schema = app.openapi()
|
||||
|
||||
# Filter paths to only include /api routes
|
||||
filtered_paths = {
|
||||
path: path_item
|
||||
for path, path_item in openapi_schema["paths"].items()
|
||||
if path.startswith("/api/")
|
||||
}
|
||||
|
||||
openapi_schema["paths"] = filtered_paths
|
||||
app.openapi_schema = openapi_schema
|
||||
return app.openapi_schema
|
||||
|
||||
app.openapi = custom_openapi
|
||||
|
||||
|
||||
# Caching middleware for performance optimization
|
||||
class CacheControlMiddleware(BaseHTTPMiddleware):
|
||||
"""Add cache control headers to responses for better performance"""
|
||||
|
||||
Reference in New Issue
Block a user