Skip to content

feat: add qovery api spec command - #691

Merged
acarranoqovery merged 3 commits into
mainfrom
feat/api-spec-command
Aug 25, 2026
Merged

feat: add qovery api spec command#691
acarranoqovery merged 3 commits into
mainfrom
feat/api-spec-command

Conversation

@acarranoqovery

Copy link
Copy Markdown
Contributor

Summary

  • Adds qovery api spec, a subcommand of the existing qovery api — fetches and prints the Qovery OpenAPI spec (YAML), from Qovery/qovery-openapi-spec.
  • No authentication required.
  • -o/--output <file> writes the spec to a file instead of stdout.
  • Added as a subcommand rather than a --spec flag on api or a new top-level qovery openapi command: api <endpoint> always expects an endpoint argument and always makes a live authenticated call, so a flag with neither would mix two different mental models. A subcommand keeps api <endpoint> completely unchanged and follows the same "parent command with its own default action + read-only subcommands" shape already used by auth (login vs. auth status/auth token) and context (show current context vs. context set).

Motivation

There's no built-in way to discover valid endpoints/methods/schemas before calling qovery api <endpoint> — today that means guessing, or trusting an external raw GitHub URL that a script/agent has to know about and that may be out of sync with the installed CLI. api-doc.qovery.com no longer serves the raw file either (it redirects to the rendered docs site), so the GitHub repo is the only stable source; this wraps that in the CLI directly.

Test plan

  • go build ./... — clean
  • gofmt -l on the changed file — clean
  • qovery api --helpspec listed as a subcommand, existing api <endpoint> usage/examples unchanged
  • qovery api spec — fetches and prints the live spec (31k lines of YAML)
  • qovery api spec -o file.yaml — writes to file
  • qovery api organization (pre-existing passthrough) — still resolves and works, confirming spec doesn't shadow real endpoint calls
  • Reviewer: confirm pulling from raw.githubusercontent.com (rather than e.g. embedding/caching a copy pinned to the CLI's release) is the right tradeoff — this always reflects the live API surface but adds a network dependency and no offline fallback

Fetches and prints the Qovery OpenAPI spec (from Qovery/qovery-openapi-spec,
the only stable source now that api-doc.qovery.com redirects to rendered docs
instead of serving the raw file). Lets scripts and agents discover valid
endpoints, methods, and request/response shapes before calling
'qovery api <endpoint>', instead of guessing or trusting a possibly stale copy.
Requires no authentication. Added as a subcommand of the existing 'api'
command rather than a new top-level command or a --spec flag, matching the
parent-command-with-subcommands shape already used by 'auth'/'context'.

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

Adds qovery api spec to fetch and print the live Qovery OpenAPI YAML, with optional file output.

Changes:

  • Registers spec under qovery api.
  • Fetches the GitHub-hosted specification with a timeout.
  • Supports stdout output or -o/--output file writing.
Suppressed comments (2)

cmd/api_spec.go:75

  • When -o is used, this status message is emitted to stdout via utils.PrintlnInfo (utils/printer.go:20-22), so stdout is not cleanly reserved for the spec/output stream. This breaks the documented “instead of stdout” mode for scripts that capture stdout; send the informational message to stderr or omit it.
			utils.PrintlnInfo("OpenAPI spec written to " + apiSpecOutput)

cmd/api_spec.go:79

  • The return value from os.Stdout.Write is discarded, so a partial or failed write (for example, ENOSPC on redirected output or a broken pipe) still makes the command exit successfully. Check the write error and return a non-zero status so callers can distinguish a complete spec from truncated output.
		_, _ = os.Stdout.Write(body)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cmd/api_spec.go
Comment thread cmd/api_spec.go
…t path

Addresses Copilot review feedback on #691: the "written to" status message
was going to stdout via PrintlnInfo, defeating the point of -o (a clean stream
to script against); the direct os.Stdout.Write also discarded its error, so a
broken pipe or full disk still exited 0.
Comment thread cmd/api_spec.go Outdated
if resp.StatusCode != http.StatusOK {
utils.PrintlnError(fmt.Errorf("failed to fetch OpenAPI spec: server returned %s", resp.Status))
os.Exit(1)
panic("unreachable") // staticcheck false positive: https://staticcheck.io/docs/checks#SA5011

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.

almost sure this isn't needed anymore.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

indeed. removed, thanks!

…spec.go

That pattern only guards against SA5011 false positives where staticcheck
can't prove code after os.Exit is unreachable and flags a later dereference
as a possible nil access. None of the five os.Exit(1) calls here are followed
by code that dereferences anything from the failed call, so there was nothing
for staticcheck to misjudge. Verified by removing all five and confirming
staticcheck, go vet, and go build stay clean.
@acarranoqovery
acarranoqovery merged commit 442612b into main Aug 25, 2026
7 checks passed
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.

4 participants