Skip to content

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

Merged
lsulak merged 11 commits into
masterfrom
copilot/add-docs-endpoint
Jul 20, 2026
Merged

feat: add GET /docs endpoint serving Swagger UI for the OpenAPI spec#190
lsulak merged 11 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

⚠️ 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

@tmikula-dev tmikula-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this approach! Thanks for this PR.

Comment thread api.yaml Outdated

@oto-macenauer-absa oto-macenauer-absa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works, but I'd add replacement of cdn.jsdelivr.net with bundles created during the docker build (inside Dockerfile) in future.

I have created an issue for the consideration: #197

@lsulak
lsulak merged commit 27c3166 into master Jul 20, 2026
9 checks passed
@lsulak
lsulak deleted the copilot/add-docs-endpoint branch July 20, 2026 13:30
@lsulak

lsulak commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Works, but I'd add replacement of cdn.jsdelivr.net with bundles created during the docker build (inside Dockerfile) in future.

I have created an issue for the consideration: #197

ok, thanks! I'll adjust it right away, outside of this PR since I've got approvals & I want to keep things small

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

4 participants