Skip to content

Honor path-level servers when prefixing path keys#100

Open
chinmaya-singal-glean wants to merge 2 commits intomainfrom
honor-path-level-servers-in-transformer
Open

Honor path-level servers when prefixing path keys#100
chinmaya-singal-glean wants to merge 2 commits intomainfrom
honor-path-level-servers-in-transformer

Conversation

@chinmaya-singal-glean
Copy link
Copy Markdown

@chinmaya-singal-glean chinmaya-singal-glean commented May 7, 2026

Summary

  • transform() previously prepended the global server's basePath to every path key, even when a path declared its own servers: block. With OpenAPI's path-level-server-wins resolution rule, pathServer.url + pathKey then composed a doubled prefix (e.g. /rest/api/index + /api/index/v1/document/...), surfacing as a wrong URL in Redoc, Speakeasy SDKs, and any "Try it" widget.
  • The transformer now derives the prefix from a path's own servers: block when one is present, and strips that basePath from the path-level server URL so the composed URL matches the global-server convention.
  • transformServerVariables extended to apply {domain}{instance} to path-level servers as well, so the rename is consistent.

Why now

The Custom Metadata API endpoints (currently x-internal: true) live under /rest/api/index rather than the indexing API's main /api/index/v1. Those endpoints are slated for GA in a follow-up PR; without this fix the published path keys and SDK URLs would be wrong.

No existing fixture in source_specs/ has a path-level servers: block, so no behavior changes for current specs — verified by the existing 54 tests still passing.

Test plan

  • pnpm test — all 55 tests pass (added one new test honors path-level servers when prefixing path keys backed by tests/fixtures/path-level-servers.yaml)
  • Manual sanity check: piped a synthetic spec with a path-level server through transform() and confirmed:
    • Path key becomes /rest/api/index/document/... (its own basePath, not the global one)
    • Path-level server URL stripped to https://{instance}-be.glean.com
    • {domain}{instance} propagated through to path-level server variables

chinmaya-singal-glean and others added 2 commits May 7, 2026 21:46
The transformer extracts a basePath from the global server URL and prepends
it to every path key. When a path defines its own servers: block (e.g. an
endpoint that sits under /rest/api/index instead of the API's main
/api/index/v1 prefix), the global basePath was still being prepended,
producing path keys like /api/index/v1/document/... while the path-level
server URL still carried /rest/api/index. Resolving server.url + pathKey
under OpenAPI's path-level-server-wins rule then yielded a doubled prefix
in both Redoc and Speakeasy SDK URL composition.

Now the transformer derives the prefix from a path's own server when one is
declared, and strips that basePath from the path-level server URL too — so
the resolved URL composes correctly. transformServerVariables also applies
the {domain} → {instance} rename to path-level servers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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