codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

feat(api): render the API docs with Scalar instead of swagger-ui #178

Merged
pat-s merged 1 commit from feat/scalar-api-reference into v16.0/forgejo-codefloe 2026-09-28 17:28:09 +00:00
Owner

Replace swagger-ui with Scalar as the viewer for /api/swagger and /api/forgejo/swagger.
The go-swagger spec generation and the page URLs are unchanged; only the viewer moves.

Changes

  • package.json / package-lock.json: add @scalar/api-reference 1.72.1, remove swagger-ui-dist, and bump vue 3.5.38 → 3.5.43 so Scalar's tree dedupes onto one Vue runtime.
  • web_src/js/codefloe/api-reference.js (new): shared helper that mounts Scalar for both pages.
  • web_src/js/standalone/swagger.js and forgejo-swagger.js: call the helper; file and webpack entry names stay, to keep upstream merges clean.
  • README.md: add an "API docs" row to the custom changes table.
  • web_src/css/standalone/swagger.css: drop the invert-filter dark mode in favour of Scalar's native one, and keep the back link readable and above Scalar's layout.

Self-hosting defaults

Scalar reaches out to scalar.com in several places by default, so the helper turns these off:

  • fonts from fonts.scalar.com (withDefaultFonts: false)
  • the "Open API Client" button linking to client.scalar.com (hideClientButton: true)
  • agent chat and MCP, which Scalar enables automatically on localhost
  • developer tools and telemetry

Scalar only uses its request proxy in its hosted web layout, so "Test Request" calls the instance directly.

Behaviour change

  • The API docs have a sidebar, search, per-language request snippets, and an in-page request client.
  • All tags start collapsed, matching swagger-ui's docExpansion: 'none'.
  • Dark mode follows the system colour scheme.
  • The API docs code grows from about 1.5 MB to about 4.1 MB; it loads only on these two pages.

Validation

  • Production webpack build passes, including the license allowlist check.
  • prek run -a passes (backend lint, Swagger generation/validation, frontend lint and type checking).
  • Both pages render in headless Chromium in light and dark mode with no console errors and no requests to any host but the instance; "Test Request" hits /api/forgejo/v1/version directly.

Not addressed here: on /api/forgejo/swagger the "Return to Forgejo" link shows only its icon, because templates/swagger/forgejo-ui.tmpl reads the label from .locale instead of ctx.Locale; this predates the change.

Replace swagger-ui with [Scalar](https://github.com/scalar/scalar) as the viewer for `/api/swagger` and `/api/forgejo/swagger`. The go-swagger spec generation and the page URLs are unchanged; only the viewer moves. ## Changes - `package.json` / `package-lock.json`: add `@scalar/api-reference` 1.72.1, remove `swagger-ui-dist`, and bump `vue` 3.5.38 → 3.5.43 so Scalar's tree dedupes onto one Vue runtime. - `web_src/js/codefloe/api-reference.js` (new): shared helper that mounts Scalar for both pages. - `web_src/js/standalone/swagger.js` and `forgejo-swagger.js`: call the helper; file and webpack entry names stay, to keep upstream merges clean. - `README.md`: add an "API docs" row to the custom changes table. - `web_src/css/standalone/swagger.css`: drop the invert-filter dark mode in favour of Scalar's native one, and keep the back link readable and above Scalar's layout. ## Self-hosting defaults Scalar reaches out to scalar.com in several places by default, so the helper turns these off: - fonts from `fonts.scalar.com` (`withDefaultFonts: false`) - the "Open API Client" button linking to `client.scalar.com` (`hideClientButton: true`) - agent chat and MCP, which Scalar enables automatically on localhost - developer tools and telemetry Scalar only uses its request proxy in its hosted web layout, so "Test Request" calls the instance directly. ## Behaviour change - The API docs have a sidebar, search, per-language request snippets, and an in-page request client. - All tags start collapsed, matching swagger-ui's `docExpansion: 'none'`. - Dark mode follows the system colour scheme. - The API docs code grows from about 1.5 MB to about 4.1 MB; it loads only on these two pages. ## Validation - Production webpack build passes, including the license allowlist check. - `prek run -a` passes (backend lint, Swagger generation/validation, frontend lint and type checking). - Both pages render in headless Chromium in light and dark mode with no console errors and no requests to any host but the instance; "Test Request" hits `/api/forgejo/v1/version` directly. Not addressed here: on `/api/forgejo/swagger` the "Return to Forgejo" link shows only its icon, because `templates/swagger/forgejo-ui.tmpl` reads the label from `.locale` instead of `ctx.Locale`; this predates the change.
pat-s force-pushed feat/scalar-api-reference from 8979281270
Some checks failed
testing / frontend-checks (pull_request) Successful in 1m38s
testing / backend-checks (pull_request) Has been cancelled
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (pull_request) Has been cancelled
testing / test-remote-cacher (redis) (pull_request) Has been cancelled
testing / test-remote-cacher (valkey) (pull_request) Has been cancelled
testing / test-remote-cacher (garnet) (pull_request) Has been cancelled
testing / test-mysql (pull_request) Has been cancelled
testing / test-pgsql (pull_request) Has been cancelled
testing / test-sqlite (pull_request) Has been cancelled
to 7660ece538
All checks were successful
testing / frontend-checks (pull_request) Successful in 1m29s
testing / backend-checks (pull_request) Successful in 7m41s
testing / test-unit (pull_request) Successful in 13m12s
testing / test-remote-cacher (valkey) (pull_request) Successful in 4m32s
testing / test-remote-cacher (redis) (pull_request) Successful in 4m33s
testing / test-remote-cacher (garnet) (pull_request) Successful in 4m16s
testing / test-e2e (pull_request) Successful in 42m20s
testing / test-mysql (pull_request) Successful in 42m22s
testing / test-pgsql (pull_request) Successful in 1h2m31s
testing / test-sqlite (pull_request) Successful in 57m27s
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped
2026-09-28 15:41:50 +00:00
Compare
pat-s merged commit 07c8b8663d into v16.0/forgejo-codefloe 2026-09-28 17:28:09 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!178
No description provided.