FHIR To Swagger
A command-line tool to generate (convert) FHIR R4 (4.0 Schema) to Swagger definitions.
Usage
The tool uses an internally stored FHIR Schema to generate the swagger definitions for requested resources to comply with the original specifications.
NOTE: This tool is not to generate swagger definitions from test servers or from any of the FHIR R4 servers. This tool generates a working swagger definition using the FHIR specs which are stored internally with the tool. The schemas and JSON specs used by the tool are downloaded from the HL7 FHIR site
The tool traverse through the fhir.schema.json
file to identify the requested resource and extracts it and other related attributes and models from the spec to generate the definitions. The search-parameters.json
file is used to identify the common search parameters and Resource specific search query parameters. The tool extracts Resource related search query parameters using the search-parameters.json
schema.
NOTE: Any changes to the above-mentioned schema files can result in fault swagger definitions.
Moreover, the tool generates all applicable resource paths for the requested Resource.
For example: If Coverage resource has been requested using the below command
fhir-to-swagger Coverage --output .
then, the generated swagger definition (coverage-output.json
) will include the following paths ...
/Coverage
: GET, POST/Coverage/{id}
: GET, PUT, DELETE/Coverage/_history
: GET/Coverage/{id}/_history
: GET/Coverage/{id}/_history/{vid}
: GET
Limitations
The tool uses the search-parameters.json
schema to identify and extract search query parameters related to a Resource as well as common parameters.
- Resource Chaining
- Modifiers
Resource Chaining
FHIR R4 supports advanced search operation called "Resource Chaining", but swagger doesn't have any support to define them.
As a workaround, the tool will traverse through the search-parameters.json
schema and extracts the query parameters which are having their type as 'reference', and based on the given reference Resource, it again traverse and extracts all related search parameters for them and appends them inside the parameters section.
NOTE: The iteration and extraction are done only for one iteration of defined reference type Resource.
Searh Modifiers
The tool and the swagger don't support search modifiers of FHIR R4 resources and operations.