TypeSchema: skip base choice declarations in inheritedRequiredFields#170
Merged
Conversation
A required base choice (e.g. value[x], 1..1) is satisfied via a variant,
not a property literally named value[x]. Listing it would emit
validateRequired("value[x]") — a check against a key that never exists in
FHIR JSON. Skip it; proper validateChoiceRequired handling is tracked in #169.
sussdorff
added a commit
to cognovis/codegen
that referenced
this pull request
Jun 2, 2026
…nherited-required choice-skip + atomic-ehr#166 inherited-required validation (f027e0f)
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.
Follow-up to #166. The
inheritedRequiredFieldscollection pushed any base-required field by name, including choice declarations.A required base choice (e.g.
value[x],1..1) is satisfied via one of its variants — there is no property literally namedvalue[x]in FHIR JSON. EmittingvalidateRequired(res, profileName, "value[x]")for it produces a check that can only misfire. This skips choice-declaration base fields in the collection loop.Proper
validateChoiceRequired()handling for inherited required choices is deferred to the per-type validator redesign in #169, which replaces this collection path entirely.Generated code — a profile inheriting a base-required
value[x]it does not re-state:Before:
After:
// (no call emitted; tracked for validateChoiceRequired in #169)src/typeschema/utils.ts: skipisChoiceDeclarationFieldbase fields inbuildProfileSnapshot's inherited-required collection.test/unit/typeschema/utils.test.ts: regression covering a base-requiredvalue[x]left un-restated by the profile.