Skip to content

feat(course): migrate Course API to TypeBox schemas#2317

Closed
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:feat/course-typebox-schemas
Closed

feat(course): migrate Course API to TypeBox schemas#2317
dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa:feat/course-typebox-schemas

Conversation

@dirkwa
Copy link
Contributor

@dirkwa dirkwa commented Feb 10, 2026

In reference to SignalK/specification#671

The Course API's openApi.json (773 lines) had to be manually kept in sync
with the validation code and TypeScript types. This PR replaces that with
TypeBox schemas that serve as single source of truth — change a schema once
and types, validation, and API docs all update.

What changes:

  • New course-schemas.ts in server-api defines all Course API schemas
    using TypeBox. Types are derived via Static<>, validation uses
    Value.Check(), and both OpenAPI + AsyncAPI docs are generated from them.

  • openApi.json is deleted. The OpenAPI document is now built
    programmatically in openApi.gen.ts, upgraded to OAS 3.1, with version
    read from package.json.

  • api-schema-builder validation in the course handler is replaced with
    TypeBox Value.Check/Errors.

  • New AsyncAPI 3.0 document for the Course API's WebSocket delta channels
    (v2 navigation.course.*, v1 courseGreatCircle.*/courseRhumbline.*),
    served with an interactive HTML viewer at /skServer/asyncapi/course/docs.

  • Admin sidebar: "Documentation" is now a dropdown with Documentation,
    OpenAPI, and AsyncAPI links.

  • ESLint: added @typescript-eslint/no-unused-expressions: off for test
    files (needed alongside the existing no-unused-expressions: off for
    chai assertions).

53 new schema validation tests. All 371 existing tests pass.

IMAGES:

image image image image image image

Replace hand-maintained openApi.json (773 lines) and api-schema-builder
validation with TypeBox schemas as single source of truth for types,
runtime validation, OpenAPI 3.1, and AsyncAPI 3.0 documentation.

- Add TypeBox course schemas to @signalk/server-api with Static<> type
  derivation, 53 unit tests
- Generate OpenAPI 3.1 document programmatically from schemas with
  recursive metadata stripping for full Swagger UI expansion
- Replace api-schema-builder validation with Value.Check/Errors
- Add AsyncAPI 3.0 for WebSocket delta channels (v2 navigation.course.*,
  v1 courseGreatCircle.*/courseRhumbline.*) with HTML viewer
- Read server version from package.json dynamically for both specs
- Add Documentation dropdown in admin sidebar with docs, OpenAPI,
  AsyncAPI links
- Fix eslint config: disable @typescript-eslint/no-unused-expressions
  for test files alongside base rule (chai compatibility)
@dirkwa
Copy link
Contributor Author

dirkwa commented Feb 13, 2026

Replaced by improved #2322

@dirkwa dirkwa closed this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants