Course Map Schema Publishing
What ships today
- TS source of truth:
packages/course-map-shared/src/types.ts(CourseMap). - Generated JSON Schema:
packages/course-map-shared/schema/course-map.v1.jsonβ checked in, draft 2020-12,additionalProperties: falseeverywhere. - Generator:
npm run schema:generate -w @course-map/shared(usests-json-schema-generator, reads JSDoc tags). - Drift check:
npm run schema:check -w @course-map/sharedβ runs in CI when course-map types or the schema file change. - Version constants:
COURSE_MAP_SCHEMA_VERSION(1.0.0) andCOURSE_MAP_SCHEMA_URLexported from@course-map/shared. - JSON exports:
GET /api/course-maps/:id/export.jsonstamps every download with$schema+schemaVersionas the first two keys, soajvand IDEs bind validators automatically.
What hasnβt shipped yet
- Hosting: The canonical
$idishttps://schema.theaccessible.org/course-map/v1.json, but the domain does not resolve yet. Downloaded JSON files reference it; following the URL 404s today.
Hosting plan
When ready to publish:
- Stand up a small Cloudflare Pages project at
schema.theaccessible.org. - Serve the generated
course-map.v1.jsonat/course-map/v1.json, withCache-Control: public, max-age=300, must-revalidateand CORS*(itβs a public spec). - Set up a GitHub Action that re-publishes the file on every push to
mainthat touchespackages/course-map-shared/schema/. - After publication, smoke-test with
ajv -s <url> -d <export.json>.
Versioning
- MAJOR bumps change the URL (
/course-map/v2.json). Add the new schema file alongside the old one; keep v1 available indefinitely. - MINOR/PATCH bumps stay at the same URL but increment
COURSE_MAP_SCHEMA_VERSION. Only backwards-compatible additions are allowed. - A change is breaking if it: removes a property, narrows a string format/pattern, removes an enum value, or makes an optional property required. Anything else is non-breaking.
How to evolve the schema
- Edit
packages/course-map-shared/src/types.ts(add fields, refine JSDoc). - Bump
COURSE_MAP_SCHEMA_VERSIONaccordingly. - Run
npm run schema:generate -w @course-map/sharedand commit both files in the same PR. - CI drift check will fail otherwise.
Why the schema doesnβt validate catalogUrlTemplate as a URI
The template contains {code} / {subject} / {number} placeholders, which are not valid in RFC 3986 URIs. The schema uses a pattern regex to require a http(s)://... prefix and at least one placeholder; full URI validation happens after substitution at use sites (substituteCatalogUrl).