Skip to content

API Docs: show full instance URL in Swagger curl examples and Request URL - #520

Merged
nicdavidson merged 3 commits into
developfrom
api-docs-curl-examples-and-request-url-show-rela
Sep 9, 2026
Merged

nicdavidson merged 3 commits into
developfrom
api-docs-curl-examples-and-request-url-show-rela

Conversation

@nicdavidson

@nicdavidson nicdavidson commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #519

Problem

Two places on the API Docs page showed a host-less /api/v2/<service>/...:

  1. Operations view (default): df-api-docs passed /api/v2/<service> into df-try-it as baseUrl. The console uses that verbatim for the resolved-URL line and the curl / Python / JS snippets, bypassing its own window.location.origin fallback.
  2. Swagger panel (advanced): the backend emits a relative servers[0].url, and the spec is fed to Swagger UI inline with no document URL to resolve against, so curl / Request URL print the relative path.

Fix

  • serviceBaseUrl is now ${window.location.origin}/api/v2/<service>.
  • Relative servers[].url entries are prefixed with the page origin right before SwaggerUI({ spec }). Absolute URLs and specs without servers pass through. The downloaded api-spec.json keeps the relative, portable URL.
  • Rebuilt dist/.

Verification

  • jest df-api-docs.component.spec.ts 9/9 (two new tests)
  • eslint clean on touched files
  • Deployed to df-dev: sanjose curl snippet now shows the full instance URL

…ger UI

The backend emits servers[0].url as '/api/v2/<service>' (valid, portable).
Swagger UI receives the spec inline, so it has no document URL to resolve
that against and prints host-less curl examples and Request URLs. Prefix
relative server URLs with window.location.origin at render time only; the
downloaded api-spec.json keeps the relative URL.

Fixes #519
The operations view passed '/api/v2/<service>' into df-try-it as baseUrl,
which it uses verbatim for the resolved-URL line and the curl / Python / JS
snippets, bypassing its own origin fallback. Prefix with the page origin so
the snippets are copy-pasteable. Includes rebuilt dist.

Refs #519
@nicdavidson
nicdavidson merged commit f73c9fd into develop Sep 9, 2026
1 check passed
@nicdavidson
nicdavidson deleted the api-docs-curl-examples-and-request-url-show-rela branch September 9, 2026 20:53
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.

1 participant