Skip to content

feat: add GET /docs endpoint serving Swagger UI for the OpenAPI spec#190

Open
lsulak with Copilot wants to merge 4 commits into
masterfrom
copilot/add-docs-endpoint
Open

feat: add GET /docs endpoint serving Swagger UI for the OpenAPI spec#190
lsulak with Copilot wants to merge 4 commits into
masterfrom
copilot/add-docs-endpoint

Conversation

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

GET /api returns raw YAML, which browsers download rather than render. This adds a GET /docs endpoint that serves a minimal HTML page embedding Swagger UI (CDN-loaded, pinned to swagger-ui-dist@5), pointed at the existing /api spec via a relative ./api URL — no host hardcoding, works across all API Gateway stages and custom domains.

Overview

src/handlers/handler_api.py — new get_docs() method:

def get_docs(self) -> dict[str, Any]:
    """Return a Swagger UI HTML page for browsing the API spec."""
    ...
    return {"statusCode": 200, "headers": {"Content-Type": "text/html"}, "body": html}

The HTML body loads swagger-ui-dist@5 from jsDelivr and initialises SwaggerUIBundle({ url: "./api", dom_id: "#swagger-ui" }).

src/event_gate_lambda.py — registered in ROUTE_MAP:

"/docs": lambda _: handler_api.get_docs(),

api.yaml/docs path documented with security: [] and 200 text/html response.

Release Notes

  • Added GET /docs endpoint: returns an interactive Swagger UI page rendered against the existing /api OpenAPI spec

⚠️ Deployment note: API Gateway must have a /docs resource (or an existing {proxy+} catch-all) routed to the EventGate Lambda. Without this, /docs will 404 at the gateway even after deploying this change. This will be done here: https://github.com/absa-group/cps-eventbus-gateway/pull/124

Closes: #191

Copilot AI changed the title [WIP] Add GET /docs endpoint for Swagger UI documentation feat: add GET /docs endpoint serving Swagger UI for the OpenAPI spec Jul 9, 2026
Copilot finished work on behalf of lsulak July 9, 2026 11:08
Copilot AI requested a review from lsulak July 9, 2026 11:08
@lsulak lsulak marked this pull request as ready for review July 9, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render OpenAPI documentation of endpoints, not just prepare its downloadable raw document version

2 participants