Skip to content

fix: describe skips endpoint resolution when BRAINPOD_OPENAPI_URL is set - #25

Open
jeroenrinzema wants to merge 1 commit into
mainfrom
fix/describe-openapi-url
Open

jeroenrinzema wants to merge 1 commit into
mainfrom
fix/describe-openapi-url

Conversation

@jeroenrinzema

Copy link
Copy Markdown
Collaborator

Follow-up to #24, addressing #24 (review).

#24 resolved the API endpoint (including loading the config file) before openapi_url checked BRAINPOD_OPENAPI_URL. With the override set and no --endpoint/BRAINPOD_API_ENDPOINT, a malformed or unreadable config — or no locatable config directory — made brainpod describe resource … fail even though it needs no endpoint.

  • openapi::describe takes an endpoint resolver that is only called when BRAINPOD_OPENAPI_URL is unset, so the override is independent of config loading again.
  • Removes the now-unreachable None endpoint branch and PRODUCTION_OPENAPI_URL; api_endpoint already defaults to https://api.brainpod.io, which yields the same URL.
  • Adds a unit test that the override never invokes the resolver, and that the resolved endpoint maps to <endpoint>/v1/openapi.json.
  • README: states that the override bypasses the endpoint and config file.

Verified: cargo clippy --all-targets, cargo test openapi; with BRAINPOD_CONFIG pointing at invalid TOML, BRAINPOD_OPENAPI_URL=… brainpod describe resource app --json now succeeds, while without the override it still reports the config parse error.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified in the OpenAPI URL override and deferred endpoint-resolution changes.

No open issues 🎉

What changed in this PR

This follow-up to #24 lets resource schema discovery bypass endpoint resolution and configuration loading when BRAINPOD_OPENAPI_URL is set, preventing unrelated configuration errors from blocking describe.

Changes:

  • Defers endpoint resolution until the OpenAPI URL override is checked.
  • Removes the redundant production URL fallback while preserving the default endpoint behavior.
  • Adds a regression test for resolver bypass and endpoint-derived URLs, and documents the bypass.
File Description
src/​openapi.rs Resolves endpoints lazily, removes the redundant fallback, and adds URL-resolution coverage.
src/​main.rs Passes endpoint and configuration lookup as a deferred resolver.
README.md Clarifies that the document URL override bypasses endpoint and configuration lookup.

Review effort: Balanced

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