Skip to content

docs(website): show v0.6.0 on the model, type and API docs pages - #1428

Draft
SnowboardTechie wants to merge 29 commits into
CORE-v0.6.0from
bryan/1391-v06-docs-pages
Draft

SnowboardTechie wants to merge 29 commits into
CORE-v0.6.0from
bryan/1391-v06-docs-pages

Conversation

@SnowboardTechie

@SnowboardTechie SnowboardTechie commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Changes proposed

The protocol docs now cover the 0.6.0 core library, and the API docs page offers v0.6.0 as its default and sends the selected version as CG-Version from "Try it out".

  • API docs dropdown is built from the OpenAPI documents. api-docs.astro lists every public/openapi/openapi.X.Y.Z.yaml the build emits, newest first, with the newest labelled "(Latest)" and selected by default. It no longer needs a hand edit per release, and the build fails if no document is found. Today that is v0.6.0 (Latest) down to v0.1.0. The filename parsing moved from inject-mock-server.ts to website/src/lib/openapi-versions.ts so both use one regex.
  • "Try it out" sends CG-Version. A Swagger requestInterceptor sets the header to the selected version on calls to the mock, unless the user typed a value. It uses the withVersionHeader helper that feat(website): move the mock API to the CG-Version header #1415 (the mock API's move to the CG-Version header) added to the hold branch, so the mock answers in the version picked in the dropdown.
  • New sections for 0.6.0 schemas: protocolVersion on the string types page, and VersionDiscoveryResponse on the success responses page, each with a card on its index page.
  • Response pages describe the version headers. Success, paginated, sorted and filtered say which typed responses carry CG-Version-Served, Vary, Deprecation, Sunset and Link from v0.6.0, and link the Versioning page and the specification.
  • "Common Error Types" on the error page matches 0.6.0. It showed the 0.5 aliases. It now shows the aliases with their header models, BadRequest (which declares its version header inline), the four version error aliases and WithVersionErrors<R>, copied from lib/core.
  • Two Usage examples compile again. The error page's example used TestModel without declaring it, and the filtered page's used Filters.* without using CommonGrants;.

Every other model and type table and code tab already follows 0.6.0, because #1420 generates them from the sources by schema name.

Context for reviewers

This PR's own changes are two commits. The rest of the diff comes from the PRs it builds on and drops out as they land:

  1. docs(website): document version negotiation for v0.6.0 #1423 (versioning docs, into CORE-v0.6.0), which carries docs(website): show the whole declaration in protocol docs code tabs #1420 (protocol pages find their code by schema name, into main). The new sections use docs(website): show the whole declaration in protocol docs code tabs #1420's components and link docs(website): document version negotiation for v0.6.0 #1423's Versioning page.
  2. The current CORE-v0.6.0, through docs(website): document version negotiation for v0.6.0 #1423's branch.

This comparison shows only this PR's changes. It stays a draft until #1423 has merged.

Things worth a look:

  • Overlap with feat(website): move the mock API to the CG-Version header #1415. That PR, now merged into the hold branch, already added v0.6.0 to the hand-typed dropdown list and wired withVersionHeader into the page. This PR keeps its imports (MOCK_SERVER_URL, VERSION_HEADER) and interceptor, and replaces its hand-typed list with the generated one.
  • The competition and form pages still pin their tables to v0.5.0. CompetitionBase, FormBase and the 35 schemas they reference are identical in the 0.5.0 and 0.6.0 OpenAPI documents.
  • This merges into the hold branch, so the issue closes when CORE-v0.6.0 reaches main.

Verified on the current head: build with link validation, eslint, Prettier, tsc, astro check, cspell (1,502 files) and 1,346 tests pass. In a browser against astro preview, the dropdown opens on v0.6.0. Executing GET /common-grants/opportunities on v0.4.0 sends CG-Version: 0.4.0 and the mock answers with CG-Version-Served: 0.4.0. On v0.6.0, a value typed into the CG-Version field (0.5.0) is sent instead, and served.

Additional information

Pages to check in this PR's website preview, once it deploys:

  • /protocol/api-docs/: the dropdown, and "Try it out" with the request's CG-Version
  • /protocol/types/string/#protocolversion
  • /protocol/responses/success/#versiondiscoveryresponse
  • /protocol/responses/error/#common-error-types

From the local browser run, the v0.4.0 "Try it out" request:

curl -X 'GET' \
  'http://localhost:4391/api/common-grants/opportunities?page=1&pageSize=100' \
  -H 'accept: */*' \
  -H 'CG-Version: 0.4.0'

Response headers include cg-version-served: 0.4.0 and vary: CG-Version.

SnowboardTechie and others added 26 commits November 17, 2026 16:14
### 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.
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
… and send CG-Version

The API docs dropdown now lists every emitted openapi.X.Y.Z.yaml, newest
first, and opens on the newest (v0.6.0). Try it out sends the selected
version as the CG-Version header on mock API requests, unless a value was
typed into the header field.
…nd discovery response

Adds protocolVersion to the string types, VersionDiscoveryResponse to the
success responses, a version headers note on the success, paginated, sorted
and filtered pages, and updates the common error types to the 0.6.0 aliases
with the version errors and WithVersionErrors. Fixes the error and filtered
usage examples so they compile.
@github-actions github-actions Bot added website Issues related to the website dependencies Pull requests that update a dependency file typescript Issue or PR related to TypeScript tooling labels Nov 20, 2026
…sioning-docs

# Conflicts:
#	website/src/content/docs/governance/adr/0028-mock-api-hosting.md
… bryan/1391-v06-docs-pages

# Conflicts:
#	website/src/pages/protocol/api-docs.astro
#	website/src/scripts/inject-mock-server.ts
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Website Preview Deployed!

Preview your changes at: https://pr-1428-common-grants.agile6.workers.dev

Built from commit 158ea71

@SnowboardTechie SnowboardTechie linked an issue Nov 20, 2026 that may be closed by this pull request
3 tasks

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file typescript Issue or PR related to TypeScript tooling website Issues related to the website

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Core] Update the models, types and API docs dropdown for v0.6

1 participant