Skip to content

fix(api-catalog): resync drift, normalize domains base URL, sort + env-aware routing - #167

Merged
jpage-godaddy merged 4 commits into
mainfrom
fix/api-catalog-drift-domains-fulfillments
Jul 30, 2026
Merged

jpage-godaddy merged 4 commits into
mainfrom
fix/api-catalog-drift-domains-fulfillments

Conversation

@jpage-godaddy

@jpage-godaddy jpage-godaddy commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Regenerates the embedded API catalog (domains.json, fulfillments.json) to resync with upstream specs — the local domains spec was already at v3.1.0 but never regenerated, and commerce.fulfillments-specification merged a new listFulfillments endpoint (v1.2.0) that was never picked up. See the failed catalog-drift run.
  • Normalizes the vendored domains spec's host to production (api.godaddy.com) instead of OTE, consistent with every other catalog domain's baseUrl.
  • Sorts api domain list alphabetically instead of following api-catalog-sources.json insertion order.
  • Generalizes the environment-aware base-URL override that already existed for the real domain commands (environments::resolve_domains) to every catalog domain via environments::resolve_catalog_base_url — checks an explicit per-domain override, otherwise applies GoDaddy's {env}-godaddy.com hostname convention. Wired into both api domain list (display) and api call (actual request routing).
  • api call now rejects an endpoint argument that doesn't start with / (e.g. a bare operationId) up front, instead of silently building an invalid request URL.
  • find_endpoint now also matches a concrete request path with path params substituted (e.g. /stores/abc123/orders) against the catalog's templated path (/stores/{storeId}/orders) — previously neither exact nor substring matching could do this, so every parameterized endpoint silently fell back to the wrong base URL and lost scope auto-detection. (Caught by Copilot review; the last two items above are its fixes.)

