Add Swagger 2.0 support and custom spec URL for api cloud#2040
Merged
jeremybeard merged 1 commit intomainfrom Mar 26, 2026
Merged
Add Swagger 2.0 support and custom spec URL for api cloud#2040jeremybeard merged 1 commit intomainfrom
jeremybeard merged 1 commit intomainfrom
Conversation
- Add Swagger 2.0 (OpenAPI 2.x) parsing support alongside existing OpenAPI 3.x. The spec version is auto-detected and the appropriate model is built. Swagger 2.0 body parameters are converted to RequestBody and responses are mapped with synthetic content types. - Add --spec-url flag on `astro api cloud` to override the default Cloud API spec URL. The base URL for requests is derived from the spec's servers/basePath combined with the current context domain. - Add --spec-token-env-var flag to provide an env var name containing an auth token for fetching specs that require authentication. - Add GetServerPath() to extract the API base path from either v3 servers[0].url or v2 basePath. - Fix circular $ref stack overflow in schema conversion by returning ref names without resolving into BuildSchema(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Pull Request Test Coverage Report for Build eb0cffd0-70af-439f-aa8a-c59d3bc28f75Details
💛 - Coveralls |
jlaneve
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--spec-urlflag onastro api cloudto override the default spec URL, with base URL derived from the spec's servers/basePath--spec-token-env-varflag to read an auth token from a named environment variable when fetching specs that require authenticationGetServerPath()to pull the API base path from v3servers[0].urlor v2basePath$refstack overflow in schema conversionBoth new flags are hidden.
Test plan
go test ./pkg/openapi/...— all existing + new tests passgo test ./cmd/api/...— all existing + new tests passgo build .compiles cleanlyastro api cloud --helpdoes not show hidden flagsastro api cloud --spec-url <url> lswith an OpenAPI 3.0 specastro api cloud --spec-url <url> lswith a Swagger 2.0 specastro api cloud --spec-url <url> --spec-token-env-var <env> lswith an auth-protected spec