GithubHelp home page GithubHelp logo

athiththan11 / fhir-to-swagger Goto Github PK

View Code? Open in Web Editor NEW
19.0 5.0 1.0 568 KB

FHIR R4 to Swagger Converter Tool

License: MIT License

JavaScript 100.00%
fhir r4 swagger swagger-2 hl7 nodejs swagger-definitions fhir-r4

fhir-to-swagger's Introduction

FHIR to Swagger

A command line tool to convert FHIR R4 (4.0 Schema) to Swagger definitions.

[:construction: Work-In-Progress (Part-Timed) & Feature Requests are Welcomed | Check #Under Development]

This tool uses the official specs and schemas provided by HL7 to generate swagger definitions. You can find the specs and schemas inside the /schemas directory.

Also you can download the specs from here

Build, Install & Run

Build & Install

Clone or download the project and execute the following command (from the root directory) to install relevant dependencies

Use NodeJS 11.14.0v for error free instalation and execution

npm install

Run

You can run the tool by following either methods

Method 01

Execute the following command (from the root Directory) to link the tool with shell

npm link

and use the following command pattern to execute the tool

fhir-to-swagger [Resource_Name] [--combine] --output [Output_Directory]

for example:

  1. Execute the following command to generate the swagger definition for Coverage resource. This will generate the swagger definition inside the current working directory

    fhir-to-swagger Coverage --output .
  2. Execute the following command to generate the swagger definition for Coverage resource with passed basePath.

    fhir-to-swagger Coverage --base fhir-api --output .
  3. Execute the following command to generate the swagger definition for Coverage, Claim & ClaimResponse resources. This will generate the swagger definitions inside the current working directory

    fhir-to-swagger Coverage Claim ClaimResponse --output .
  4. Execute the following command to generate a combined swagger definition for Coverage, Claim & ClaimResponse resources. This will generate a combined swagger definitions inside the current working directory with the name combined-swagger--output.json

    fhir-to-swagger Coverage Claim ClaimResponse --combine --output .
  5. Execute the folloing command to generate a combined swagger definition for Coverage, Claim & ClaimResponse resources with custom version, basePath, host.

    fhir-to-swagger Coverage Claim ClaimResponse --combine --title Combined--FHIR-API --host hapi.fhir.org --combined-base fhir --swagger-version 2.0.0 --output .
  6. Execute the following command to generate swagger definition for Coverage resource with only DELETE operations

    fhir-to-swagger Coverage --verbs put delete --output .
  7. Execute the following command to generate a combined swagger definition for Coverage and Claim resources with GET, PUT and DELETE operations

    fhir-to-swagger Coverage Claim --combine --verbs coverage.get claim.put delete --output .

Method 02

Execute the following command from the root directory

node server.js Coverage

The above command will generate the swagger-definitions and saves it inside the /outputs folder of the tool

Commands

Base Path Configurations

The Fhir-to-Swagger tool now supports the following three arguments to define basePath for individual Swagger definitions as well as for the combined swagger definitions

  • --base: The basePath of the generated Swagger Definition of a single Resource
  • --default-base: A default basePath will be used (ex: '/coverage-api') for the generated Swagger Definitions
  • --combined-base: The basePath of the combined Swagger Definition

Under Development

Tool

Folder Structure

    -
    |- bin
    |    |- fhir-to-swagger
    |- schemas
    |    |- fhir.schema.json
    |    |- search-parameters.json
    |- utils
    |    |- utils.js
    |- server.js

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 request 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 request 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 agains traverse and extracts all related search parameters for them and appends them inside the parameters section.

NOTE: The iteration and extraction is done only for one iteration of defined reference type Resource.

Searh Modifiers

The tool and the swagger doesn't support search modifiers of FHIR R4 resources and operations.

fhir-to-swagger's People

Contributors

athiththan11 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

nirmal070125

fhir-to-swagger's Issues

Summary and description

"/fhir/Claim/{id}/_history/{vid}": { "get": { "tags": [ "Claim" ], "summary": "Get claim history", "description": "Get claim history by providing transaction id and version"

List of produces

"produces": [ "text/plain", "application/json", "application/fhir+json", "application/json+fhir", "text/json", "application/xml", "application/fhir+xml", "application/xml+fhir", "text/xml", "text/xml+fhir", "application/octet-stream" ],

Generate multiple resources.

Is there any way to generate multiple resources by specifying multiple types.

For example:
fhir-to-swagger Claim Coverage ClaimResponse etc.

image

Tile, base url and api prefix

Be able to change the following.

fhir-to-swagger Claim Coverage ClaimResponse --combine --title Claim-Coverage-ClaimResponse--FHIRAPI --url hapi.fhir.org --prefix fhir --version v1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.