Repository navigation
fix(api-catalog): resync drift, normalize domains base URL, sort + env-aware routing - #167
Conversation
…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).
There was a problem hiding this comment.
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
domainsandfulfillments) to resolve upstream drift and normalizedomainsto a prod-canonicalbaseUrl. - Adds generalized environment-aware catalog base-URL resolution (
resolve_catalog_base_url) and wires it intoapi domain listandapi 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.
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.
There was a problem hiding this comment.
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_urldescribe 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`,
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.
There was a problem hiding this comment.
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_urlnormalizes catalog domain names by replacing-with_when building the local-config override key (e.g.customer-profilesbecomescustomer_profiles_api_url). Howeverapi domain listsurfaces 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 settingcustomer-profiles_api_urlinenvironments.tomlwould never be picked up. Consider checking both the raw<domain>_api_urlkey 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;
Summary
domains.json,fulfillments.json) to resync with upstream specs — the localdomainsspec was already at v3.1.0 but never regenerated, andcommerce.fulfillments-specificationmerged a newlistFulfillmentsendpoint (v1.2.0) that was never picked up. See the failed catalog-drift run.domainsspec's host to production (api.godaddy.com) instead of OTE, consistent with every other catalog domain'sbaseUrl.api domain listalphabetically instead of followingapi-catalog-sources.jsoninsertion order.domaincommands (environments::resolve_domains) to every catalog domain viaenvironments::resolve_catalog_base_url— checks an explicit per-domain override, otherwise applies GoDaddy's{env}-godaddy.comhostname convention. Wired into bothapi domain list(display) andapi call(actual request routing).api callnow rejects anendpointargument that doesn't start with/(e.g. a bare operationId) up front, instead of silently building an invalid request URL.find_endpointnow 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 --checkall passcargo test -p generate-api-catalog— structural drift guard passes against the regenerated catalogGITHUB_TOKENand confirmed it matches CI's diff exactly (267 insertions / 18 deletions acrossdomains.json+fulfillments.json)cargo run -- api domain list --env {prod,ote,test}resolves correct per-domain, per-environment hosts (e.g.fulfillments→fulfillment.api.commerce.test-godaddy.comundertest) and alphabetical orderingapi call's routing covered by unit tests mirroring thefind_endpoint+resolve_catalog_base_urlcomposition it uses, including the new concrete-path-vs-template matching (no existing httpmock harness for its real HTTP path to extend)$defskey-naming quirk ingenerate-api-catalogunrelated to this PR's scope)🤖 Generated with Claude Code