Skip to content
This repository was archived by the owner on Mar 18, 2026. It is now read-only.

Add a mustache based generator#39

Draft
JulianStitz wants to merge 38 commits intofhir-schema:mainfrom
JulianStitz:main
Draft

Add a mustache based generator#39
JulianStitz wants to merge 38 commits intofhir-schema:mainfrom
JulianStitz:main

Conversation

@JulianStitz
Copy link
Copy Markdown

@JulianStitz JulianStitz commented Oct 29, 2025

Summary

This merge introduces a Mustache-based code generator designed to further separate concerns and lower the barrier for contributions to the FHIR code generation process.

Motivation

The goal is to enable a flexible and transparent way of generating source code through template sets and a minimal configuration file.
This approach allows developers to easily create tailored code for specific use cases without requiring deep knowledge of the underlying generation infrastructure.

Key Idea

By decoupling the generation logic from the template definitions, this system empowers contributors to:

  1. Define or modify templates independently,
  2. Customize output for various targets and languages,
  3. Extend or adjust the generation process with minimal setup.

Outlook

It is also conceivable to migrate the existing generators for TypeScript, Python, and C# to this model in the future, unifying the generation approach across all supported languages.

Open Tasks

  • Align code style with the rest of the repository
  • Add comprehensive test coverage
  • Complete the Java example
  • Demonstrate the general suitability of the approach
  • Add documentation and a guide on how to create templates / configuration in order to support an additional language / use-case

…ooks, debugging options, and schema-driven rendering configurations.

Provide example mustache templates to generate basic java types.
…odels, enhance template support, and eliminate unused `titleCase`.
… complex types and resources. Enhance schema handling with URI-based references, add child type support to ViewModel generation, and update templates accordingly.
…ng whitelists/blacklists for resources and complex types.
…ng by introducing `inner_resource_or_complex_type`. Update config.json, enhance polymorphic support, and add builder pattern support.
…ntLock` for thread safety, refining `ArrayList` initialization, and adding default constructors to builders and resource classes. Update type-handling annotations and improve polymorphic support.
…mplates. Add hashCode/equals, optional fields, wither methods, and improved polymorphic handling. Enhance ViewModel generation with detailed field/property flags and support for child/parent relationships. Update Maven config for spotless plugin and test dependencies. Add comprehensive `ResourceTest`.
…ce date/time getter support. Update `config.json` mappings and streamline field getter logic using reusable templates.
…lity for serialization control, refine `List.copyOf` logic for optional arrays, and update `ResourceTest` to include nested input serialization.
…oved support for array handling and input validation. Update imports for `Arrays` and adjust `ResourceTest` to refine task input serialization.
…eature. Refactor `config.json` and templates for `wither` integration. Update `ResourceTest` imports and task input handling. Refine Maven configuration to include `maven-source-plugin`. Optimize ViewModel generation with `NamedViewModel` ownership and streamlined primitive handling.
…er()` in `wither` methods for consistency and improved reusability.
…th conditional handling for child elements.
…eration and improve `type` handling in `config.json`.
…n resource classes, streamline `resourceClass` handling in `resource_names.mustache`, and update `config.json` paths for improved resource organization.
…ethods and integrate them into relevant resource and complex type templates.
…removing `wither` methods, introducing `final` modifiers for `toBuilder()` methods, and updating `config.json`. Enhance `ResourceTest` to include extension handling and additional validation.
… by introducing reusable element handling for primitives and adjusting `config.json`. Update `ResourceTest` with new JSON serialization and extension handling. Remove outdated templates and refine field getter logic.
…or description equality, and adjust import order.
…ort for primitive array elements, improve field getter handling, and streamline serialization logic.
…itive` type support, enhancing builder handling, serialization, and array element processing. Update `ResourceTest` to align with new primitive behaviors and add null safety checks for extension methods.
…s` class, adding equality methods for `OffsetDateTime` and lists, enhancing serialization and hash code handling. Update `ResourceTest` for `LocalDateTime` support and improve JSON serialization. Add `jackson-datatype-jsr310` dependency in `pom.xml`.
…h `findFirstCodingBySystem` and `findCodingsBySystem` methods, refine `toBuilder()` handling, and integrate reusable behavior for complex types.
…nsionByURL`, and `findExtensionsByURL` methods final in Mustache Java templates for improved immutability.
….json` and integrating reusable `ToStringHelper` utility in `utils.mustache`. Include feature usage in relevant templates.
…ingHelper`. Update `ResourceTest` with additional `toString` assertions and refine `utils.mustache` helper methods.
…ate spotless plugin in `pom.xml`. Refactor templates to enhance null-safety annotations and streamline field declaration style.
…Enhance `ResourceTest` with additional assertions and update `ResourceName` with utility methods for improved resource referencing.
…`Collectors.joining`, improving code readability and reducing iteration logic.
…a Format in `pom.xml`. Update templates for streamlined annotation usage and add `toReference` method for resource references.
…s, enhance clarity in private methods, and simplify `toString` implementation for improved readability.
… Update `ViewModelFactory` to collect and process resource and complex type dependencies.
…tructure. Update `config.json` paths and add separate `pom.xml` files for `model` and `client-spring` modules. Simplify `sdk-parent` configuration with module-based dependency management.
…mplates. Update parent `pom.xml` to reflect module removal.
@ryukzak
Copy link
Copy Markdown
Contributor

ryukzak commented Nov 14, 2025

Hi @JulianStitz!

I will start to migrate your PR to the https://github.com/atomic-ehr/codegen

@ryukzak
Copy link
Copy Markdown
Contributor

ryukzak commented Nov 19, 2025

@JulianStitz Here is a migrated PR: atomic-ehr/codegen#27

Please, take a look.

@JulianStitz
Copy link
Copy Markdown
Author

Hi @JulianStitz!

I will start to migrate your PR to the https://github.com/atomic-ehr/codegen

Thank you :) i submitted a review to your pr at the atomic repo. let's continue discussion there :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants