Repository navigation
docs(website): document version negotiation for v0.6.0 - #1423
Draft
SnowboardTechie wants to merge 24 commits into
Draft
SnowboardTechie wants to merge 24 commits into
SnowboardTechie wants to merge 24 commits into
Conversation
### Summary - Fixes #1159 - Time to review: 30 minutes ### Changes proposed Adds [ADR 0032](https://github.com/HHS/simpler-grants-protocol/blob/bryan/1159-adr-0032-version-negotiation/website/src/content/docs/governance/adr/0032-api-version-negotiation.md), which decides how a client asks a CommonGrants API for a protocol version and what the server tells it back: - A client selects a version with an optional `CG-Version` request header. Every response confirms the version served in `CG-Version-Served`, and a client that sends no version gets the server's pinned default. - A server publishes the versions it serves at `GET /common-grants/versions`, as a baseline plus entries for routes that differ. - Version problems get dedicated codes: `version.malformed` and `version.conflict` (400), and `version.unsupported` and `version.retired` (406). - Retirement uses the standard `Deprecation`, `Sunset`, and `Link` headers. A change of default uses `Link` with `rel="successor-version"`, and the date is published in discovery. The ADR is organized as Overview, Evaluation, and Specification, with client and implementer questions in each area. It also covers how a client discovers versions and how a server retires one. It also answers #1372, which is already closed. ### Context for reviewers Implementation is tracked in the [[Core] v0.6.0 release](https://github.com/HHS/simpler-grants-protocol/milestone/5) milestone: headers #1386, discovery #1387, version errors #1388, and the mock API #1393. The specification's versioning section still describes a patch as adding "new optional functionality", which contradicts this ADR. #1389 owns that correction, along with documenting the default-change link. This PR also adds a "Partly superseded" note to [ADR 0028](https://github.com/HHS/simpler-grants-protocol/blob/bryan/1159-adr-0032-version-negotiation/website/src/content/docs/governance/adr/0028-mock-api-hosting.md), since this decision replaces its version path prefix while the rest of 0028 stands. Verified locally: Prettier and cspell pass on the changed files, and the website builds. ### Additional information Rendered page: the website preview link on this PR, at `/governance/adr/0032-api-version-negotiation/`.
Adds GET /common-grants/versions to the 0.6.0 base API, tagged optional, with the VersionDiscovery, OperationVersions, UpcomingDefault and VersionRetirement models and a protocolVersion type. The route lets a server publish its default version, the versions every route serves, per-route exceptions, an upcoming default and deprecated versions, per the API version negotiation ADR draft (#1159, #1372). Versions.v0_6 and Types.protocolVersion are stubs owned by #1386 and are dropped when that PR lands. The 0.1.0 through 0.5.0 OpenAPI documents are unchanged. Refs #1387
Discovery sits outside version selection, so its models tolerate fields they don't know instead of being versioned per document, as the route description promises. The baseline fields now say they describe routes without an operations entry, versions requires at least one entry, and the deprecated map documents its keys. Refs #1387
OkT now spreads the version response headers, so discovery would have advertised CG-Version-Served and Vary. ADR 0032 says discovery carries neither, because clients call it before they know which version to request. The route returns a dedicated VersionDiscoveryResponse instead. Refs #1387
The defaultVersion docs now say a default is one of the listed versions, which the schema can't express. The route description adds the ADR's authentication ceiling and narrows "fields are only ever added" to data, since the response envelope stays closed. The interface comment says adopters don't type-parameterize the response, now that the models accept unknown fields. Refs #1387
Adds the lookup protocol pages will use to show a schema's code without file paths or line numbers. TypeSpec is read with the compiler's own parser; TypeScript with the TypeScript parser; Python with a small scanner that tracks brackets and strings. A name that isn't declared, or is declared more than once, throws.
Each protocol page now names the schema in <SchemaTable schema=...> and <SchemaFormatTabs schema=... typeSpec python typescript>, and the code tabs show the whole declaration found by name. About 100 tabs that were cut off, shifted or showing other code now show the right declaration, and a schema or snippet that can't be found fails the build. The schema-to-page map that links table types to their pages is built from the pages during the site build, so generate-schema-docs.ts goes, along with generate-schema-metadata.ts, generate-type-formatting.ts and SchemaMetadataLoader, whose output nothing read. Closes #872
… fields - The dev server re-reads the TypeSpec, Python and TypeScript sources once per page render, so a source edit shows on reload; a production build still reads them once. - Declarations shown together keep the blank lines the source has between them, so Python classes sit two blank lines apart. - The Python tabs for the pagination and sorting models show their base class (PaginatedBase, SortBase), which holds the inherited fields. - Drop code with no reader: the example file branch, the cache-clearing helper and an export; use the TypeSpec parser's line lookup and one shared recursive file listing.
…-docs # Conflicts: # website/public/openapi/openapi.0.6.0.yaml
Move the specification page to v0.6.0, correct the patch rule, and add the version negotiation rules from ADR 0032, including the successor-version link that announces a change of default. Add the discovery route to the routes tables, v0.6.0 migration notes, and a Versioning page that explains the model with the ADR's examples.
Contributor
|
🚀 Website Preview Deployed! Preview your changes at: https://pr-1423-common-grants.agile6.workers.dev Built from commit 67fe607 |
3 tasks
Adds GET /common-grants/versions to the 0.6.0 base API, tagged optional, with the VersionDiscovery, OperationVersions, UpcomingDefault and VersionRetirement models and a protocolVersion type. The route lets a server publish its default version, the versions every route serves, per-route exceptions, an upcoming default and deprecated versions, per the API version negotiation ADR draft (#1159, #1372). Versions.v0_6 and Types.protocolVersion are stubs owned by #1386 and are dropped when that PR lands. The 0.1.0 through 0.5.0 OpenAPI documents are unchanged. Refs #1387
Discovery sits outside version selection, so its models tolerate fields they don't know instead of being versioned per document, as the route description promises. The baseline fields now say they describe routes without an operations entry, versions requires at least one entry, and the deprecated map documents its keys. Refs #1387
OkT now spreads the version response headers, so discovery would have advertised CG-Version-Served and Vary. ADR 0032 says discovery carries neither, because clients call it before they know which version to request. The route returns a dedicated VersionDiscoveryResponse instead. Refs #1387
The defaultVersion docs now say a default is one of the listed versions, which the schema can't express. The route description adds the ADR's authentication ceiling and narrows "fields are only ever added" to data, since the response envelope stays closed. The interface comment says adopters don't type-parameterize the response, now that the models accept unknown fields. Refs #1387
Validate each key of `deprecated` against the protocol version format in the JSON Schema files, and say that an upcoming default is one of `versions`, as ADR 0032 requires of every default.
A key is written exactly as its version appears in `versions`. Matching on major and minor is how a client finds the entry for the version it requested, so say that separately, with an example.
…nto bryan/1389-versioning-docs # Conflicts: # lib/core/lib/core/models/version-discovery.tsp # website/public/openapi/openapi.0.6.0.yaml # website/public/schemas/yaml/OperationVersions.yaml # website/public/schemas/yaml/VersionDiscovery.yaml
This was referenced Nov 20, 2026
…sioning-docs # Conflicts: # website/src/content/docs/governance/adr/0028-mock-api-hosting.md
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
Changes proposed
The protocol docs now describe version negotiation as ADR 0032 settles it, so a client or implementer can read how to find, request and retire versions without reading the ADR.
CG-Version, the response headers, the four version errors, the discovery route, retiring a version, and changing the default.Linkwithrel="successor-version"on responses served by default, with the date in discovery'supcomingDefaultand noDeprecationorSunset./protocol/versioning/), modeled on Authentication and scopes, walks through discovery, asking for a version, confirming what was served, the version errors, and the retirement and default-change signals. It ends with tables and TypeSpec for the discovery and version error schemas.GET /versionsis listed in the routes tables as optional, with the rule that a server serving more than one version MUST implement it stated in the text.Model, type and response pages and the API docs dropdown are not touched here. They belong to #1391.
Context for reviewers
Only three files are this PR's own:
website/src/content/docs/protocol/specification/index.md,website/src/content/docs/protocol/versioning.mdxand the sidebar entry inwebsite/astro.config.mjs. The comparison from the second merge commit shows just those.The rest of the diff comes from two open PRs this branch is built on, and drops out as they land:
main). The new page uses its<SchemaTable schema="…" />and<SchemaFormatTabs schema="…" typeSpec />components. Once it merges,maingets merged intoCORE-v0.6.0.CORE-v0.6.0). The new page renders itsVersionDiscoveryschemas. Merging it here conflicted only in the generatedopenapi.0.6.0.yaml, which was regenerated with the website's TypeSpec step.This stays a draft until both have merged.
Things worth a look:
VersionErrorScopehas a hand-written table. The generated JSON Schema doesn't carry the enum members' descriptions, so the generated table had an empty description column.SortOrderon the sorting page is written the same way.CG-Version-Served, but the shared 400 response declares it optional because version errors use the same status and must not carry it; anddiscoveryon a version error is optional in TypeSpec because a single-version server needn't publish discovery.CORE-v0.6.0reachesmain, not when this PR merges.Verified by building the site on this branch (
pnpm run build, all internal links valid),pnpm run test(1,264 tests pass), eslint, Prettier,tsc,astro checkand cspell, then reading the built specification and versioning pages against ADR 0032.Additional information
Rendered pages in this PR's website preview: Versioning and the specification's Versions section.