Skip to content

Commit f7b66f5

Browse files
authored
Merge pull request #574 from honey-insurance/resolve-ref2
expand README to include information about external reference support
2 parents 224e8b0 + 8752aba commit f7b66f5

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
- Supports JSON and YAML files for input
2121
- Supports generation through CLI, Node.js and NPX
2222
- Supports tsc and @babel/plugin-transform-typescript
23-
23+
- Supports external references using [`json-schema-ref-parser`](https://github.com/APIDevTools/json-schema-ref-parser/)
2424

2525
## Install
2626

@@ -392,6 +392,32 @@ const getToken = async () => {
392392
OpenAPI.TOKEN = getToken;
393393
```
394394

395+
### References
396+
397+
Local references to schema definitions (those beginning with `#/definitions/schemas/`) will
398+
be converted to type references to the equivalent, generated top-level type.
399+
400+
The OpenAPI generator also supports external references, which allows you to break
401+
down your openapi.yml into multiple sub-files, or incorporate third-party schemas
402+
as part of your types to ensure everything is able to be TypeScript generated.
403+
404+
External references may be:
405+
* *relative references* - references to other files at the same location e.g.
406+
`{ $ref: 'schemas/customer.yml' }`
407+
* *remote references* - fully qualified references to another remote location
408+
e.g. `{ $ref: 'https://myexampledomain.com/schemas/customer_schema.yml' }`
409+
410+
For remote references, both files (when the file is on the current filesystem)
411+
and http(s) URLs are supported.
412+
413+
External references may also contain internal paths in the external schema (e.g.
414+
`schemas/collection.yml#/definitions/schemas/Customer`) and back-references to
415+
the base openapi file or between files (so that you can reference another
416+
schema in the main file as a type of an object or array property, for example).
417+
418+
At start-up, an OpenAPI or Swagger file with external references will be "bundled",
419+
so that all external references and back-references will be resolved (but local
420+
references preserved).
395421

396422
### Compare to other generators
397423
Depending on which swagger generator you use, you will see different output.

0 commit comments

Comments
 (0)