Skip to content

✨ feat: Serve Scalar API reference from the API server#186

Merged
yeazelm merged 1 commit intopapercomputeco:mainfrom
yeazelm:swagger
Apr 15, 2026
Merged

✨ feat: Serve Scalar API reference from the API server#186
yeazelm merged 1 commit intopapercomputeco:mainfrom
yeazelm:swagger

Conversation

@yeazelm
Copy link
Copy Markdown
Contributor

@yeazelm yeazelm commented Apr 15, 2026

Summary

PR #183 wired up swaggo annotations and generated the OpenAPI spec. This adds a drop-in runtime viewer: /swagger renders Scalar via CDN, so no viewer assets are embedded and the binary only grows by ~1 MB. Spec is served at /swagger/doc.json via swag.ReadDoc.

Testing

  • run locally and confirm UI comes up at localhost:8081/swagger

@yeazelm yeazelm requested a review from jpmcb April 15, 2026 16:07
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 15, 2026

Greptile Summary

This PR adds a drop-in Scalar API reference viewer served at /swagger, backed by the OpenAPI spec generated in #183. The implementation is minimal and clean: a small HTML page pointing the Scalar viewer at /swagger/doc.json, with the viewer JS fetched from CDN at view time rather than embedded in the binary.

  • api/swagger_middleware.go — new file; registers /swagger (HTML shell) and /swagger/doc.json (spec via swag.ReadDoc()) on the Fiber app
  • api/api.go — one-line call to mountSwagger inserted after the v1 routes
  • The CDN script tag does not pin a version, meaning any future breaking release of @scalar/api-reference would silently break the viewer without any code change in this repo

Confidence Score: 4/5

Safe to merge; the only concern is a non-pinned CDN version that could cause a silent future regression.

The change is small, focused, and follows the existing Fiber routing patterns. The sole non-blocking issue is the unversioned CDN script URL — pinning the version (and optionally adding an SRI hash) would make the setup more robust, but it does not block correctness today.

api/swagger_middleware.go — CDN script tag should pin a specific @scalar/api-reference version.

Important Files Changed

Filename Overview
api/swagger_middleware.go New file adding Scalar API reference UI served via CDN. Clean implementation with minimal binary footprint; CDN script is loaded without a pinned version, which could cause silent breakage on a future major Scalar release.
api/api.go Single-line addition calling mountSwagger in the right place — after v1 routes and before MCP registration. No issues.

Sequence Diagram

sequenceDiagram
    participant Browser
    participant TapesAPI as Tapes API Server
    participant jsDelivr as cdn.jsdelivr.net

    Browser->>TapesAPI: GET /swagger
    TapesAPI-->>Browser: 200 HTML (scalarHTML shell)

    Browser->>jsDelivr: GET /npm/@scalar/api-reference (CDN, latest)
    jsDelivr-->>Browser: Scalar viewer JS

    Browser->>TapesAPI: GET /swagger/doc.json
    TapesAPI->>TapesAPI: swag.ReadDoc()
    TapesAPI-->>Browser: 200 OpenAPI JSON spec

    Browser->>Browser: Render Scalar API reference UI
Loading

Reviews (1): Last reviewed commit: "✨ feat: Serve Scalar API reference from ..." | Re-trigger Greptile

Comment thread api/swagger_middleware.go Outdated
Comment thread api/swagger_middleware.go Outdated
PR papercomputeco#183 wired up swaggo annotations and generated the OpenAPI spec.
This adds a drop-in runtime viewer: /swagger renders Scalar via CDN,
so no viewer assets are embedded and the binary only grows by ~1 MB.
Spec is served at /swagger/doc.json via swag.ReadDoc.

Signed-off-by: Matt Yeazel <matt@papercompute.com>
@yeazelm yeazelm merged commit 28c7759 into papercomputeco:main Apr 15, 2026
10 checks passed
@yeazelm yeazelm deleted the swagger branch April 15, 2026 16:57
@continue
Copy link
Copy Markdown

continue Bot commented Apr 15, 2026

Documentation update created: https://github.com/papercomputeco/tapes.dev/pull/99

This PR adds documentation for the new /swagger and /swagger/doc.json endpoints to the Inspect page at tapes.dev.

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.

2 participants