fhir-openapi-translator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/definitions/r4/fhir.schema.json.gz +0 -0
- package/definitions/r4/operation-definitions.json.gz +0 -0
- package/definitions/r4/search-parameters.json.gz +0 -0
- package/definitions/r4/structure-definitions.json.gz +0 -0
- package/definitions/r4b/fhir.schema.json.gz +0 -0
- package/definitions/r4b/operation-definitions.json.gz +0 -0
- package/definitions/r4b/search-parameters.json.gz +0 -0
- package/definitions/r4b/structure-definitions.json.gz +0 -0
- package/definitions/r5/fhir.schema.json.gz +0 -0
- package/definitions/r5/operation-definitions.json.gz +0 -0
- package/definitions/r5/search-parameters.json.gz +0 -0
- package/definitions/r5/structure-definitions.json.gz +0 -0
- package/dist/chunk-G3DCRADV.js +1429 -0
- package/dist/chunk-G3DCRADV.js.map +1 -0
- package/dist/cli.js +170 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +253 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/docs/REFERENCE.md +200 -0
- package/docs/demo.gif +0 -0
- package/package.json +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 fhir-openapi-translator contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# fhir-openapi-translator
|
|
2
|
+
|
|
3
|
+
**Turn any FHIR resource into an OpenAPI spec — and generate typed models in any language.**
|
|
4
|
+
|
|
5
|
+
[](https://github.com/krishgok/fhir-openapi-translator/actions/workflows/ci.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://nodejs.org)
|
|
8
|
+
[](https://hl7.org/fhir)
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
HAPI FHIR and Firely give Java/.NET teams great FHIR models. Everyone else — Go, Rust, Kotlin, PHP, C++, TypeScript — has no equivalent. But every language has an OpenAPI code generator. This tool bridges the gap: give it a resource name and a FHIR version, get back a clean, self-contained OpenAPI document ready for `openapi-generator`.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install fhir-openapi-translator # library + `fhir-oas` CLI
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Node.js ≥ 20. FHIR definitions ship with the package — no network, no server.
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
# One resource, or many
|
|
26
|
+
fhir-oas generate Patient --fhir-version r4 -o patient.yaml
|
|
27
|
+
|
|
28
|
+
# Then generate a client in any language
|
|
29
|
+
npx @openapitools/openapi-generator-cli generate \
|
|
30
|
+
-i patient.yaml -g typescript-fetch -o ./client \
|
|
31
|
+
--additional-properties=modelPropertyNaming=original
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
That's a complete spec — the `Patient` schema, its full dependency closure, the standard REST interactions, and every official search parameter — that any OpenAPI generator turns into typed models and clients.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
# Target OpenAPI 3.1 as JSON (default is 3.0.3 YAML, for widest codegen support)
|
|
40
|
+
fhir-oas generate Patient -f r5 --openapi-version 3.1 --format json -o patient.json
|
|
41
|
+
|
|
42
|
+
# Add the standard operations ($everything, $validate, ...)
|
|
43
|
+
fhir-oas generate Patient -f r4 --operations
|
|
44
|
+
|
|
45
|
+
# Apply an Implementation Guide profile (e.g. US Core)
|
|
46
|
+
fhir-oas generate Patient -f r4 --ig hl7.fhir.us.core@5.0.1 --profile us-core-patient
|
|
47
|
+
|
|
48
|
+
# Match one server's declared surface (reads its /metadata)
|
|
49
|
+
fhir-oas generate -f r4 --capability https://server.example.org/fhir
|
|
50
|
+
|
|
51
|
+
# Merge into an existing spec, preserving comments and key order
|
|
52
|
+
fhir-oas generate Questionnaire -f r4 --merge-into api.yaml
|
|
53
|
+
|
|
54
|
+
# CI drift guard: fail if a committed spec no longer matches generation
|
|
55
|
+
fhir-oas check Patient Observation -f r4 --file api.yaml
|
|
56
|
+
|
|
57
|
+
# List resources for a version, or profiles in an IG package
|
|
58
|
+
fhir-oas list --fhir-version r4b
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { generateOpenApi } from "fhir-openapi-translator";
|
|
63
|
+
const doc = generateOpenApi({ resources: ["Patient"], fhirVersion: "r4" });
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## What it does
|
|
67
|
+
|
|
68
|
+
- **FHIR R4, R4B, R5** → **OpenAPI 3.0.3 or 3.1.0**, YAML or JSON.
|
|
69
|
+
- **Minimal output** — only the resources you ask for and what they reference.
|
|
70
|
+
- **Typed code enums** from required ValueSet bindings, not bare strings.
|
|
71
|
+
- **Custom operations** from the official OperationDefinitions.
|
|
72
|
+
- **Profiles / IGs** — apply US Core-style constraints from any IG package.
|
|
73
|
+
- **CapabilityStatement-driven** — generate exactly what a server supports.
|
|
74
|
+
- **Merge mode & drift guard** — coexist with hand-written specs, catch drift in CI.
|
|
75
|
+
|
|
76
|
+
## Where it fits
|
|
77
|
+
|
|
78
|
+
| | fhir-openapi-translator | HAPI / Firely |
|
|
79
|
+
|---|:---:|:---:|
|
|
80
|
+
| Output | OpenAPI (→ any language) | Java / .NET models |
|
|
81
|
+
| Runtime needed | none (offline CLI) | a running server / SDK |
|
|
82
|
+
| US Core / IG profiles | ✅ | ✅ |
|
|
83
|
+
| Per-resource, codegen-tuned specs | ✅ | — |
|
|
84
|
+
|
|
85
|
+
**Complements a FHIR SDK, doesn't replace it.** Keep HAPI or Firely for server-side models and conformance — this produces the OpenAPI contract around them: for consumers in any language, and for the tooling you already run (gateways, mock servers, contract tests).
|
|
86
|
+
|
|
87
|
+
## Docs
|
|
88
|
+
|
|
89
|
+
- **[Reference](docs/REFERENCE.md)** — full CLI, library API, codegen recipes, limitations
|
|
90
|
+
- **[Examples](examples/)** — worked walkthroughs for each feature
|
|
91
|
+
|
|
92
|
+
## Legal & attribution
|
|
93
|
+
|
|
94
|
+
- **FHIR®** is a registered trademark of [Health Level Seven International (HL7®)](https://www.hl7.org). This project is **not affiliated with, endorsed by, or sponsored by HL7**; the name is used only to describe what the tool consumes.
|
|
95
|
+
- Bundled definitions derive from the official HL7 FHIR packages (the FHIR specification is published under [CC0 / public domain](https://build.fhir.org/license.html)) and [`@medplum/definitions`](https://www.npmjs.com/package/@medplum/definitions) (Apache-2.0). IG packages you pass to `--ig` are licensed by their own publishers.
|
|
96
|
+
- Generated specs describe the FHIR data model but do **not** guarantee FHIR conformance — validate payloads with a real FHIR validator. See [limitations](docs/REFERENCE.md#assumptions-and-known-limitations).
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
[MIT](LICENSE)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|