Repository navigation
fix(cli): refresh v0.4.0 and v0.5.0 base specs from core - #1417
Open
karinamzalez wants to merge 1 commit into
Open
karinamzalez wants to merge 1 commit into
karinamzalez wants to merge 1 commit into
Conversation
Regenerates the committed base specs so they match what the CLI build produces and what the website publishes. For v0.4.0, the awards routes are now tagged optional instead of experimental, matching the promotion in the v0.5.0 core release (#1268). Other changes are description and example values only.
SnowboardTechie
approved these changes
Nov 20, 2026
karinamzalez
added a commit
that referenced
this pull request
Nov 20, 2026
) ### Summary - Fixes #1390 - Time to review: 30 minutes Makes `cg check spec` check the version negotiation headers from ADR 0032 against the 0.6.0 spec, and adds a single clear error for APIs that put the version in their paths. Checking that multi-version servers publish the discovery route is out of scope, since route tags can't express that rule. > [!IMPORTANT] > This targets `CORE-v0.6.0`. The bundled 0.6.0 spec is regenerated from the latest `CORE-v0.6.0`, so it includes the version headers (#1401), the version errors (#1414), and the versions discovery route (#1399). ### Changes proposed - Sort protocol versions as version numbers, so 0.10.0 comes after 0.9.0: - `lib/cli/src/commands/check/check-args.ts`: new `parseBaseVersions` sorts with `semver` and skips file names that aren't a clean version - `lib/cli/package.json`, `pnpm-lock.yaml`: add `semver` and `@types/semver` - `lib/cli/lib/openapi/openapi.0.6.0.yaml`: bundle the 0.6.0 base spec (version headers, version errors, and the `/common-grants/versions` discovery route), which becomes the default when no `--protocol-version` is passed - `lib/cli/src/commands/check/utils/check-matching-routes.ts`: - Report a missing header parameter (such as `CG-Version`) and a missing required response header (such as `CG-Version-Served`) as errors. Names match regardless of case, and a header declared once on the path item counts. - Check headers on routes tagged `experimental` too, which still skip the other checks - Only treat HTTP methods on a path item as routes, so path-level `parameters` aren't checked as a route - `lib/cli/src/commands/check/utils/check-extra-routes.ts`: same fix, so path-level `parameters` or `summary` aren't reported as extra routes - `lib/cli/src/commands/check/utils/check-path-versioning.ts`: new check that reports one error when routes put a protocol version like `v0.6` right before or after `/common-grants/`. It only mentions `CG-Version` when the base spec declares it, and leaves a host API's own versioning like `/api/v2/common-grants/` alone. - `lib/cli/src/commands/check/check-service.ts`: run the path versioning check first and stop there if it fires, instead of listing every route as missing - `lib/cli/src/commands/check/utils/types.ts`, `utils/error-utils.ts`: new error types and their labels in the output - `lib/cli/src/commands/check/README.md`: document the header and path versioning checks - `lib/cli/src/__tests__/commands/check/`: unit tests for each check, plus end-to-end tests that edit the bundled specs ### Context for reviewers Look most closely at `check-matching-routes.ts`: header expectations come from the base spec rather than a version check in code, which is why checks against 0.1.0 to 0.5.0 are unchanged. To verify: 1. Build the CLI and run its tests: `pnpm --filter @common-grants/cli run ci`. Expect 171 passing tests. The build also regenerates the 0.1.0 to 0.5.0 specs, so run `git checkout lib/cli/lib/openapi` afterwards (#1417 refreshes 0.4.0 and 0.5.0 separately). 2. From `lib/cli`, check the 0.5.0 spec against 0.5.0: `node dist/index.js check spec lib/openapi/openapi.0.5.0.yaml --protocol-version 0.5.0`. Expect `Spec is valid and compliant with base spec`, the same as today. 3. Check the same spec with no version: `node dist/index.js check spec lib/openapi/openapi.0.5.0.yaml`. Expect it to fail, with `Header parameter missing` and `Response header missing` on each route, plus a warning that the optional `GET /common-grants/versions` route is missing, because 0.6.0 is now the default. ### Additional information Output from the built CLI. `missing-headers.yaml` is the 0.6.0 spec with `CG-Version` removed from one route and `CG-Version-Served` removed from another. `versioned-paths.yaml` is the 0.6.0 spec with every route under `/v0.6`. ``` $ cg check spec missing-headers.yaml --protocol-version 0.6.0 Validation error: Spec validation failed: 2 errors ================================= Route conflicts GET /common-grants/opportunities 1 issues found: Header parameter missing Message: Missing header parameter [CG-Version] GET /common-grants/opportunities/{oppId} 1 issues found: Response header missing Status code: 200 Message: Missing response header [CG-Version-Served] for status code [200] ``` ``` $ cg check spec versioned-paths.yaml Validation error: Spec validation failed: 1 errors ================================= Version in path Routes put the protocol version in the path, such as '/v0.6/common-grants/applications/search'. Serve CommonGrants routes under '/common-grants/' with no version segment and select the version with the 'CG-Version' request header (ADR 0032). ``` ``` $ pnpm --filter @common-grants/cli run ci All matched files use Prettier code style! Compilation completed successfully. Test Files 19 passed (19) Tests 171 passed (171) ``` Release note: the FastAPI template's CI runs `cg check spec openapi.yaml` with no version against the published CLI. Once CLI 0.6.0 is released, that job will fail until the template adds the version headers or pins `--protocol-version 0.5.0`.
This branch has not been deployed
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
cg check specchecks an API against the CLI's own copy of the protocol spec for the version you pick. The CLI's copies of the 0.4.0 and 0.5.0 specs had fallen out of date. This PR replaces them with fresh copies generated from the current core library. The 0.6.0 spec is out of scope; #1390 adds it.Changes proposed
lib/cli/lib/openapi/openapi.0.4.0.yaml:lib/cli/lib/openapi/openapi.0.5.0.yaml: timestamp examples now end inZ(fix(core): give timestamp examples a UTC offset #1342). No effect on checks.Context for reviewers
Look most closely at what changes for
cg check spec --protocol-version 0.4.0:This is intended. The core library doesn't set these labels per version, so the v0.5.0 change applies to 0.4.0 too, and the v0.5.0 release notes say so.
To verify:
pnpm --filter @common-grants/cli run ci. It should pass.git status. The build should leave no changes inlib/cli/lib/openapi/, which means the committed copies match what the build generates.diff website/public/openapi/openapi.0.4.0.yaml lib/cli/lib/openapi/openapi.0.4.0.yaml, then the same for 0.5.0. There should be no output, which means the CLI now matches the specs the website publishes.Additional information
pnpm --filter @common-grants/cli run ci(checks, build, tests):CLI spec copies compared with the website's published copies: