|
20 | 20 | - Supports JSON and YAML files for input
|
21 | 21 | - Supports generation through CLI, Node.js and NPX
|
22 | 22 | - 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/) |
24 | 24 |
|
25 | 25 | ## Install
|
26 | 26 |
|
@@ -392,6 +392,32 @@ const getToken = async () => {
|
392 | 392 | OpenAPI.TOKEN = getToken;
|
393 | 393 | ```
|
394 | 394 |
|
| 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). |
395 | 421 |
|
396 | 422 | ### Compare to other generators
|
397 | 423 | Depending on which swagger generator you use, you will see different output.
|
|
0 commit comments