docusaurus-plugin-openapi-docs 1.4.4 → 1.4.6
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/lib/markdown/createRequestSchema.js +21 -13
- package/lib/markdown/createResponseSchema.js +21 -13
- package/lib/openapi/createRequestExample.js +3 -0
- package/lib/openapi/createResponseExample.js +3 -0
- package/lib/types.d.ts +1 -0
- package/package.json +2 -2
- package/src/markdown/createRequestSchema.ts +16 -8
- package/src/markdown/createResponseSchema.ts +16 -8
- package/src/openapi/createRequestExample.ts +4 -0
- package/src/openapi/createResponseExample.ts +4 -0
- package/src/types.ts +1 -0
|
@@ -92,14 +92,16 @@ function createAnyOneOf(schema) {
|
|
|
92
92
|
}
|
|
93
93
|
function createProperties(schema) {
|
|
94
94
|
const discriminator = schema.discriminator;
|
|
95
|
-
return Object.entries(schema.properties).map(([key, val]) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
return Object.entries(schema.properties).map(([key, val]) => {
|
|
96
|
+
return createEdges({
|
|
97
|
+
name: key,
|
|
98
|
+
schema: val,
|
|
99
|
+
required: Array.isArray(schema.required)
|
|
100
|
+
? schema.required.includes(key)
|
|
101
|
+
: false,
|
|
102
|
+
discriminator,
|
|
103
|
+
});
|
|
104
|
+
});
|
|
103
105
|
}
|
|
104
106
|
function createAdditionalProperties(schema) {
|
|
105
107
|
// TODO?:
|
|
@@ -214,10 +216,13 @@ function createItems(schema) {
|
|
|
214
216
|
if (mergedSchemas.oneOf !== undefined ||
|
|
215
217
|
mergedSchemas.anyOf !== undefined) {
|
|
216
218
|
return (0, utils_1.create)("div", {
|
|
217
|
-
children: [
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
children: [createAnyOneOf(mergedSchemas)],
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
// Handles properties
|
|
223
|
+
if (mergedSchemas.properties !== undefined) {
|
|
224
|
+
return (0, utils_1.create)("div", {
|
|
225
|
+
children: [createProperties(mergedSchemas)],
|
|
221
226
|
});
|
|
222
227
|
}
|
|
223
228
|
}
|
|
@@ -443,7 +448,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
443
448
|
* Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
|
|
444
449
|
*/
|
|
445
450
|
function createEdges({ name, schema, required, discriminator, }) {
|
|
446
|
-
var _a, _b;
|
|
451
|
+
var _a, _b, _c, _d;
|
|
447
452
|
const schemaName = (0, schema_1.getSchemaName)(schema);
|
|
448
453
|
if (discriminator !== undefined && discriminator.propertyName === name) {
|
|
449
454
|
return createPropertyDiscriminator(name, "string", schema, discriminator, required);
|
|
@@ -491,6 +496,9 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
491
496
|
if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.properties) !== undefined) {
|
|
492
497
|
return createDetailsNode(name, schemaName, schema, required);
|
|
493
498
|
}
|
|
499
|
+
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) {
|
|
500
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
501
|
+
}
|
|
494
502
|
if (schema.readOnly && schema.readOnly === true) {
|
|
495
503
|
return undefined;
|
|
496
504
|
}
|
|
@@ -93,14 +93,16 @@ function createAnyOneOf(schema) {
|
|
|
93
93
|
}
|
|
94
94
|
function createProperties(schema) {
|
|
95
95
|
const discriminator = schema.discriminator;
|
|
96
|
-
return Object.entries(schema.properties).map(([key, val]) =>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
return Object.entries(schema.properties).map(([key, val]) => {
|
|
97
|
+
return createEdges({
|
|
98
|
+
name: key,
|
|
99
|
+
schema: val,
|
|
100
|
+
required: Array.isArray(schema.required)
|
|
101
|
+
? schema.required.includes(key)
|
|
102
|
+
: false,
|
|
103
|
+
discriminator,
|
|
104
|
+
});
|
|
105
|
+
});
|
|
104
106
|
}
|
|
105
107
|
function createAdditionalProperties(schema) {
|
|
106
108
|
// TODO?:
|
|
@@ -215,10 +217,13 @@ function createItems(schema) {
|
|
|
215
217
|
if (mergedSchemas.oneOf !== undefined ||
|
|
216
218
|
mergedSchemas.anyOf !== undefined) {
|
|
217
219
|
return (0, utils_1.create)("div", {
|
|
218
|
-
children: [
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
children: [createAnyOneOf(mergedSchemas)],
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// Handles properties
|
|
224
|
+
if (mergedSchemas.properties !== undefined) {
|
|
225
|
+
return (0, utils_1.create)("div", {
|
|
226
|
+
children: [createProperties(mergedSchemas)],
|
|
222
227
|
});
|
|
223
228
|
}
|
|
224
229
|
}
|
|
@@ -442,7 +447,7 @@ function createPropertyDiscriminator(name, schemaName, schema, discriminator, re
|
|
|
442
447
|
* Creates the edges or "leaves" of a schema tree. Edges can branch into sub-nodes with createDetails().
|
|
443
448
|
*/
|
|
444
449
|
function createEdges({ name, schema, required, discriminator, }) {
|
|
445
|
-
var _a, _b;
|
|
450
|
+
var _a, _b, _c, _d;
|
|
446
451
|
const schemaName = (0, schema_1.getSchemaName)(schema);
|
|
447
452
|
if (discriminator !== undefined && discriminator.propertyName === name) {
|
|
448
453
|
return createPropertyDiscriminator(name, "string", schema, discriminator, required);
|
|
@@ -490,6 +495,9 @@ function createEdges({ name, schema, required, discriminator, }) {
|
|
|
490
495
|
if (((_b = schema.items) === null || _b === void 0 ? void 0 : _b.properties) !== undefined) {
|
|
491
496
|
return createDetailsNode(name, schemaName, schema, required);
|
|
492
497
|
}
|
|
498
|
+
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) {
|
|
499
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
500
|
+
}
|
|
493
501
|
if (schema.writeOnly && schema.writeOnly === true) {
|
|
494
502
|
return undefined;
|
|
495
503
|
}
|
package/lib/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.6",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "cb1f7125cd919da03346cdcb9eef49f4de8537e7"
|
|
72
72
|
}
|
|
@@ -104,16 +104,16 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
104
104
|
|
|
105
105
|
function createProperties(schema: SchemaObject) {
|
|
106
106
|
const discriminator = schema.discriminator;
|
|
107
|
-
return Object.entries(schema.properties!).map(([key, val]) =>
|
|
108
|
-
createEdges({
|
|
107
|
+
return Object.entries(schema.properties!).map(([key, val]) => {
|
|
108
|
+
return createEdges({
|
|
109
109
|
name: key,
|
|
110
110
|
schema: val,
|
|
111
111
|
required: Array.isArray(schema.required)
|
|
112
112
|
? schema.required.includes(key)
|
|
113
113
|
: false,
|
|
114
114
|
discriminator,
|
|
115
|
-
})
|
|
116
|
-
);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
function createAdditionalProperties(schema: SchemaObject) {
|
|
@@ -258,10 +258,14 @@ function createItems(schema: SchemaObject) {
|
|
|
258
258
|
mergedSchemas.anyOf !== undefined
|
|
259
259
|
) {
|
|
260
260
|
return create("div", {
|
|
261
|
-
children: [
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
261
|
+
children: [createAnyOneOf(mergedSchemas)],
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Handles properties
|
|
266
|
+
if (mergedSchemas.properties !== undefined) {
|
|
267
|
+
return create("div", {
|
|
268
|
+
children: [createProperties(mergedSchemas)],
|
|
265
269
|
});
|
|
266
270
|
}
|
|
267
271
|
}
|
|
@@ -613,6 +617,10 @@ function createEdges({
|
|
|
613
617
|
return createDetailsNode(name, schemaName, schema, required);
|
|
614
618
|
}
|
|
615
619
|
|
|
620
|
+
if (schema.items?.anyOf !== undefined || schema.items?.oneOf !== undefined) {
|
|
621
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
622
|
+
}
|
|
623
|
+
|
|
616
624
|
if (schema.readOnly && schema.readOnly === true) {
|
|
617
625
|
return undefined;
|
|
618
626
|
}
|
|
@@ -109,16 +109,16 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
109
109
|
|
|
110
110
|
function createProperties(schema: SchemaObject) {
|
|
111
111
|
const discriminator = schema.discriminator;
|
|
112
|
-
return Object.entries(schema.properties!).map(([key, val]) =>
|
|
113
|
-
createEdges({
|
|
112
|
+
return Object.entries(schema.properties!).map(([key, val]) => {
|
|
113
|
+
return createEdges({
|
|
114
114
|
name: key,
|
|
115
115
|
schema: val,
|
|
116
116
|
required: Array.isArray(schema.required)
|
|
117
117
|
? schema.required.includes(key)
|
|
118
118
|
: false,
|
|
119
119
|
discriminator,
|
|
120
|
-
})
|
|
121
|
-
);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function createAdditionalProperties(schema: SchemaObject) {
|
|
@@ -263,10 +263,14 @@ function createItems(schema: SchemaObject) {
|
|
|
263
263
|
mergedSchemas.anyOf !== undefined
|
|
264
264
|
) {
|
|
265
265
|
return create("div", {
|
|
266
|
-
children: [
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
children: [createAnyOneOf(mergedSchemas)],
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Handles properties
|
|
271
|
+
if (mergedSchemas.properties !== undefined) {
|
|
272
|
+
return create("div", {
|
|
273
|
+
children: [createProperties(mergedSchemas)],
|
|
270
274
|
});
|
|
271
275
|
}
|
|
272
276
|
}
|
|
@@ -613,6 +617,10 @@ function createEdges({
|
|
|
613
617
|
return createDetailsNode(name, schemaName, schema, required);
|
|
614
618
|
}
|
|
615
619
|
|
|
620
|
+
if (schema.items?.anyOf !== undefined || schema.items?.oneOf !== undefined) {
|
|
621
|
+
return createDetailsNode(name, schemaName, schema, required);
|
|
622
|
+
}
|
|
623
|
+
|
|
616
624
|
if (schema.writeOnly && schema.writeOnly === true) {
|
|
617
625
|
return undefined;
|
|
618
626
|
}
|