Skip to content

TypeSchema: skip base choice declarations in inheritedRequiredFields#170

Merged
ryukzak merged 2 commits into
mainfrom
fix/inherited-required-skip-choice-decl
Jun 1, 2026
Merged

TypeSchema: skip base choice declarations in inheritedRequiredFields#170
ryukzak merged 2 commits into
mainfrom
fix/inherited-required-skip-choice-decl

Conversation

@ryukzak
Copy link
Copy Markdown
Collaborator

@ryukzak ryukzak commented Jun 1, 2026

Follow-up to #166. The inheritedRequiredFields collection 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 named value[x] in FHIR JSON. Emitting validateRequired(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:

...validateRequired(res, profileName, "value[x]"),   // checks a key that never exists

After:

// (no call emitted; tracked for validateChoiceRequired in #169)
  • src/typeschema/utils.ts: skip isChoiceDeclarationField base fields in buildProfileSnapshot's inherited-required collection.
  • test/unit/typeschema/utils.test.ts: regression covering a base-required value[x] left un-restated by the profile.

ryukzak added 2 commits June 1, 2026 16:06
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.
@ryukzak ryukzak merged commit 4f4ccda into main Jun 1, 2026
37 checks passed
@ryukzak ryukzak deleted the fix/inherited-required-skip-choice-decl branch June 1, 2026 15:12
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)
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