Skip to content

PY: generate resourceType as str instead of Literal#190

Merged
ryukzak merged 3 commits into
mainfrom
py-resourcetype-str
Jun 26, 2026
Merged

PY: generate resourceType as str instead of Literal#190
ryukzak merged 3 commits into
mainfrom
py-resourcetype-str

Conversation

@ryukzak

@ryukzak ryukzak commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Generate the resourceType field as str instead of a per-resource Literal[...]. The value is still validated on the Pydantic side via Field(pattern=...); a per-subclass Literal narrows the parent field and is redundant with the pattern.

Before:

class Observation(DomainResource):
    resourceType: Literal['Observation'] = Field(
        default='Observation',
        alias='resourceType',
        serialization_alias='resourceType',
        pattern='Observation'
    )

After:

class Observation(DomainResource):
    resourceType: str = Field(
        default='Observation',
        alias='resourceType',
        serialization_alias='resourceType',
        pattern='Observation'
    )
  • Update Python writer + multi-package snapshots (cda, sql-on-fhir, local-package).
  • Regenerate the python-r4-us-core example.

Follow-up: shadow-warning fix split into #191.

ryukzak added 3 commits June 26, 2026 10:19
Validate the value via the Field pattern instead of a Literal type. A
per-subclass Literal narrows the parent field and is redundant with the
pattern constraint.
@ryukzak ryukzak merged commit a186134 into main Jun 26, 2026
35 checks passed
@ryukzak ryukzak deleted the py-resourcetype-str branch June 26, 2026 08:29
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