feat(api): render the API docs with Scalar instead of swagger-ui #178
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!178
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/scalar-api-reference"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Replace swagger-ui with Scalar as the viewer for
/api/swaggerand/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-reference1.72.1, removeswagger-ui-dist, and bumpvue3.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.jsandforgejo-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.scalar.com(withDefaultFonts: false)client.scalar.com(hideClientButton: true)Scalar only uses its request proxy in its hosted web layout, so "Test Request" calls the instance directly.
Behaviour change
docExpansion: 'none'.Validation
prek run -apasses (backend lint, Swagger generation/validation, frontend lint and type checking)./api/forgejo/v1/versiondirectly.Not addressed here: on
/api/forgejo/swaggerthe "Return to Forgejo" link shows only its icon, becausetemplates/swagger/forgejo-ui.tmplreads the label from.localeinstead ofctx.Locale; this predates the change.89792812707660ece538