Skip to content

fix(typescript): Keep the extension prefix in @type, and test generated TypeScript in models-ts - #71

Open
howaskew wants to merge 2 commits into
masterfrom
fix/example-spec-types
Open

howaskew wants to merge 2 commits into
masterfrom
fix/example-spec-types

Conversation

@howaskew

@howaskew howaskew commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the @type of beta and test interface classes in the generated TypeScript, and adds a check that builds and tests the generated TypeScript in models-ts on every models-lib pull request.

Supersedes #68 and #69 (thanks @nickevansuk).

1. Keep the extension prefix in @type (supersedes #68)

The TypeScript template used the unprefixed name, so beta:Bar was generated as '@type': 'Bar', which in JSON-LD means https://schema.org/Bar. This affects all 8 beta classes and all 16 test interface classes, and two of the data-models examples fail the models-ts build because of it.

#68 used the full modelType, which also prefixes schema.org classes ('schema:Thing', and 874 schema.org files in all). That breaks valid data: models-ts then rejects {"@type": "ContactPoint"}, data-models' own event_example_1 and place_example_1 no longer type-check (4 build errors), and data written to #68's types fails the data model validator ("schema:ImageObject": "Invalid type, expected Array of ImageObject").

This change adds jsonLdTypeName: the full type when the prefix is not schema, otherwise the unprefixed name. Only the 24 beta and test class files change (2 lines each); schema.org and OpenActive types are unchanged. .NET, PHP and Ruby already use the full type.

Class Before #68 This PR
Thing (schema.org) 'Thing' 'schema:Thing' 'Thing'
Event (OpenActive) 'Event' 'Event' 'Event'
Bar (beta) 'Bar' 'beta:Bar' 'beta:Bar'

2. Build and test the generated TypeScript (supersedes #69)

A test-ts job runs the models-ts Update Data Model workflow with this ref, which generates the TypeScript into models-ts, then builds and tests it without creating a pull request. This uses the callable workflow added in openactive/models-ts#12 (which replaces openactive/models-ts#7), now on models-ts main.

Also updates actions/checkout and actions/setup-node to v4.

Verification

Locally, with data-models plus a one-line example fix (scheduledsession-split_example_1.json uses "type" instead of "@type"; openactive/data-models#212):

Check Result
models-ts npm run build 0 errors (3 before this PR)
models-ts npm test 34 passing
.NET, PHP, Ruby Output unchanged
actionlint No issues

Until openactive/data-models#212 is released (3.0.11), test-ts reports 1 error, in scheduledsession-split_example_1.

Note for models-ts release notes

The @type literal for beta and test classes changes (for example 'Bar' becomes 'beta:Bar'), so code relying on the unprefixed value will no longer compile.

howaskew and others added 2 commits October 21, 2026 13:15
…sses

Generated TypeScript models used the unprefixed class name as the @type
literal and in the Joi schema, so beta and test-interface classes were
typed as e.g. 'Bar' and 'OpenBookingSimulateAction'. In JSON-LD these
classes are only reachable through their extension prefix, and real data
(including the data-models place_example_1.json example) uses
'beta:Bar', 'beta:Cafe', 'test:OpenBookingSimulateAction' and so on.

OpenActive and schema.org classes keep their unprefixed names, as the
OpenActive context defines terms for OpenActive classes and uses
schema.org as its @vocab.

This fixes two of the three tsc errors in the models-ts data-models
example tests (place_example_1.spec.ts). Only the 8 beta and 16 test
interface model files change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Add a test-ts job that runs the models-ts Update Data Model workflow
with this models-lib ref: it generates the TypeScript models into
models-ts, then builds and tests them, without creating a pull request.
Generator changes that produce invalid TypeScript are then caught on the
models-lib pull request instead of after a data-models release.

Supersedes #69, and needs the models-ts workflow to accept
workflow_call (models-ts ci/testable-build-v2, replacing models-ts #7).

Also update actions/checkout and actions/setup-node to v4.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant