Skip to content

Comments

[ballerina-health-tool] Modify template gen to use a single port, single OAS def in aggregate mode#120

Merged
isuruh15 merged 8 commits intoballerina-platform:mainfrom
Sanjana-Attanayake:main
Aug 15, 2025
Merged

[ballerina-health-tool] Modify template gen to use a single port, single OAS def in aggregate mode#120
isuruh15 merged 8 commits intoballerina-platform:mainfrom
Sanjana-Attanayake:main

Conversation

@Sanjana-Attanayake
Copy link
Contributor

Purpose

Related to: Bal FHIR tool should be able to generate FHIR server skeleton

Goals

  1. To generate a single OAS def in aggregated mode of template generation
  2. For the aggregated service to be deployed in a single port using Ballerina Language Interceptor for both FHIR versions.
  3. Bug Fix: Correcting the parse error for short fields containing a colon (:) element.
  4. Bug Fix: Ensure datatype capitalization for content reference elements.

Approach

When a profile is passed to the Ballerina Health Tool, it first sends all the StructureDefinition resources to the codegen-tool-framework. This framework processes them and extracts the necessary context, including OpenAPI Specification (OAS) definitions.

OAS definitions are generated for all resources in the profile, regardless of whether the mode is aggregated or not.

In aggregated mode, the tool combines the definitions of all related resources into a single APIDefinition model. It then breaks this model down into key parts such as:

  • Info
  • Endpoints
  • Resource Types
  • Tags
  • Path Maps
  • Components

Once all required resources are gathered and processed, a new APIDefinition is created for the aggregation. Finally, this complete definition is written to a YAML file.

User stories

Aggregated resources now have a single OAS-Definition File and all the services now work on a single port.

Release note

In template generation mode for aggregated resources it now have a single OAS-Definition File and all the services now work on a single port.

Automation tests

Tested with multiple packages for both FHIR versions R4 and R5 to see whether the generated templates are correct.
Tested with Devant for USCore501 for aggregated mode and USCore501 Patient for microservices deployment.

Security checks

Related PRs

Add FHIR API template aggregation support for monolithic deployments

Test environment

JDK: 21
Ballerina: 2201.12.3
OS: Windows 11 Pro

Learning

Ballerina HTTP Request Interceptor

isuruh15
isuruh15 previously approved these changes Aug 7, 2025
if (DEFAULT_DATA_TYPES.contains(datatypeDefn.getDefinition().getName())
|| "Extension".equals(datatypeDefn.getDefinition().getType())) {
continue;
} else if (datatypeDefn.getDefinition().getStatus().toString().equalsIgnoreCase("draft") &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we swap the values as "draft".equalsIgnoreCase(datatypeDefn.getDefinition().getStatus().toString())

@isuruh15 isuruh15 merged commit a111f9d into ballerina-platform:main Aug 15, 2025
2 checks passed
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.

2 participants