PY: default fieldFormat to camelCase#189
Merged
Merged
Conversation
- Change Python generator default fieldFormat from snake_case to camelCase - Use the formatted resourceType field name in __pydantic_fields_set__.add instead of a hardcoded snake_case literal - Drop the TYPE_CHECKING resourceType shim from fhirpy base model; camelCase models expose resourceType natively, so the static alias workaround is no longer needed
- Update marital_status assertion to maritalStatus in python writer test - Regenerate Python snapshots (camelCase field names, resourceType)
- Drop explicit fieldFormat: snake_case from us-core generate.ts (now uses the camelCase default) - Update hand-written demos/tests to camelCase field access, kwargs, raw extension dict keys, and validation error message assertions
MikhailArtemyev
approved these changes
Jun 19, 2026
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.
Default change
fieldFormattocamelCase(wassnake_case). Fields keep their FHIR spelling instead of being converted.Generated models before/after — using FHIR field names directly avoids the snake_case ↔ alias indirection:
Opt back into snake_case explicitly (unchanged behavior):
Generator fixes
__pydantic_fields_set__.add(...)now uses the formattedresourceTypefield name instead of a hardcoded"resource_type"literal — for camelCase models the field isresourceType, so the old literal marked a non-existent field as set.TYPE_CHECKINGresourceTypeshim from the fhirpy base model. It existed so static type-checkers saw aresourceTypeattribute on snake_case models (where the field isresource_type). camelCase models exposeresourceTypenatively, so the shim is unnecessary.Example & tests
examples/python-r4-us-core: dropped explicitfieldFormat: "snake_case"(now uses the camelCase default) and migrated hand-written demos/tests to camelCase field access, kwargs, raw-extension dict keys, and validation-message assertions.mypyand the offline pytest suite pass.examples/python-r4keepsfieldFormat: "snake_case"to retain snake_case coverage at generation level.Note
resourceTypeshim, somypyagainst snake_case fhirpy models will reportResourceProtocolnon-conformance. The default (camelCase) is unaffected.