feat(course): migrate Course API to TypeBox schemas#2317
Closed
dirkwa wants to merge 1 commit intoSignalK:masterfrom
Closed
feat(course): migrate Course API to TypeBox schemas#2317dirkwa wants to merge 1 commit intoSignalK:masterfrom
dirkwa wants to merge 1 commit intoSignalK:masterfrom
Conversation
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)
Contributor
Author
|
Replaced by improved #2322 |
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.
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.tsin server-api defines all Course API schemasusing TypeBox. Types are derived via
Static<>, validation usesValue.Check(), and both OpenAPI + AsyncAPI docs are generated from them.openApi.jsonis deleted. The OpenAPI document is now builtprogrammatically in
openApi.gen.ts, upgraded to OAS 3.1, with versionread from package.json.
api-schema-buildervalidation in the course handler is replaced withTypeBox
Value.Check/Errors.New AsyncAPI 3.0 document for the Course API's WebSocket delta channels
(v2
navigation.course.*, v1courseGreatCircle.*/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: offfor testfiles (needed alongside the existing
no-unused-expressions: offforchai assertions).
53 new schema validation tests. All 371 existing tests pass.
IMAGES: