Skip to content

Add static OpenAPI spec and clean up operation IDs#24

Merged
ragnorc merged 11 commits into
mainfrom
ragnorc/explore-api
Apr 19, 2026
Merged

Add static OpenAPI spec and clean up operation IDs#24
ragnorc merged 11 commits into
mainfrom
ragnorc/explore-api

Conversation

@ragnorc

@ragnorc ragnorc commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Commits a static openapi.json extracted from the Utoipa annotations, kept in sync via a golden-file test (openapi_spec_is_up_to_date). Regenerate with OMNIGRAPH_UPDATE_OPENAPI=1 cargo test -p omnigraph-server --test openapi openapi_spec_is_up_to_date — any drift between the committed spec and the Utoipa-generated output fails CI.
  • Adds operation_id to every #[utoipa::path] so generated SDK methods have clean camelCase names (read, createBranch, getRun, mergeBranches, etc.) instead of the default function-name-derived IDs.

Test plan

  • cargo test -p omnigraph-server --test openapi — all 65 tests pass
  • openapi.json contains valid OpenAPI 3.1 with 16 paths, 30 schemas, bearer_token scheme
  • Round-trip: running the golden-file test without the env var passes (committed == generated)

🤖 Generated with Claude Code


Note

Medium Risk
Adds a committed openapi.json golden file and CI automation that can push commits back to same-repo PR branches, which affects CI behavior and repository history. Runtime API behavior is largely unchanged, but tooling/SDK generation may be impacted by the new explicit operation_id values.

Overview
Adds a committed OpenAPI artifact and keeps it in sync automatically. This PR introduces a generated openapi.json checked into the repo, plus a golden-file test (openapi_spec_is_up_to_date) that fails when the committed spec drifts from the Utoipa-generated output.

Updates CI and docs to support spec regeneration. Workspace CI now sets OMNIGRAPH_UPDATE_OPENAPI for same-repo PRs and, when openapi.json changes, commits and pushes the regenerated file back to the PR branch (requiring contents: write).

Stabilizes SDK method naming. All #[utoipa::path] endpoints in omnigraph-server now specify explicit operation_ids (e.g., listBranches, getRun, applySchema) so generated clients get consistent names.

Reviewed by Cursor Bugbot for commit bcddbdf. Bugbot is set up for automated code reviews on this repo. Configure here.

ragnorc and others added 2 commits April 17, 2026 14:26
Introduce SDK generation scaffolding: commit a static openapi.json
extracted from the Utoipa annotations via a golden-file test, add
Stainless workspace/config for TypeScript and Python SDKs, and clean
up operation IDs for ergonomic generated method names.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop .stainless/ workspace and generator config; keep the static
openapi.json, golden-file test, and operation_id cleanup so the
spec stays usable with any SDK generator.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ragnorc ragnorc changed the title Add static OpenAPI spec and Stainless SDK scaffolding Add static OpenAPI spec and clean up operation IDs Apr 17, 2026
ragnorc and others added 3 commits April 17, 2026 15:53
Wire a local pre-commit hook that regenerates openapi.json whenever
the server source changes, and document the workflow in CONTRIBUTING.
Opt-in via `pre-commit install`; the existing CI test remains the
authoritative drift check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Track a project pre-commit hook under scripts/hooks/ that regenerates
openapi.json when server source is staged, and auto-stages the updated
spec into the commit. Zero external dependencies — plain bash + cargo.

Enable via `git config core.hooksPath scripts/hooks`. The CI drift
test remains the authoritative check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread scripts/hooks/pre-commit Outdated
ragnorc and others added 2 commits April 17, 2026 16:26
Describe the CI workflow that regenerates openapi.json on PRs and the
fork fallback. The workflow itself is added in a follow-up commit via
the GitHub API (local tooling lacks workflow-scope).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ragnorc ragnorc force-pushed the ragnorc/explore-api branch from 57135fb to e0d48ad Compare April 17, 2026 14:29
ragnorc and others added 3 commits April 17, 2026 19:09
The separate openapi-sync workflow was duplicating the workspace build
(~15 min cold-cache compile), paying the cost twice per PR. Fold the
regen + auto-commit into the existing test job: one compile, shared
rust-cache, same drift-check semantics.

- Same-repo PRs: OMNIGRAPH_UPDATE_OPENAPI=1 during the test run, then
  commit the regenerated spec back to the PR branch
- Fork PRs / pushes: env var empty, test stays in strict drift-check mode
- openapi_spec_is_up_to_date treats empty env value as unset, so the
  conditional workflow env expression works

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml Outdated
Restore the default pull_request checkout (refs/pull/N/merge) so tests
see the merged state. The openapi.json auto-commit now uses a separate
shallow clone of the PR branch, so the pushed commit contains only the
spec change rather than the merge-commit tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit bcddbdf. Configure here.

Comment thread .github/workflows/ci.yml
tmp=$(mktemp -d)
git clone --depth 1 --branch "${{ github.head_ref }}" \
"https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" \
"$tmp"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Script injection via github.head_ref in shell command

Medium Severity

${{ github.head_ref }} is interpolated directly into a run: shell script, which is a known GitHub Actions script injection vector. A branch name containing shell metacharacters (e.g., backticks or $()) would execute arbitrary commands in a context where GITHUB_TOKEN with contents: write is available. The safe pattern is to pass the value via an env: mapping (e.g., HEAD_REF: ${{ github.head_ref }}) and reference "$HEAD_REF" in the script instead.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bcddbdf. Configure here.

@ragnorc ragnorc merged commit 567ebe5 into main Apr 19, 2026
5 checks passed
@aaltshuler aaltshuler deleted the ragnorc/explore-api branch June 8, 2026 15:43
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.

1 participant