Skip to content

Code Generator

FHIR resource code generation utilities.

generator

Classes:

Name Description
CodeGenerator

CodeGenerator

Path: fhircraft.fhir.resources.generator.CodeGenerator

CodeGenerator()

Methods:

Name Description
generate_resource_model_code

Generate the source code for resource model(s) based on the input resources.

generate_resource_model_code

generate_resource_model_code(resources: type[BaseModel] | List[type[BaseModel]], include_validators: bool = True) -> str

Generate the source code for resource model(s) based on the input resources.

Parameters:

Name Type Description Default
resources Union[BaseModel, List[BaseModel]]

The resource(s) to generate the model code for.

required
include_validators bool

Whether to include validators in the generated code (default: True). Recommended to be True for most use cases.

True

Returns:

Name Type Description
str str

The generated source code for the resource model(s).