You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
build: track the OpenAPI spec and regenerate the client in pre-commit - #177
Tracks the OpenAPI spec as backend/openapi.json and adds a pre-commit hook that runs make generate-client, so API schema changes show up in review as a spec diff instead of only through types.gen.ts.
The hook runs when backend/src/, backend/uv.lock, scripts/generate-client-sdk.shbackend/openapi.json, frontend/openapi-ts.config.ts or frontend/package.json changes, and fails the commit when the spec or client moved, like any fixing hook.
The spec is written with indent=2 for readable diffs. Regenerating on main leaves the client unchanged, so it was already in sync.
It adds about 8 seconds to backend commits, and the first run fetches openapi-ts through npx.
Checked by making ExecutionOutput.filename nullable and committing. The hook failed and rewrote both backend/openapi.json and types.gen.ts.
CI does not run pre-commit, so a --no-verify commit can still drift. A CI job running make generate-client then git diff --exit-code would close that, and I left it out to keep this small. Whichever of this and #173 merges second needs the spec regenerated, because #173 changes ExecutionOutput.
Commits frontend/openapi.json, written with indentation so schema changes show as readable diffs.
A pre-commit hook runs make generate-client when backend code, the lock file or the generator config changes, and fails the commit if the spec or client moved.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 0d984053-f99c-4c69-ba92-b48be0f848b2
Commits
Reviewing files that changed from the base of the PR and between 7130f0f and 2a5266a.
Files selected for processing: 8
.pre-commit-config.yaml
README.md
backend/openapi.json
changelog/177.trivial.md
frontend/.gitignore
frontend/README.md
frontend/openapi-ts.config.ts
scripts/generate-client-sdk.sh
Walkthrough
The OpenAPI JSON output now uses two-space indentation and is no longer ignored. A serial pre-commit hook runs client generation when matching backend, generator-script or OpenAPI paths change. The changelog records this workflow.
Changes: OpenAPI generation
Layer / File(s)
Summary
Generation and tracking scripts/generate-client-sdk.sh, frontend/.gitignore, .pre-commit-config.yaml, changelog/177.trivial.md
The generator writes indented OpenAPI JSON. The OpenAPI file is no longer ignored. A serial pre-commit hook runs make generate-client for matching paths without passing filenames. The changelog describes the tracked specification and hook.
Possibly related issues
Publish a Python client for the REF API #171: This PR adds the committed OpenAPI specification and automatic regeneration described in the issue. It does not implement the Python client or CI drift check.
Climate-REF/ref-app#172: This PR changes backend API responses and generated client types; this change adds regeneration for backend changes.
Climate-REF/ref-app#147: This PR changes API routes and the generated frontend client; this change adds automatic regeneration.
Climate-REF/ref-app#173: This PR changes an API contract, and its description identifies OpenAPI regeneration as relevant when combined with this change.
Change: Other
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "build: track the OpenAPI spec and regenerate the client in pre-commit" matches the main changes. The PR adds frontend/openapi.json to version control (removed from frontend/.gitignore), and…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "build: track the OpenAPI spec and regenerate the client in pre-commit" matches the main changes. The PR adds frontend/openapi.json to version control (removed from frontend/.gitignore), and adds a pre-commit generate-client hook that runs make generate-client. The title is specific and concise, and a reviewer scanning history can identify the primary change.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Review coverage is incomplete: 1 file could not be fully reviewed. Findings from completed review steps are included; see review info for details.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Nitpick comments: 1
.pre-commit-config.yaml: 1
71-77: Trivial · Data Integrity & Integration · Heavy lift
Add a CI job that fails when the committed OpenAPI spec or client is stale.
The pre-commit hook is the only step that regenerates frontend/openapi.json and frontend/src/client/. The hook is installed only by make setup, and git commit --no-verify skips it. No job in .github/workflows/ci.yml regenerates these files or compares them with the committed versions. The frontend build also uses the committed client without regenerating it. A stale spec or client can therefore merge.
Add a job that regenerates both files and fails on any difference, then add it to ci-pass so that it gates merges:
Suggested CI change
+ generated-client:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v7+ - name: Install uv+ uses: astral-sh/setup-uv@v10.3.2+ with:+ enable-cache: true+ - name: Setup Node.js+ uses: actions/setup-node@v7+ with:+ node-version: '24'+ - name: Regenerate the OpenAPI spec and client+ run: make generate-client+ - name: Fail if the committed spec or client differs+ run: test -z "$(git status --porcelain -- frontend/openapi.json frontend/src/client)"
Confirm that generation is deterministic on the runner before making the job required.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: f4f1555d-dca0-4a69-b588-cd2715257326
Commits
Reviewing files that changed from the base of the PR and between 7130f0f and eb45f49.
Files selected for processing: 5
.pre-commit-config.yaml
changelog/177.trivial.md
frontend/.gitignore
frontend/openapi.json
scripts/generate-client-sdk.sh
Files not fully reviewed because their changes were unavailable: 1
frontend/openapi.json
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
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.
Tracks the OpenAPI spec as
backend/openapi.jsonand adds a pre-commit hook that runsmake generate-client, so API schema changes show up in review as a spec diff instead of only throughtypes.gen.ts.backend/src/,backend/uv.lock,scripts/generate-client-sdk.shbackend/openapi.json,frontend/openapi-ts.config.tsorfrontend/package.jsonchanges, and fails the commit when the spec or client moved, like any fixing hook.indent=2for readable diffs. Regenerating onmainleaves the client unchanged, so it was already in sync.openapi-tsthroughnpx.Checked by making
ExecutionOutput.filenamenullable and committing. The hook failed and rewrote bothbackend/openapi.jsonandtypes.gen.ts.CI does not run pre-commit, so a
--no-verifycommit can still drift. A CI job runningmake generate-clientthengit diff --exit-codewould close that, and I left it out to keep this small. Whichever of this and #173 merges second needs the spec regenerated, because #173 changesExecutionOutput.