docusaurus-plugin-openapi-docs 2.2.0 → 2.2.2
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/README.md +85 -60
- package/lib/index.js +9 -0
- package/lib/markdown/createSchema.js +27 -21
- package/lib/markdown/createSchema.test.js +247 -29
- package/lib/markdown/createStatusCodes.js +12 -8
- package/lib/markdown/index.js +1 -1
- package/lib/openapi/createRequestExample.js +2 -2
- package/lib/openapi/createResponseExample.js +2 -2
- package/package.json +2 -2
- package/src/index.ts +12 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +146 -1
- package/src/markdown/createSchema.test.ts +291 -33
- package/src/markdown/createSchema.ts +60 -50
- package/src/markdown/createStatusCodes.ts +12 -8
- package/src/markdown/index.ts +1 -1
- package/src/openapi/createRequestExample.ts +2 -2
- package/src/openapi/createResponseExample.ts +2 -2
package/README.md
CHANGED
|
@@ -6,23 +6,33 @@
|
|
|
6
6
|
|
|
7
7
|
<div align="center">
|
|
8
8
|
|
|
9
|
-
OpenAPI plugin for generating API reference docs in Docusaurus
|
|
9
|
+
OpenAPI plugin for generating API reference docs in Docusaurus v3.
|
|
10
|
+
|
|
11
|
+
<img src="https://img.shields.io/badge/dynamic/json?style=for-the-badge&logo=meta&color=blueviolet&label=Docusaurus&query=dependencies%5B%22%40docusaurus%2Fcore%22%5D&url=https%3A%2F%2Fraw.githubusercontent.com%2FPaloAltoNetworks%2Fdocusaurus-openapi-docs%2Fmain%2Fdemo%2Fpackage.json" />
|
|
12
|
+
<br/><br/>
|
|
13
|
+
|
|
14
|
+
[](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/HEAD/LICENSE) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs)
|
|
15
|
+
<br/>
|
|
16
|
+
[](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/actions/workflows/validate.yaml) [](https://github.com/prettier/prettier) [](https://www.cypress.io/) [](https://github.com/facebook/jest) [](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/HEAD/CONTRIBUTING.md#pull-requests)
|
|
17
|
+
<br />
|
|
10
18
|
|
|
11
19
|
</div>
|
|
12
20
|
|
|
13
21
|
<p align="center">
|
|
14
22
|
|
|
15
|
-
<img
|
|
23
|
+
<img src="https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/assets/9343811/d4e75f15-7daf-48d2-a772-a0c49aa25d26" width="900" />
|
|
16
24
|
|
|
17
25
|
</p>
|
|
18
26
|
|
|
27
|
+
---
|
|
28
|
+
|
|
19
29
|
## Overview
|
|
20
30
|
|
|
21
|
-
The `docusaurus-plugin-openapi-docs` package extends the Docusaurus CLI with commands for generating MDX using the OpenAPI specification as the source. The resulting MDX is fully compatible with [plugin-content-docs](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs) and can be used to render beautiful reference API docs
|
|
31
|
+
The `docusaurus-plugin-openapi-docs` package extends the Docusaurus CLI with commands for generating MDX using the OpenAPI specification as the source. The resulting MDX is fully compatible with [plugin-content-docs](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs) and can be used to render beautiful reference API docs when combined with the `docusaurus-theme-openapi-docs` theme.
|
|
22
32
|
|
|
23
33
|
Key Features:
|
|
24
34
|
|
|
25
|
-
- **Compatible:** Works with Swagger 2.0 and OpenAPI 3.
|
|
35
|
+
- **Compatible:** Works with Swagger 2.0 and OpenAPI 3.x.
|
|
26
36
|
- **Fast:** Convert large OpenAPI specs into MDX docs in seconds. 🔥
|
|
27
37
|
- **Stylish:** Based on the same [Infima styling framework](https://infima.dev/) that powers the Docusaurus UI.
|
|
28
38
|
- **Flexible:** Supports single, multi and _even micro_ OpenAPI specs.
|
|
@@ -31,13 +41,13 @@ Key Features:
|
|
|
31
41
|
|
|
32
42
|
| Docusaurus OpenAPI Docs | Docusaurus |
|
|
33
43
|
| ----------------------- | --------------- |
|
|
34
|
-
| 3.0.
|
|
35
|
-
| 2.
|
|
44
|
+
| 3.0.1 (current) | `3.0.1 - 3.4.0` |
|
|
45
|
+
| 2.2.1 (legacy) | `2.4.1 - 2.4.3` |
|
|
36
46
|
| 1.7.3 (legacy) | `2.0.1 - 2.2.0` |
|
|
37
47
|
|
|
38
48
|
## Bootstrapping from Template (new Docusaurus site)
|
|
39
49
|
|
|
40
|
-
Run the following to bootstrap a Docsaurus
|
|
50
|
+
Run the following to bootstrap a Docsaurus v3 site (classic theme) with `docusaurus-openapi-docs`:
|
|
41
51
|
|
|
42
52
|
```bash
|
|
43
53
|
npx create-docusaurus@2.4.3 my-website --package-manager yarn
|
|
@@ -51,57 +61,59 @@ Template Repository URL:
|
|
|
51
61
|
https://github.com/PaloAltoNetworks/docusaurus-template-openapi-docs.git
|
|
52
62
|
```
|
|
53
63
|
|
|
54
|
-
> When asked how the template repo should be cloned choose "copy"
|
|
64
|
+
> When asked how the template repo should be cloned choose "copy".
|
|
55
65
|
|
|
56
66
|
```bash
|
|
57
67
|
cd my-website
|
|
58
68
|
yarn start
|
|
59
69
|
```
|
|
60
70
|
|
|
71
|
+
If all goes well, you should be greeted by a brand new Docusaurus site that includes API reference docs for the ubiquitous Petstore API!
|
|
72
|
+
|
|
61
73
|
## Installation (existing Docusaurus site)
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
> Both the plugin and theme are currently designed to pair with a specific Docusaurus release. The Docusaurus badge in the `README.md` and at the top of this page will always reflect the current compatible versions.
|
|
76
|
+
|
|
77
|
+
### Plugin
|
|
64
78
|
|
|
65
79
|
```bash
|
|
66
80
|
yarn add docusaurus-plugin-openapi-docs
|
|
67
81
|
```
|
|
68
82
|
|
|
69
|
-
Theme
|
|
83
|
+
### Theme
|
|
70
84
|
|
|
71
85
|
```bash
|
|
72
86
|
yarn add docusaurus-theme-openapi-docs
|
|
73
87
|
```
|
|
74
88
|
|
|
75
|
-
## Configuring `docusaurus.config.
|
|
89
|
+
## Configuring `docusaurus.config.ts` (Plugin and theme usage)
|
|
76
90
|
|
|
77
|
-
Here is an example of properly configuring `docusaurus.config.
|
|
91
|
+
Here is an example of properly configuring `docusaurus.config.ts` for `docusaurus-plugin-openapi-docs` and `docusaurus-theme-openapi-docs` usage.
|
|
78
92
|
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
> Note: Instructions may differ slightly for sites that haven't migrated to typescript.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// docusaurus.config.ts
|
|
97
|
+
// note that parts of the complete config were left out for brevity
|
|
98
|
+
import type * as Preset from "@docusaurus/preset-classic";
|
|
99
|
+
import type { Config } from "@docusaurus/types";
|
|
100
|
+
import type * as Plugin from "@docusaurus/types/src/plugin";
|
|
101
|
+
import type * as OpenApiPlugin from "docusaurus-plugin-openapi-docs";
|
|
81
102
|
|
|
82
103
|
{
|
|
83
104
|
presets: [
|
|
84
105
|
[
|
|
85
106
|
"classic",
|
|
86
|
-
|
|
87
|
-
({
|
|
107
|
+
{
|
|
88
108
|
docs: {
|
|
89
|
-
sidebarPath:
|
|
90
|
-
|
|
91
|
-
"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
|
|
92
|
-
docLayoutComponent: "@theme/DocPage",
|
|
93
|
-
docItemComponent: "@theme/ApiItem" // derived from docusaurus-theme-openapi-docs
|
|
94
|
-
},
|
|
95
|
-
blog: {
|
|
96
|
-
showReadingTime: true,
|
|
97
|
-
editUrl:
|
|
98
|
-
"https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/"
|
|
109
|
+
sidebarPath: "./sidebars.ts",
|
|
110
|
+
docItemComponent: "@theme/ApiItem", // Derived from docusaurus-theme-openapi
|
|
99
111
|
},
|
|
100
112
|
theme: {
|
|
101
|
-
customCss:
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
]
|
|
113
|
+
customCss: "./src/css/custom.css",
|
|
114
|
+
},
|
|
115
|
+
} satisfies Preset.Options,
|
|
116
|
+
],
|
|
105
117
|
],
|
|
106
118
|
|
|
107
119
|
plugins: [
|
|
@@ -109,19 +121,15 @@ Here is an example of properly configuring `docusaurus.config.js` file for `docu
|
|
|
109
121
|
'docusaurus-plugin-openapi-docs',
|
|
110
122
|
{
|
|
111
123
|
id: "api", // plugin id
|
|
112
|
-
docsPluginId: "classic", //
|
|
124
|
+
docsPluginId: "classic", // configured for preset-classic
|
|
113
125
|
config: {
|
|
114
|
-
petstore: {
|
|
115
|
-
specPath: "examples/petstore.yaml",
|
|
116
|
-
outputDir: "
|
|
117
|
-
sidebarOptions: {
|
|
118
|
-
groupPathsBy: "tag",
|
|
126
|
+
petstore: {
|
|
127
|
+
specPath: "examples/petstore.yaml",
|
|
128
|
+
outputDir: "docs/petstore",
|
|
129
|
+
sidebarOptions: {
|
|
130
|
+
groupPathsBy: "tag",
|
|
119
131
|
},
|
|
120
|
-
},
|
|
121
|
-
burgers: {
|
|
122
|
-
specPath: "examples/food/burgers/openapi.yaml",
|
|
123
|
-
outputDir: "api/food/burgers",
|
|
124
|
-
}
|
|
132
|
+
} satisfies OpenApiPlugin.Options,
|
|
125
133
|
}
|
|
126
134
|
},
|
|
127
135
|
]
|
|
@@ -136,10 +144,11 @@ Here is an example of properly configuring `docusaurus.config.js` file for `docu
|
|
|
136
144
|
|
|
137
145
|
The `docusaurus-plugin-openapi-docs` plugin can be configured with the following options:
|
|
138
146
|
|
|
139
|
-
| Name | Type | Default
|
|
140
|
-
| -------------- | -------- |
|
|
141
|
-
| `id` | `string` | `null`
|
|
142
|
-
| `
|
|
147
|
+
| Name | Type | Default | Description |
|
|
148
|
+
| -------------- | -------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
149
|
+
| `id` | `string` | `null` | A unique plugin ID. |
|
|
150
|
+
| `docsPlugin` | `string` | `@docusaurus/plugin-content-docs` | The plugin used to render the OpenAPI docs (ignored if the plugin instance referenced by `docsPluginId` is a `preset`). |
|
|
151
|
+
| `docsPluginId` | `string` | `null` | The plugin ID associated with the `preset` or configured `docsPlugin` instance used to render the OpenAPI docs (e.g. "your-plugin-id", "classic", "default"). |
|
|
143
152
|
|
|
144
153
|
### config
|
|
145
154
|
|
|
@@ -148,7 +157,7 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
|
|
|
148
157
|
| Name | Type | Default | Description |
|
|
149
158
|
| -------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
150
159
|
| `specPath` | `string` | `null` | Designated URL or path to the source of an OpenAPI specification file or directory of multiple OpenAPI specification files. |
|
|
151
|
-
| `ouputDir` | `string` | `null` | Desired output path for generated MDX files.
|
|
160
|
+
| `ouputDir` | `string` | `null` | Desired output path for generated MDX and sidebar files. |
|
|
152
161
|
| `proxy` | `string` | `null` | _Optional:_ Proxy URL to prepend to base URL when performing API requests from browser. |
|
|
153
162
|
| `template` | `string` | `null` | _Optional:_ Customize MDX content with a desired template. |
|
|
154
163
|
| `downloadUrl` | `string` | `null` | _Optional:_ Designated URL for downloading OpenAPI specification. (requires `info` section/doc) |
|
|
@@ -166,7 +175,7 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
|
|
|
166
175
|
|
|
167
176
|
| Name | Type | Default | Description |
|
|
168
177
|
| -------------------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
169
|
-
| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag`.
|
|
178
|
+
| `groupPathsBy` | `string` | `null` | Organize and group sidebar slice by specified option. Note: Currently, `groupPathsBy` only contains support for grouping by `tag` and `tagGroup`. |
|
|
170
179
|
| `categoryLinkSource` | `string` | `null` | Defines what source to use for rendering category link pages when grouping paths by tag. <br/><br/>The supported options are as follows: <br/><br/> `tag`: Sets the category link config type to `generated-index` and uses the tag description as the link config description. <br/><br/>`info`: Sets the category link config type to `doc` and renders the `info` section as the category link (recommended only for multi/micro-spec scenarios). <br/><br/>`none`: Does not create pages for categories, only groups that can be expanded/collapsed. |
|
|
171
180
|
| `sidebarCollapsible` | `boolean` | `true` | Whether sidebar categories are collapsible by default. |
|
|
172
181
|
| `sidebarCollapsed` | `boolean` | `true` | Whether sidebar categories are collapsed by default. |
|
|
@@ -189,11 +198,12 @@ The `docusaurus-plugin-openapi-docs` plugin can be configured with the following
|
|
|
189
198
|
|
|
190
199
|
`markdownGenerators` can be configured with the following options:
|
|
191
200
|
|
|
192
|
-
| Name
|
|
193
|
-
|
|
|
194
|
-
| `createApiPageMD`
|
|
195
|
-
| `createInfoPageMD`
|
|
196
|
-
| `createTagPageMD`
|
|
201
|
+
| Name | Type | Default | Description |
|
|
202
|
+
| -------------------- | ---------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
203
|
+
| `createApiPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for API pages.<br/><br/>**Function type:** `(pageData: ApiPageMetadata) => string` |
|
|
204
|
+
| `createInfoPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for info pages.<br/><br/>**Function type:** `(pageData: InfoPageMetadata) => string` |
|
|
205
|
+
| `createTagPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for tag pages.<br/><br/>**Function type:** `(pageData: TagPageMetadata) => string` |
|
|
206
|
+
| `createSchemaPageMD` | `function` | `null` | _Optional:_ Returns a string of the raw markdown body for schema pages.<br/><br/>**Function type:** `(pageData: SchemaPageMetadata) => string` |
|
|
197
207
|
|
|
198
208
|
## CLI Usage
|
|
199
209
|
|
|
@@ -214,11 +224,12 @@ Commands:
|
|
|
214
224
|
write-translations [options] [siteDir] Extract required translations of your site.
|
|
215
225
|
write-heading-ids [options] [siteDir] [files...] Generate heading ids in Markdown content.
|
|
216
226
|
docs:version <version> Tag a new docs version
|
|
217
|
-
gen-api-docs <id>
|
|
218
|
-
gen-api-docs:version <id:version>
|
|
219
|
-
clean-api-docs <id> Clears the generated OpenAPI docs MDX files and sidebar.js (if enabled).
|
|
220
|
-
clean-api-docs:version <id:version> Clears the versioned, generated OpenAPI docs MDX files, versions.json and sidebar.js (if
|
|
227
|
+
gen-api-docs [options] <id> Generates OpenAPI docs in MDX file format and sidebar.ts (if enabled).
|
|
228
|
+
gen-api-docs:version [options] <id:version> Generates versioned OpenAPI docs in MDX file format, versions.js and sidebar.ts (if
|
|
221
229
|
enabled).
|
|
230
|
+
clean-api-docs [options] <id> Clears the generated OpenAPI docs MDX files and sidebar.ts (if enabled).
|
|
231
|
+
clean-api-docs:version [options] <id:version> Clears the versioned, generated OpenAPI docs MDX files, versions.json and sidebar.ts
|
|
232
|
+
(if enabled)
|
|
222
233
|
```
|
|
223
234
|
|
|
224
235
|
### Generating OpenAPI Docs
|
|
@@ -240,10 +251,10 @@ yarn docusaurus gen-api-docs <id>
|
|
|
240
251
|
Example:
|
|
241
252
|
|
|
242
253
|
```bash
|
|
243
|
-
yarn docusaurus gen-api-docs
|
|
254
|
+
yarn docusaurus gen-api-docs petstore
|
|
244
255
|
```
|
|
245
256
|
|
|
246
|
-
> The example above will only generate API docs relative to `
|
|
257
|
+
> The example above will only generate API docs relative to `petstore`.
|
|
247
258
|
|
|
248
259
|
### Cleaning API Docs
|
|
249
260
|
|
|
@@ -262,7 +273,7 @@ yarn docusaurus clean-api-docs <id>
|
|
|
262
273
|
Example:
|
|
263
274
|
|
|
264
275
|
```bash
|
|
265
|
-
yarn docusaurus clean-api-docs
|
|
276
|
+
yarn docusaurus clean-api-docs petstore
|
|
266
277
|
```
|
|
267
278
|
|
|
268
279
|
> The example above will remove all API docs relative to `burgers`.
|
|
@@ -299,6 +310,20 @@ yarn build-packages
|
|
|
299
310
|
yarn watch:demo
|
|
300
311
|
```
|
|
301
312
|
|
|
313
|
+
## Credits
|
|
314
|
+
|
|
315
|
+
Special thanks to @bourdakos1 (Nick Bourdakos), the author of [docusaurus-openapi](https://github.com/cloud-annotations/docusaurus-openapi), which this project is heavily based on.
|
|
316
|
+
|
|
317
|
+
For more insight into why we decided to completely fork see [#47](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/pull/47)
|
|
318
|
+
|
|
319
|
+
## Contributors
|
|
320
|
+
|
|
321
|
+
<a href="https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/graphs/contributors">
|
|
322
|
+
<img src="https://contrib.rocks/image?repo=PaloAltoNetworks/docusaurus-openapi-docs" />
|
|
323
|
+
</a>
|
|
324
|
+
|
|
302
325
|
## Support
|
|
303
326
|
|
|
304
|
-
|
|
327
|
+
See [SUPPORT.md](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/SUPPORT.md) for our support agreement and guidelines.
|
|
328
|
+
|
|
329
|
+
If you believe you found a bug or have an idea you'd like to suggest you may [report an issue](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/new/choose) or [start a discussion](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/discussions/new/choose).
|
package/lib/index.js
CHANGED
|
@@ -375,6 +375,15 @@ custom_edit_url: null
|
|
|
375
375
|
downloadUrl: metadata.downloadUrl,
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
|
+
if (!fs_1.default.existsSync(outputDir)) {
|
|
379
|
+
try {
|
|
380
|
+
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
381
|
+
console.log(chalk_1.default.green(`Successfully created "${outputDir}"`));
|
|
382
|
+
}
|
|
383
|
+
catch (err) {
|
|
384
|
+
console.error(chalk_1.default.red(`Failed to create "${outputDir}"`), chalk_1.default.yellow(err));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
378
387
|
const versionsJson = JSON.stringify(versionsArray, null, 2);
|
|
379
388
|
try {
|
|
380
389
|
fs_1.default.writeFileSync(`${outputDir}/versions.json`, versionsJson, "utf8");
|
|
@@ -67,6 +67,12 @@ function createAnyOneOf(schema) {
|
|
|
67
67
|
? anyOneSchema.title
|
|
68
68
|
: `MOD${index + 1}`;
|
|
69
69
|
const anyOneChildren = [];
|
|
70
|
+
if (anyOneSchema.type === "object" &&
|
|
71
|
+
!anyOneSchema.properties &&
|
|
72
|
+
!anyOneSchema.allOf &&
|
|
73
|
+
!anyOneSchema.items) {
|
|
74
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
75
|
+
}
|
|
70
76
|
if (anyOneSchema.properties !== undefined) {
|
|
71
77
|
anyOneChildren.push(createProperties(anyOneSchema));
|
|
72
78
|
delete anyOneSchema.properties;
|
|
@@ -510,6 +516,19 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
510
516
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
511
517
|
return createAnyOneOfProperty(name, schemaName, schema, required, schema.nullable);
|
|
512
518
|
}
|
|
519
|
+
if (schema.properties !== undefined) {
|
|
520
|
+
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
521
|
+
}
|
|
522
|
+
if (schema.additionalProperties !== undefined) {
|
|
523
|
+
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
524
|
+
}
|
|
525
|
+
// array of objects
|
|
526
|
+
if (((_a = schema.items) === null || _a === void 0 ? void 0 : _a.properties) !== undefined) {
|
|
527
|
+
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
528
|
+
}
|
|
529
|
+
if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.anyOf) !== undefined || ((_c = schema.items) === null || _c === void 0 ? void 0 : _c.oneOf) !== undefined) {
|
|
530
|
+
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
531
|
+
}
|
|
513
532
|
if (schema.allOf !== undefined) {
|
|
514
533
|
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
515
534
|
if (SCHEMA_TYPE === "request") {
|
|
@@ -534,7 +553,7 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
534
553
|
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required, schema.nullable);
|
|
535
554
|
}
|
|
536
555
|
// array of objects
|
|
537
|
-
if (((
|
|
556
|
+
if (((_d = mergedSchemas.items) === null || _d === void 0 ? void 0 : _d.properties) !== undefined) {
|
|
538
557
|
return createDetailsNode(name, mergedSchemaName, mergedSchemas, required, schema.nullable);
|
|
539
558
|
}
|
|
540
559
|
return (0, utils_1.create)("SchemaItem", {
|
|
@@ -546,19 +565,6 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
546
565
|
schema: mergedSchemas,
|
|
547
566
|
});
|
|
548
567
|
}
|
|
549
|
-
if (schema.properties !== undefined) {
|
|
550
|
-
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
551
|
-
}
|
|
552
|
-
if (schema.additionalProperties !== undefined) {
|
|
553
|
-
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
554
|
-
}
|
|
555
|
-
// array of objects
|
|
556
|
-
if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.properties) !== undefined) {
|
|
557
|
-
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
558
|
-
}
|
|
559
|
-
if (((_c = schema.items) === null || _c === void 0 ? void 0 : _c.anyOf) !== undefined || ((_d = schema.items) === null || _d === void 0 ? void 0 : _d.oneOf) !== undefined) {
|
|
560
|
-
return createDetailsNode(name, schemaName, schema, required, schema.nullable);
|
|
561
|
-
}
|
|
562
568
|
// primitives and array of non-objects
|
|
563
569
|
return (0, utils_1.create)("SchemaItem", {
|
|
564
570
|
collapsible: false,
|
|
@@ -591,13 +597,6 @@ function createNodes(schema, schemaType) {
|
|
|
591
597
|
if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
|
|
592
598
|
nodes.push(createAnyOneOf(schema));
|
|
593
599
|
}
|
|
594
|
-
if (schema.allOf !== undefined) {
|
|
595
|
-
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
596
|
-
// allOf seems to always result in properties
|
|
597
|
-
if (mergedSchemas.properties !== undefined) {
|
|
598
|
-
nodes.push(createProperties(mergedSchemas));
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
600
|
if (schema.properties !== undefined) {
|
|
602
601
|
nodes.push(createProperties(schema));
|
|
603
602
|
}
|
|
@@ -608,6 +607,13 @@ function createNodes(schema, schemaType) {
|
|
|
608
607
|
if (schema.items !== undefined) {
|
|
609
608
|
nodes.push(createItems(schema));
|
|
610
609
|
}
|
|
610
|
+
if (schema.allOf !== undefined) {
|
|
611
|
+
const { mergedSchemas } = mergeAllOf(schema.allOf);
|
|
612
|
+
// allOf seems to always result in properties
|
|
613
|
+
if (mergedSchemas.properties !== undefined) {
|
|
614
|
+
nodes.push(createProperties(mergedSchemas));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
611
617
|
if (nodes.length && nodes.length > 0) {
|
|
612
618
|
return nodes.filter(Boolean).flat();
|
|
613
619
|
}
|