docusaurus-plugin-openapi-docs 4.1.0 → 4.2.0
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/index.js +4 -0
- package/lib/markdown/createContactInfo.js +1 -1
- package/lib/markdown/createParamsDetails.d.ts +1 -2
- package/lib/markdown/createParamsDetails.js +7 -42
- package/lib/markdown/createRequestBodyDetails.d.ts +1 -1
- package/lib/markdown/createRequestSchema.d.ts +1 -1
- package/lib/markdown/createRequestSchema.js +8 -132
- package/lib/markdown/createResponseSchema.d.ts +1 -1
- package/lib/markdown/createResponseSchema.js +8 -94
- package/lib/markdown/createSchema.d.ts +1 -4
- package/lib/markdown/createSchema.js +32 -56
- package/lib/markdown/createStatusCodes.d.ts +1 -4
- package/lib/markdown/createStatusCodes.js +10 -259
- package/lib/markdown/index.js +11 -22
- package/lib/openapi/createRequestExample.js +2 -2
- package/lib/openapi/createResponseExample.js +2 -2
- package/lib/openapi/openapi.js +3 -1
- package/lib/openapi/types.d.ts +1 -0
- package/lib/options.js +1 -0
- package/package.json +3 -3
- package/src/index.ts +4 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +55 -0
- package/src/markdown/createContactInfo.ts +1 -1
- package/src/markdown/createParamsDetails.ts +7 -49
- package/src/markdown/createRequestSchema.ts +9 -143
- package/src/markdown/createResponseSchema.ts +9 -112
- package/src/markdown/createSchema.ts +29 -61
- package/src/markdown/createStatusCodes.ts +9 -268
- package/src/markdown/index.ts +11 -22
- package/src/openapi/createRequestExample.ts +2 -5
- package/src/openapi/createResponseExample.ts +2 -5
- package/src/openapi/openapi.ts +3 -1
- package/src/openapi/types.ts +1 -0
- package/src/openapi/utils/loadAndResolveSpec.ts +1 -1
- package/src/options.ts +1 -0
|
@@ -5,19 +5,9 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createStatusCodes =
|
|
13
|
-
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
14
|
-
const createDescription_1 = require("./createDescription");
|
|
15
|
-
const createDetails_1 = require("./createDetails");
|
|
16
|
-
const createDetailsSummary_1 = require("./createDetailsSummary");
|
|
17
|
-
const createResponseSchema_1 = require("./createResponseSchema");
|
|
9
|
+
exports.createStatusCodes = void 0;
|
|
18
10
|
const utils_1 = require("./utils");
|
|
19
|
-
const utils_2 = require("./utils");
|
|
20
|
-
const createResponseExample_1 = require("../openapi/createResponseExample");
|
|
21
11
|
function json2xml(o, tab) {
|
|
22
12
|
var toXml = function (v, name, ind) {
|
|
23
13
|
var xml = "";
|
|
@@ -61,253 +51,14 @@ function json2xml(o, tab) {
|
|
|
61
51
|
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
62
52
|
}
|
|
63
53
|
exports.default = json2xml;
|
|
64
|
-
function
|
|
65
|
-
return
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
className: "schemaItem",
|
|
74
|
-
children: [
|
|
75
|
-
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
76
|
-
children: [
|
|
77
|
-
(0, utils_1.create)("strong", { children: headerName }),
|
|
78
|
-
(0, utils_2.guard)(type, () => [
|
|
79
|
-
(0, utils_1.create)("span", {
|
|
80
|
-
style: { opacity: "0.6" },
|
|
81
|
-
children: ` ${type}`,
|
|
82
|
-
}),
|
|
83
|
-
]),
|
|
84
|
-
],
|
|
85
|
-
}),
|
|
86
|
-
(0, utils_1.create)("div", {
|
|
87
|
-
children: [
|
|
88
|
-
(0, utils_2.guard)(description, (description) => (0, utils_1.create)("div", {
|
|
89
|
-
style: {
|
|
90
|
-
marginTop: ".5rem",
|
|
91
|
-
marginBottom: ".5rem",
|
|
92
|
-
},
|
|
93
|
-
children: [
|
|
94
|
-
(0, utils_2.guard)(example, () => `Example: ${example}`),
|
|
95
|
-
(0, createDescription_1.createDescription)(description),
|
|
96
|
-
],
|
|
97
|
-
})),
|
|
98
|
-
],
|
|
99
|
-
}),
|
|
100
|
-
],
|
|
101
|
-
});
|
|
102
|
-
}),
|
|
103
|
-
],
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
function createResponseExamples(responseExamples, mimeType) {
|
|
107
|
-
let language = "shell";
|
|
108
|
-
if (mimeType.endsWith("json")) {
|
|
109
|
-
language = "json";
|
|
110
|
-
}
|
|
111
|
-
if (mimeType.endsWith("xml")) {
|
|
112
|
-
language = "xml";
|
|
113
|
-
}
|
|
114
|
-
return Object.entries(responseExamples).map(([exampleName, exampleValue]) => {
|
|
115
|
-
if (typeof exampleValue.value === "object") {
|
|
116
|
-
return (0, utils_1.create)("TabItem", {
|
|
117
|
-
label: `${exampleName}`,
|
|
118
|
-
value: `${exampleName}`,
|
|
119
|
-
children: [
|
|
120
|
-
(0, utils_2.guard)(exampleValue.summary, (summary) => [
|
|
121
|
-
(0, utils_1.create)("div", {
|
|
122
|
-
children: `${summary}`,
|
|
123
|
-
className: "openapi-example__summary",
|
|
124
|
-
}),
|
|
125
|
-
]),
|
|
126
|
-
(0, utils_1.create)("ResponseSamples", {
|
|
127
|
-
responseExample: JSON.stringify(exampleValue.value, null, 2),
|
|
128
|
-
language: language,
|
|
129
|
-
}),
|
|
130
|
-
],
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return (0, utils_1.create)("TabItem", {
|
|
134
|
-
label: `${exampleName}`,
|
|
135
|
-
value: `${exampleName}`,
|
|
136
|
-
children: [
|
|
137
|
-
(0, utils_2.guard)(exampleValue.summary, (summary) => [
|
|
138
|
-
(0, utils_1.create)("div", {
|
|
139
|
-
children: `${summary}`,
|
|
140
|
-
className: "openapi-example__summary",
|
|
141
|
-
}),
|
|
142
|
-
]),
|
|
143
|
-
(0, utils_1.create)("ResponseSamples", {
|
|
144
|
-
responseExample: exampleValue.value,
|
|
145
|
-
language: language,
|
|
146
|
-
}),
|
|
147
|
-
],
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
exports.createResponseExamples = createResponseExamples;
|
|
152
|
-
function createResponseExample(responseExample, mimeType) {
|
|
153
|
-
let language = "shell";
|
|
154
|
-
if (mimeType.endsWith("json")) {
|
|
155
|
-
language = "json";
|
|
156
|
-
}
|
|
157
|
-
if (mimeType.endsWith("xml")) {
|
|
158
|
-
language = "xml";
|
|
159
|
-
}
|
|
160
|
-
if (typeof responseExample === "object") {
|
|
161
|
-
return (0, utils_1.create)("TabItem", {
|
|
162
|
-
label: `Example`,
|
|
163
|
-
value: `Example`,
|
|
164
|
-
children: [
|
|
165
|
-
(0, utils_2.guard)(responseExample.summary, (summary) => [
|
|
166
|
-
(0, utils_1.create)("div", {
|
|
167
|
-
children: `${summary}`,
|
|
168
|
-
className: "openapi-example__summary",
|
|
169
|
-
}),
|
|
170
|
-
]),
|
|
171
|
-
(0, utils_1.create)("ResponseSamples", {
|
|
172
|
-
responseExample: JSON.stringify(responseExample, null, 2),
|
|
173
|
-
language: language,
|
|
174
|
-
}),
|
|
175
|
-
],
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
return (0, utils_1.create)("TabItem", {
|
|
179
|
-
label: `Example`,
|
|
180
|
-
value: `Example`,
|
|
181
|
-
children: [
|
|
182
|
-
(0, utils_2.guard)(responseExample.summary, (summary) => [
|
|
183
|
-
(0, utils_1.create)("div", {
|
|
184
|
-
children: `${summary}`,
|
|
185
|
-
className: "openapi-example__summary",
|
|
186
|
-
}),
|
|
187
|
-
]),
|
|
188
|
-
(0, utils_1.create)("ResponseSamples", {
|
|
189
|
-
responseExample: responseExample,
|
|
190
|
-
language: language,
|
|
191
|
-
}),
|
|
192
|
-
],
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
exports.createResponseExample = createResponseExample;
|
|
196
|
-
function createExampleFromSchema(schema, mimeType) {
|
|
197
|
-
const responseExample = (0, createResponseExample_1.sampleResponseFromSchema)(schema);
|
|
198
|
-
if (mimeType.endsWith("xml")) {
|
|
199
|
-
let responseExampleObject;
|
|
200
|
-
try {
|
|
201
|
-
responseExampleObject = JSON.parse(JSON.stringify(responseExample));
|
|
202
|
-
}
|
|
203
|
-
catch {
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
if (typeof responseExampleObject === "object") {
|
|
207
|
-
let xmlExample;
|
|
208
|
-
try {
|
|
209
|
-
xmlExample = (0, xml_formatter_1.default)(json2xml(responseExampleObject, ""), {
|
|
210
|
-
indentation: " ",
|
|
211
|
-
lineSeparator: "\n",
|
|
212
|
-
collapseContent: true,
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
catch {
|
|
216
|
-
const xmlExampleWithRoot = { root: responseExampleObject };
|
|
217
|
-
try {
|
|
218
|
-
xmlExample = (0, xml_formatter_1.default)(json2xml(xmlExampleWithRoot, ""), {
|
|
219
|
-
indentation: " ",
|
|
220
|
-
lineSeparator: "\n",
|
|
221
|
-
collapseContent: true,
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
catch {
|
|
225
|
-
xmlExample = json2xml(responseExampleObject, "");
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
return (0, utils_1.create)("TabItem", {
|
|
229
|
-
label: `Example (from schema)`,
|
|
230
|
-
value: `Example (from schema)`,
|
|
231
|
-
children: [
|
|
232
|
-
(0, utils_1.create)("ResponseSamples", {
|
|
233
|
-
responseExample: xmlExample,
|
|
234
|
-
language: "xml",
|
|
235
|
-
}),
|
|
236
|
-
],
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (typeof responseExample === "object") {
|
|
241
|
-
return (0, utils_1.create)("TabItem", {
|
|
242
|
-
label: `Example (from schema)`,
|
|
243
|
-
value: `Example (from schema)`,
|
|
244
|
-
children: [
|
|
245
|
-
(0, utils_1.create)("ResponseSamples", {
|
|
246
|
-
responseExample: JSON.stringify(responseExample, null, 2),
|
|
247
|
-
language: "json",
|
|
248
|
-
}),
|
|
249
|
-
],
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
return undefined;
|
|
253
|
-
}
|
|
254
|
-
exports.createExampleFromSchema = createExampleFromSchema;
|
|
255
|
-
function createStatusCodes({ label, id, responses }) {
|
|
256
|
-
if (responses === undefined) {
|
|
257
|
-
return undefined;
|
|
258
|
-
}
|
|
259
|
-
const codes = Object.keys(responses);
|
|
260
|
-
if (codes.length === 0) {
|
|
261
|
-
return undefined;
|
|
262
|
-
}
|
|
263
|
-
return (0, utils_1.create)("div", {
|
|
264
|
-
children: [
|
|
265
|
-
(0, utils_1.create)("div", {
|
|
266
|
-
children: [
|
|
267
|
-
(0, utils_1.create)("ApiTabs", {
|
|
268
|
-
label,
|
|
269
|
-
id,
|
|
270
|
-
children: codes.map((code) => {
|
|
271
|
-
const responseHeaders = responses[code].headers;
|
|
272
|
-
return (0, utils_1.create)("TabItem", {
|
|
273
|
-
label: code,
|
|
274
|
-
value: code,
|
|
275
|
-
children: [
|
|
276
|
-
(0, utils_1.create)("div", {
|
|
277
|
-
children: (0, createDescription_1.createDescription)(responses[code].description),
|
|
278
|
-
}),
|
|
279
|
-
responseHeaders &&
|
|
280
|
-
(0, createDetails_1.createDetails)({
|
|
281
|
-
className: "openapi-markdown__details",
|
|
282
|
-
"data-collapsed": true,
|
|
283
|
-
open: false,
|
|
284
|
-
style: { textAlign: "left", marginBottom: "1rem" },
|
|
285
|
-
children: [
|
|
286
|
-
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
287
|
-
children: [
|
|
288
|
-
(0, utils_1.create)("strong", {
|
|
289
|
-
children: "Response Headers",
|
|
290
|
-
}),
|
|
291
|
-
],
|
|
292
|
-
}),
|
|
293
|
-
createResponseHeaders(responseHeaders),
|
|
294
|
-
],
|
|
295
|
-
}),
|
|
296
|
-
(0, utils_1.create)("div", {
|
|
297
|
-
children: (0, createResponseSchema_1.createResponseSchema)({
|
|
298
|
-
title: "Schema",
|
|
299
|
-
body: {
|
|
300
|
-
content: responses[code].content,
|
|
301
|
-
},
|
|
302
|
-
}),
|
|
303
|
-
}),
|
|
304
|
-
],
|
|
305
|
-
});
|
|
306
|
-
}),
|
|
307
|
-
}),
|
|
308
|
-
],
|
|
309
|
-
}),
|
|
310
|
-
],
|
|
311
|
-
});
|
|
54
|
+
function createStatusCodes({ id, label, responses }) {
|
|
55
|
+
return [
|
|
56
|
+
(0, utils_1.create)("StatusCodes", {
|
|
57
|
+
id: id,
|
|
58
|
+
label: label,
|
|
59
|
+
responses: responses,
|
|
60
|
+
}),
|
|
61
|
+
"\n\n",
|
|
62
|
+
];
|
|
312
63
|
}
|
|
313
64
|
exports.createStatusCodes = createStatusCodes;
|
package/lib/markdown/index.js
CHANGED
|
@@ -21,7 +21,6 @@ const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
|
21
21
|
const createParamsDetails_1 = require("./createParamsDetails");
|
|
22
22
|
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
23
23
|
const createRequestHeader_1 = require("./createRequestHeader");
|
|
24
|
-
const createSchema_1 = require("./createSchema");
|
|
25
24
|
const createStatusCodes_1 = require("./createStatusCodes");
|
|
26
25
|
const createTermsOfService_1 = require("./createTermsOfService");
|
|
27
26
|
const createVendorExtensions_1 = require("./createVendorExtensions");
|
|
@@ -29,18 +28,13 @@ const createVersionBadge_1 = require("./createVersionBadge");
|
|
|
29
28
|
const utils_1 = require("./utils");
|
|
30
29
|
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, callbacks, }, infoPath, frontMatter, }) {
|
|
31
30
|
return (0, utils_1.render)([
|
|
32
|
-
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
33
|
-
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
34
31
|
`import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
|
|
35
|
-
`import
|
|
36
|
-
`import
|
|
37
|
-
`import
|
|
38
|
-
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
39
|
-
`import SchemaItem from "@theme/SchemaItem";\n`,
|
|
40
|
-
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
41
|
-
`import Heading from "@theme/Heading";\n`,
|
|
32
|
+
`import ParamsDetails from "@theme/ParamsDetails";\n`,
|
|
33
|
+
`import RequestSchema from "@theme/RequestSchema";\n`,
|
|
34
|
+
`import StatusCodes from "@theme/StatusCodes";\n`,
|
|
42
35
|
`import OperationTabs from "@theme/OperationTabs";\n`,
|
|
43
|
-
`import TabItem from "@theme/TabItem";\n
|
|
36
|
+
`import TabItem from "@theme/TabItem";\n`,
|
|
37
|
+
`import Heading from "@theme/Heading";\n\n`,
|
|
44
38
|
(0, createHeading_1.createHeading)(title),
|
|
45
39
|
(0, createMethodEndpoint_1.createMethodEndpoint)(method, path),
|
|
46
40
|
infoPath && (0, createAuthorization_1.createAuthorization)(infoPath),
|
|
@@ -50,10 +44,7 @@ function createApiPageMD({ title, api: { deprecated, "x-deprecated-description":
|
|
|
50
44
|
(0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
|
|
51
45
|
(0, createDescription_1.createDescription)(description),
|
|
52
46
|
requestBody || parameters ? (0, createRequestHeader_1.createRequestHeader)("Request") : undefined,
|
|
53
|
-
(0, createParamsDetails_1.createParamsDetails)({ parameters
|
|
54
|
-
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "query" }),
|
|
55
|
-
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "header" }),
|
|
56
|
-
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "cookie" }),
|
|
47
|
+
(0, createParamsDetails_1.createParamsDetails)({ parameters }),
|
|
57
48
|
(0, createRequestBodyDetails_1.createRequestBodyDetails)({
|
|
58
49
|
title: "Body",
|
|
59
50
|
body: requestBody,
|
|
@@ -89,15 +80,13 @@ exports.createTagPageMD = createTagPageMD;
|
|
|
89
80
|
function createSchemaPageMD({ schema }) {
|
|
90
81
|
const { title = "", description } = schema;
|
|
91
82
|
return (0, utils_1.render)([
|
|
92
|
-
`import
|
|
93
|
-
`import
|
|
94
|
-
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
95
|
-
`import Heading from "@theme/Heading";\n`,
|
|
96
|
-
`import TabItem from "@theme/TabItem";\n\n`,
|
|
83
|
+
`import Schema from "@theme/Schema";\n`,
|
|
84
|
+
`import Heading from "@theme/Heading";\n\n`,
|
|
97
85
|
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
98
86
|
(0, createDescription_1.createDescription)(description),
|
|
99
|
-
(0, utils_1.create)("
|
|
100
|
-
|
|
87
|
+
(0, utils_1.create)("Schema", {
|
|
88
|
+
schema: schema,
|
|
89
|
+
schemaType: "response",
|
|
101
90
|
}),
|
|
102
91
|
]);
|
|
103
92
|
}
|
|
@@ -51,7 +51,7 @@ function sampleRequestFromProp(name, prop, obj) {
|
|
|
51
51
|
obj[name] = (0, exports.sampleRequestFromSchema)(prop.anyOf[0]);
|
|
52
52
|
}
|
|
53
53
|
else if (prop.allOf) {
|
|
54
|
-
const
|
|
54
|
+
const mergedSchemas = (0, createSchema_1.mergeAllOf)(prop);
|
|
55
55
|
sampleRequestFromProp(name, mergedSchemas, obj);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
@@ -86,7 +86,7 @@ const sampleRequestFromSchema = (schema = {}) => {
|
|
|
86
86
|
return (0, exports.sampleRequestFromSchema)(anyOf[0]);
|
|
87
87
|
}
|
|
88
88
|
if (allOf) {
|
|
89
|
-
const
|
|
89
|
+
const mergedSchemas = (0, createSchema_1.mergeAllOf)(schemaCopy);
|
|
90
90
|
if (mergedSchemas.properties) {
|
|
91
91
|
for (const [key, value] of Object.entries(mergedSchemas.properties)) {
|
|
92
92
|
if ((value.readOnly && value.readOnly === true) || value.deprecated) {
|
|
@@ -51,7 +51,7 @@ function sampleResponseFromProp(name, prop, obj) {
|
|
|
51
51
|
obj[name] = (0, exports.sampleResponseFromSchema)(prop.anyOf[0]);
|
|
52
52
|
}
|
|
53
53
|
else if (prop.allOf) {
|
|
54
|
-
const
|
|
54
|
+
const mergedSchemas = (0, createSchema_1.mergeAllOf)(prop);
|
|
55
55
|
sampleResponseFromProp(name, mergedSchemas, obj);
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
@@ -68,7 +68,7 @@ const sampleResponseFromSchema = (schema = {}) => {
|
|
|
68
68
|
return example;
|
|
69
69
|
}
|
|
70
70
|
if (allOf) {
|
|
71
|
-
const
|
|
71
|
+
const mergedSchemas = (0, createSchema_1.mergeAllOf)(schemaCopy);
|
|
72
72
|
if (mergedSchemas.properties) {
|
|
73
73
|
for (const [key, value] of Object.entries(mergedSchemas.properties)) {
|
|
74
74
|
if ((value.writeOnly && value.writeOnly === true) ||
|
package/lib/openapi/openapi.js
CHANGED
|
@@ -21,8 +21,9 @@ const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
|
21
21
|
const openapi_to_postmanv2_1 = __importDefault(require("openapi-to-postmanv2"));
|
|
22
22
|
const postman_collection_1 = __importDefault(require("postman-collection"));
|
|
23
23
|
const createRequestExample_1 = require("./createRequestExample");
|
|
24
|
-
const loadAndResolveSpec_1 = require("./utils/loadAndResolveSpec");
|
|
25
24
|
const index_1 = require("../index");
|
|
25
|
+
const createResponseExample_1 = require("./createResponseExample");
|
|
26
|
+
const loadAndResolveSpec_1 = require("./utils/loadAndResolveSpec");
|
|
26
27
|
/**
|
|
27
28
|
* Convenience function for converting raw JSON to a Postman Collection object.
|
|
28
29
|
*/
|
|
@@ -355,6 +356,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
355
356
|
.replace(/((?:^|[^\\])(?:\\{2})*)"/g, "$1'")
|
|
356
357
|
.replace(/\s+$/, "")
|
|
357
358
|
: "",
|
|
359
|
+
sample: JSON.stringify((0, createResponseExample_1.sampleResponseFromSchema)(schemaObject)),
|
|
358
360
|
},
|
|
359
361
|
schema: schemaObject,
|
|
360
362
|
};
|
package/lib/openapi/types.d.ts
CHANGED
package/lib/options.js
CHANGED
|
@@ -23,6 +23,7 @@ const markdownGenerators = utils_validation_1.Joi.object({
|
|
|
23
23
|
createApiPageMD: utils_validation_1.Joi.function(),
|
|
24
24
|
createInfoPageMD: utils_validation_1.Joi.function(),
|
|
25
25
|
createTagPageMD: utils_validation_1.Joi.function(),
|
|
26
|
+
createSchemaPageMD: utils_validation_1.Joi.function(),
|
|
26
27
|
});
|
|
27
28
|
exports.OptionsSchema = utils_validation_1.Joi.object({
|
|
28
29
|
id: utils_validation_1.Joi.string().required(),
|
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": "4.
|
|
4
|
+
"version": "4.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"@docusaurus/utils": "^3.5.0",
|
|
43
43
|
"@docusaurus/utils-validation": "^3.5.0",
|
|
44
44
|
"@redocly/openapi-core": "^1.10.5",
|
|
45
|
+
"allof-merge": "^0.6.6",
|
|
45
46
|
"chalk": "^4.1.2",
|
|
46
47
|
"clsx": "^1.1.1",
|
|
47
48
|
"fs-extra": "^9.0.1",
|
|
48
49
|
"json-pointer": "^0.6.2",
|
|
49
|
-
"json-schema-merge-allof": "^0.8.1",
|
|
50
50
|
"json5": "^2.2.3",
|
|
51
51
|
"lodash": "^4.17.20",
|
|
52
52
|
"mustache": "^4.2.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "e7295a8aa6f3fab5ccc4f8f9ad0e6c33d785aa16"
|
|
66
66
|
}
|
package/src/index.ts
CHANGED
|
@@ -278,7 +278,11 @@ title: "{{{title}}}"
|
|
|
278
278
|
description: "{{{frontMatter.description}}}"
|
|
279
279
|
sidebar_label: "{{{title}}}"
|
|
280
280
|
hide_title: true
|
|
281
|
+
{{#schema}}
|
|
282
|
+
hide_table_of_contents: true
|
|
283
|
+
{{/schema}}
|
|
281
284
|
schema: true
|
|
285
|
+
sample: {{{frontMatter.sample}}}
|
|
282
286
|
custom_edit_url: null
|
|
283
287
|
---
|
|
284
288
|
|
|
@@ -364,6 +364,24 @@ Array [
|
|
|
364
364
|
qualifierMessage={undefined}
|
|
365
365
|
schema={{ type: \\"string\\" }}
|
|
366
366
|
></SchemaItem>;
|
|
367
|
+
",
|
|
368
|
+
"<SchemaItem
|
|
369
|
+
collapsible={false}
|
|
370
|
+
name={\\"parentProp1\\"}
|
|
371
|
+
required={false}
|
|
372
|
+
schemaName={\\"string\\"}
|
|
373
|
+
qualifierMessage={undefined}
|
|
374
|
+
schema={{ type: \\"string\\" }}
|
|
375
|
+
></SchemaItem>;
|
|
376
|
+
",
|
|
377
|
+
"<SchemaItem
|
|
378
|
+
collapsible={false}
|
|
379
|
+
name={\\"parentProp2\\"}
|
|
380
|
+
required={false}
|
|
381
|
+
schemaName={\\"string\\"}
|
|
382
|
+
qualifierMessage={undefined}
|
|
383
|
+
schema={{ type: \\"string\\" }}
|
|
384
|
+
></SchemaItem>;
|
|
367
385
|
",
|
|
368
386
|
]
|
|
369
387
|
`;
|
|
@@ -711,6 +729,15 @@ Array [
|
|
|
711
729
|
qualifierMessage={undefined}
|
|
712
730
|
schema={{ type: \\"string\\" }}
|
|
713
731
|
></SchemaItem>;
|
|
732
|
+
",
|
|
733
|
+
"<SchemaItem
|
|
734
|
+
collapsible={false}
|
|
735
|
+
name={\\"type\\"}
|
|
736
|
+
required={false}
|
|
737
|
+
schemaName={\\"string\\"}
|
|
738
|
+
qualifierMessage={undefined}
|
|
739
|
+
schema={{ type: \\"string\\" }}
|
|
740
|
+
></SchemaItem>;
|
|
714
741
|
",
|
|
715
742
|
]
|
|
716
743
|
`;
|
|
@@ -797,6 +824,34 @@ Array [
|
|
|
797
824
|
qualifierMessage={undefined}
|
|
798
825
|
schema={{ type: \\"string\\" }}
|
|
799
826
|
></SchemaItem>;
|
|
827
|
+
",
|
|
828
|
+
"<div className={\\"openapi-discriminator__item openapi-schema__list-item\\"}>
|
|
829
|
+
<div>
|
|
830
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
831
|
+
<strong
|
|
832
|
+
className={\\"openapi-discriminator__name openapi-schema__property\\"}
|
|
833
|
+
>
|
|
834
|
+
type
|
|
835
|
+
</strong>
|
|
836
|
+
<span className={\\"openapi-schema__name\\"}>string</span>
|
|
837
|
+
</span>
|
|
838
|
+
<div style={{ paddingLeft: \\"1rem\\" }}>
|
|
839
|
+
**Possible values:** [\`typeA\`, \`typeB\`]
|
|
840
|
+
</div>
|
|
841
|
+
<DiscriminatorTabs className={\\"openapi-tabs__discriminator\\"}>
|
|
842
|
+
<TabItem label={\\"typeA\\"} value={\\"0-item-discriminator\\"}>
|
|
843
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
844
|
+
#/definitions/TypeA
|
|
845
|
+
</div>
|
|
846
|
+
</TabItem>
|
|
847
|
+
<TabItem label={\\"typeB\\"} value={\\"1-item-discriminator\\"}>
|
|
848
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
849
|
+
#/definitions/TypeB
|
|
850
|
+
</div>
|
|
851
|
+
</TabItem>
|
|
852
|
+
</DiscriminatorTabs>
|
|
853
|
+
</div>
|
|
854
|
+
</div>;
|
|
800
855
|
",
|
|
801
856
|
]
|
|
802
857
|
`;
|
|
@@ -5,60 +5,18 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import { createDetails } from "./createDetails";
|
|
9
|
-
import { createDetailsSummary } from "./createDetailsSummary";
|
|
10
8
|
import { create } from "./utils";
|
|
11
9
|
import { ApiItem } from "../types";
|
|
12
10
|
|
|
13
11
|
interface Props {
|
|
14
12
|
parameters: ApiItem["parameters"];
|
|
15
|
-
type: "path" | "query" | "header" | "cookie";
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
export function createParamsDetails({ parameters
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return createDetails({
|
|
28
|
-
className: "openapi-markdown__details",
|
|
29
|
-
"data-collapsed": false,
|
|
30
|
-
open: true,
|
|
31
|
-
style: { marginBottom: "1rem" },
|
|
32
|
-
children: [
|
|
33
|
-
createDetailsSummary({
|
|
34
|
-
children: [
|
|
35
|
-
create("h3", {
|
|
36
|
-
className: "openapi-markdown__details-summary-header-params",
|
|
37
|
-
children: `${
|
|
38
|
-
type.charAt(0).toUpperCase() + type.slice(1)
|
|
39
|
-
} Parameters`,
|
|
40
|
-
}),
|
|
41
|
-
],
|
|
42
|
-
}),
|
|
43
|
-
create("div", {
|
|
44
|
-
children: [
|
|
45
|
-
create("ul", {
|
|
46
|
-
children: params.map((param) => {
|
|
47
|
-
return create("ParamsItem", {
|
|
48
|
-
className: "paramsItem",
|
|
49
|
-
param: {
|
|
50
|
-
...param,
|
|
51
|
-
enumDescriptions: Object.entries(
|
|
52
|
-
param?.schema?.["x-enumDescriptions"] ??
|
|
53
|
-
param?.schema?.items?.["x-enumDescriptions"] ??
|
|
54
|
-
{}
|
|
55
|
-
),
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
}),
|
|
59
|
-
}),
|
|
60
|
-
],
|
|
61
|
-
}),
|
|
62
|
-
],
|
|
63
|
-
});
|
|
15
|
+
export function createParamsDetails({ parameters }: Props) {
|
|
16
|
+
return [
|
|
17
|
+
create("ParamsDetails", {
|
|
18
|
+
parameters: parameters,
|
|
19
|
+
}),
|
|
20
|
+
"\n\n",
|
|
21
|
+
];
|
|
64
22
|
}
|