Test plan

  • cargo check / cargo clippy -- -D warnings / cargo test (405 passing) / cargo fmt --check all pass
  • cargo test -p generate-api-catalog — structural drift guard passes against the regenerated catalog
  • Reproduced the drift locally with a real GITHUB_TOKEN and confirmed it matches CI's diff exactly (267 insertions / 18 deletions across domains.json + fulfillments.json)
  • Manually verified cargo run -- api domain list --env {prod,ote,test} resolves correct per-domain, per-environment hosts (e.g. fulfillments → fulfillment.api.commerce.test-godaddy.com under test) and alphabetical ordering
  • api call's routing covered by unit tests mirroring the find_endpoint + resolve_catalog_base_url composition it uses, including the new concrete-path-vs-template matching (no existing httpmock harness for its real HTTP path to extend)
  • Copilot review: 4 comments across 2 rounds, all addressed (2 fixed with new commits + tests, 2 explained — one mirrors upstream vendored spec content, one is a pre-existing $defs key-naming quirk in generate-api-catalog unrelated to this PR's scope)

🤖 Generated with Claude Code

…ins base URL

The embedded catalog had drifted from upstream: the local domains spec was
already at v3.1.0 (server-derived Consent, orderId/price fields) but never
regenerated, and commerce.fulfillments-specification merged a new
listFulfillments endpoint (v1.2.0) that was never picked up.

Also pins the vendored domains spec's host to production (api.godaddy.com)
instead of OTE, matching every other catalog domain's baseUrl — the real
domain commands already resolve their base URL per environment at runtime,
so this was always cosmetic, but the inconsistency made `api domain list`
misleading.
…ment

`api domain list` now sorts alphabetically instead of following
api-catalog-sources.json insertion order.

Generalizes the environment-aware base-URL override that already existed
for the real `domain` commands (environments::resolve_domains) to every
catalog domain: `environments::resolve_catalog_base_url` checks an explicit
per-domain override (local config or a <PREFIX>_<DOMAIN>_API_URL env var,
read directly rather than through cli-engine's apply_env_vars so it works
against prod/ote builtins too) and otherwise applies GoDaddy's
`{env}-godaddy.com` hostname convention. Wired into both `api domain list`
(display) and `api call` (actual request routing, via the existing
find_endpoint match).
Copilot AI review requested due to automatic review settings July 30, 2026 20:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR resynchronizes the embedded API catalog with upstream OpenAPI sources, and improves how gddy api resolves and displays per-domain base URLs across environments (prod/ote/test/dev), with stable alphabetical domain ordering.

Changes:

  • Regenerates the embedded API catalog JSON (notably domains and fulfillments) to resolve upstream drift and normalize domains to a prod-canonical baseUrl.
  • Adds generalized environment-aware catalog base-URL resolution (resolve_catalog_base_url) and wires it into api domain list and api call.
  • Sorts the embedded catalog domain list once at load time to ensure consistent ordering across all catalog consumers.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
rust/src/environments/mod.rs Adds shared host-substitution logic and a new resolve_catalog_base_url for per-domain, env-aware base URL routing.
rust/src/api_explorer/mod.rs Sorts catalog domains once, displays env-resolved base URLs in api domain list, and routes api call using matched catalog domain base URLs.
rust/schemas/api/manifest.json Updates generated manifest timestamp and domain ordering/metadata to match regenerated catalog.
rust/schemas/api/fulfillments.json Regenerates fulfillments domain (adds listFulfillments, schema updates, version bump).
rust/schemas/api/domains.json Regenerates domains domain (baseUrl normalized to prod, schema updates, version bump).
rust/domains-client/scripts/regenerate-spec.sh Updates domains spec regeneration to use prod-canonical host for the document’s server URL.
rust/domains-client/openapi/domains.oas3.json Normalizes the domains OpenAPI servers[0].url to https://api.godaddy.com.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rust/src/api_explorer/mod.rs Resolved
Comment thread rust/schemas/api/domains.json Resolved
Comment thread rust/schemas/api/fulfillments.json Resolved
find_endpoint can match a raw operationId, but the request URL is always
built from the literal endpoint argument, not the matched catalog path —
a bare operationId would silently build an invalid URL. Reject it up
front with a clear error instead.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

rust/src/environments/mod.rs:162

  • The docs for resolve_catalog_base_url describe the override as <domain>_api_url, but the implementation normalizes catalog domain names by replacing - with _ (e.g. customer-profiles -> customer_profiles_api_url). Calling out that normalization here would avoid config/env-var confusion.
/// `api domain list` / `api call`). Checks an explicit override first — a
/// `<domain>_api_url` key from local config, or a `<PREFIX>_<DOMAIN>_API_URL`
/// env var read directly here (not through cli-engine's `apply_env_vars`,

Comment thread rust/src/api_explorer/mod.rs Resolved
find_endpoint's exact/substring matching never matched a real request path
with path params substituted (e.g. /stores/abc123/orders) against the
catalog's templated path (/stores/{storeId}/orders) — a concrete path never
literally contains the {storeId} placeholder. This silently dropped both
scope auto-detection and, since the prior commit, base-URL routing for any
parameterized endpoint. Add segment-based template matching alongside the
existing exact/substring checks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

rust/src/environments/mod.rs:179

  • resolve_catalog_base_url normalizes catalog domain names by replacing - with _ when building the local-config override key (e.g. customer-profiles becomes customer_profiles_api_url). However api domain list surfaces the domain name with hyphens, and the doc comment says the override is <domain>_api_url, which suggests a hyphenated key. As-is, a user setting customer-profiles_api_url in environments.toml would never be picked up. Consider checking both the raw <domain>_api_url key and the underscore-normalized variant (env vars still need _).
pub fn resolve_catalog_base_url(domain: &str, prod_base_url: &str, env_name: &str) -> String {
    let override_key = format!("{}_api_url", domain.replace('-', "_"));
    if let Some(url) = domain_override(&override_key, env_name, |k| std::env::var(k).ok()) {
        return url;

@jpage-godaddy
jpage-godaddy merged commit 339db2d into main Jul 30, 2026
6 checks passed
@jpage-godaddy
jpage-godaddy deleted the fix/api-catalog-drift-domains-fulfillments branch July 30, 2026 22:12
This was referenced Jul 30, 2026
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.

3 participants