docusaurus-plugin-openapi-docs 0.0.0-441 → 0.0.0-448
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.
|
@@ -344,7 +344,9 @@ function createDetailsNode(name, schemaName, schema, required) {
|
|
|
344
344
|
style: { opacity: "0.6" },
|
|
345
345
|
children: ` ${schemaName}`,
|
|
346
346
|
}),
|
|
347
|
-
(0, utils_1.guard)(
|
|
347
|
+
(0, utils_1.guard)(Array.isArray(required)
|
|
348
|
+
? required.includes(name)
|
|
349
|
+
: required === true, () => [
|
|
348
350
|
(0, utils_1.create)("strong", {
|
|
349
351
|
style: {
|
|
350
352
|
fontSize: "var(--ifm-code-font-size)",
|
|
@@ -60,15 +60,17 @@ function sampleResponseFromProp(name, prop, obj) {
|
|
|
60
60
|
}
|
|
61
61
|
const sampleResponseFromSchema = (schema = {}) => {
|
|
62
62
|
try {
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
64
|
let { type, example, allOf, oneOf, anyOf, properties, items } = schema;
|
|
64
|
-
if
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
// TODO: determine if we should always ignore the example when creating from schema
|
|
66
|
+
// if (example !== undefined) {
|
|
67
|
+
// return example;
|
|
68
|
+
// }
|
|
67
69
|
if (allOf) {
|
|
68
70
|
const { mergedSchemas } = (0, createResponseSchema_1.mergeAllOf)(allOf);
|
|
69
71
|
if (mergedSchemas.properties) {
|
|
70
72
|
for (const [key, value] of Object.entries(mergedSchemas.properties)) {
|
|
71
|
-
if (value.
|
|
73
|
+
if (value.writeOnly && value.writeOnly === true) {
|
|
72
74
|
delete mergedSchemas.properties[key];
|
|
73
75
|
}
|
|
74
76
|
}
|
|
@@ -99,14 +101,14 @@ const sampleResponseFromSchema = (schema = {}) => {
|
|
|
99
101
|
for (let [name, prop] of Object.entries(properties !== null && properties !== void 0 ? properties : {})) {
|
|
100
102
|
if (prop.properties) {
|
|
101
103
|
for (const [key, value] of Object.entries(prop.properties)) {
|
|
102
|
-
if (value.
|
|
104
|
+
if (value.writeOnly && value.writeOnly === true) {
|
|
103
105
|
delete prop.properties[key];
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
if (prop.items && prop.items.properties) {
|
|
108
110
|
for (const [key, value] of Object.entries(prop.items.properties)) {
|
|
109
|
-
if (value.
|
|
111
|
+
if (value.writeOnly && value.writeOnly === true) {
|
|
110
112
|
delete prop.items.properties[key];
|
|
111
113
|
}
|
|
112
114
|
}
|
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": "0.0.0-
|
|
4
|
+
"version": "0.0.0-448",
|
|
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": "9ca7fd6049b1e78fb047b1d99ed0bd61df2ffb10"
|
|
72
72
|
}
|
|
@@ -407,15 +407,20 @@ function createDetailsNode(
|
|
|
407
407
|
style: { opacity: "0.6" },
|
|
408
408
|
children: ` ${schemaName}`,
|
|
409
409
|
}),
|
|
410
|
-
guard(
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
410
|
+
guard(
|
|
411
|
+
Array.isArray(required)
|
|
412
|
+
? required.includes(name)
|
|
413
|
+
: required === true,
|
|
414
|
+
() => [
|
|
415
|
+
create("strong", {
|
|
416
|
+
style: {
|
|
417
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
418
|
+
color: "var(--openapi-required)",
|
|
419
|
+
},
|
|
420
|
+
children: " required",
|
|
421
|
+
}),
|
|
422
|
+
]
|
|
423
|
+
),
|
|
419
424
|
],
|
|
420
425
|
}),
|
|
421
426
|
create("div", {
|
|
@@ -77,18 +77,20 @@ function sampleResponseFromProp(name: string, prop: any, obj: any): any {
|
|
|
77
77
|
|
|
78
78
|
export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
|
|
79
79
|
try {
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
80
81
|
let { type, example, allOf, oneOf, anyOf, properties, items } = schema;
|
|
81
82
|
|
|
82
|
-
if
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// TODO: determine if we should always ignore the example when creating from schema
|
|
84
|
+
// if (example !== undefined) {
|
|
85
|
+
// return example;
|
|
86
|
+
// }
|
|
85
87
|
|
|
86
88
|
if (allOf) {
|
|
87
89
|
const { mergedSchemas }: { mergedSchemas: SchemaObject } =
|
|
88
90
|
mergeAllOf(allOf);
|
|
89
91
|
if (mergedSchemas.properties) {
|
|
90
92
|
for (const [key, value] of Object.entries(mergedSchemas.properties)) {
|
|
91
|
-
if (value.
|
|
93
|
+
if (value.writeOnly && value.writeOnly === true) {
|
|
92
94
|
delete mergedSchemas.properties[key];
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -121,7 +123,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
|
|
|
121
123
|
for (let [name, prop] of Object.entries(properties ?? {})) {
|
|
122
124
|
if (prop.properties) {
|
|
123
125
|
for (const [key, value] of Object.entries(prop.properties)) {
|
|
124
|
-
if (value.
|
|
126
|
+
if (value.writeOnly && value.writeOnly === true) {
|
|
125
127
|
delete prop.properties[key];
|
|
126
128
|
}
|
|
127
129
|
}
|
|
@@ -129,7 +131,7 @@ export const sampleResponseFromSchema = (schema: SchemaObject = {}): any => {
|
|
|
129
131
|
|
|
130
132
|
if (prop.items && prop.items.properties) {
|
|
131
133
|
for (const [key, value] of Object.entries(prop.items.properties)) {
|
|
132
|
-
if (value.
|
|
134
|
+
if (value.writeOnly && value.writeOnly === true) {
|
|
133
135
|
delete prop.items.properties[key];
|
|
134
136
|
}
|
|
135
137
|
}
|