docusaurus-plugin-openapi-docs 0.0.0-775 → 0.0.0-783
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/createCallbackMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createCallbackMethodEndpoint.js +21 -0
- package/lib/markdown/createCallbacks.js +2 -2
- package/lib/markdown/createMethodEndpoint.js +8 -1
- package/lib/markdown/createSchema.js +4 -0
- package/lib/markdown/createSchema.test.js +48 -0
- package/package.json +2 -2
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +87 -0
- package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
- package/src/markdown/createCallbacks.ts +2 -2
- package/src/markdown/createMethodEndpoint.ts +8 -1
- package/src/markdown/createSchema.test.ts +64 -0
- package/src/markdown/createSchema.ts +5 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createCallbackMethodEndpoint(method: String, path: String): string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createCallbackMethodEndpoint = void 0;
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
function createCallbackMethodEndpoint(method, path) {
|
|
12
|
+
return [
|
|
13
|
+
(0, utils_1.create)("MethodEndpoint", {
|
|
14
|
+
method: method,
|
|
15
|
+
path: path,
|
|
16
|
+
context: "callback",
|
|
17
|
+
}),
|
|
18
|
+
"\n\n",
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
exports.createCallbackMethodEndpoint = createCallbackMethodEndpoint;
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* ========================================================================== */
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createCallbacks = void 0;
|
|
10
|
+
const createCallbackMethodEndpoint_1 = require("./createCallbackMethodEndpoint");
|
|
10
11
|
const createDescription_1 = require("./createDescription");
|
|
11
|
-
const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
12
12
|
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
13
13
|
const createStatusCodes_1 = require("./createStatusCodes");
|
|
14
14
|
const utils_1 = require("./utils");
|
|
@@ -54,7 +54,7 @@ function createCallbacks({ callbacks }) {
|
|
|
54
54
|
label: `${method.toUpperCase()} ${name}`,
|
|
55
55
|
value: `${method}-${name}`,
|
|
56
56
|
children: [
|
|
57
|
-
(0,
|
|
57
|
+
(0, createCallbackMethodEndpoint_1.createCallbackMethodEndpoint)(method, path),
|
|
58
58
|
// TODO: add `deprecation notice` when markdown support is added
|
|
59
59
|
(0, createDescription_1.createDescription)(description),
|
|
60
60
|
(0, createRequestBodyDetails_1.createRequestBodyDetails)({
|
|
@@ -9,6 +9,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.createMethodEndpoint = void 0;
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
11
|
function createMethodEndpoint(method, path) {
|
|
12
|
-
return [
|
|
12
|
+
return [
|
|
13
|
+
(0, utils_1.create)("MethodEndpoint", {
|
|
14
|
+
method: method,
|
|
15
|
+
path: path,
|
|
16
|
+
context: "endpoint",
|
|
17
|
+
}),
|
|
18
|
+
"\n\n",
|
|
19
|
+
];
|
|
13
20
|
}
|
|
14
21
|
exports.createMethodEndpoint = createMethodEndpoint;
|
|
@@ -90,6 +90,10 @@ function createAnyOneOf(schema) {
|
|
|
90
90
|
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
91
91
|
delete anyOneSchema.allOf;
|
|
92
92
|
}
|
|
93
|
+
if (anyOneSchema.oneOf !== undefined) {
|
|
94
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
95
|
+
delete anyOneSchema.oneOf;
|
|
96
|
+
}
|
|
93
97
|
if (anyOneSchema.items !== undefined) {
|
|
94
98
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
95
99
|
delete anyOneSchema.items;
|
|
@@ -218,6 +218,54 @@ describe("createNodes", () => {
|
|
|
218
218
|
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
219
219
|
});
|
|
220
220
|
});
|
|
221
|
+
describe("anyOf", () => {
|
|
222
|
+
it("should render primitives within anyOf", async () => {
|
|
223
|
+
const schema = {
|
|
224
|
+
type: "object",
|
|
225
|
+
properties: {
|
|
226
|
+
oneOfProperty: {
|
|
227
|
+
anyOf: [
|
|
228
|
+
{
|
|
229
|
+
type: "integer",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
type: "boolean",
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
title: "One of int or bool",
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
240
|
+
});
|
|
241
|
+
it("should render oneOf within anyOf", async () => {
|
|
242
|
+
const schema = {
|
|
243
|
+
type: "object",
|
|
244
|
+
properties: {
|
|
245
|
+
oneOfProperty: {
|
|
246
|
+
anyOf: [
|
|
247
|
+
{
|
|
248
|
+
oneOf: [
|
|
249
|
+
{
|
|
250
|
+
type: "integer",
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
type: "boolean",
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
title: "An int or a bool",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
type: "string",
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
title: "One of int or bool, or a string",
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
expect(await Promise.all((0, createSchema_1.createNodes)(schema, "response").map(async (md) => await prettier.format(md, { parser: "babel" })))).toMatchSnapshot();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
221
269
|
describe("allOf", () => {
|
|
222
270
|
it("should render same-level properties with allOf", async () => {
|
|
223
271
|
const schema = {
|
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-783",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=14"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "fde0fbcb9f5e91b02506de828ad39cc295f68608"
|
|
66
66
|
}
|
|
@@ -368,6 +368,93 @@ Array [
|
|
|
368
368
|
]
|
|
369
369
|
`;
|
|
370
370
|
|
|
371
|
+
exports[`createNodes anyOf should render oneOf within anyOf 1`] = `
|
|
372
|
+
Array [
|
|
373
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
374
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
375
|
+
<summary style={{}}>
|
|
376
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
377
|
+
<strong className={\\"openapi-schema__property\\"}>oneOfProperty</strong>
|
|
378
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
379
|
+
</span>
|
|
380
|
+
</summary>
|
|
381
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
382
|
+
<div>
|
|
383
|
+
<span className={\\"badge badge--info\\"} style={{ marginBottom: \\"1rem\\" }}>
|
|
384
|
+
anyOf
|
|
385
|
+
</span>
|
|
386
|
+
<SchemaTabs>
|
|
387
|
+
<TabItem label={\\"An int or a bool\\"} value={\\"0-item-properties\\"}>
|
|
388
|
+
<div>
|
|
389
|
+
<span
|
|
390
|
+
className={\\"badge badge--info\\"}
|
|
391
|
+
style={{ marginBottom: \\"1rem\\" }}
|
|
392
|
+
>
|
|
393
|
+
oneOf
|
|
394
|
+
</span>
|
|
395
|
+
<SchemaTabs>
|
|
396
|
+
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
397
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
398
|
+
integer
|
|
399
|
+
</div>
|
|
400
|
+
</TabItem>
|
|
401
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
402
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
403
|
+
boolean
|
|
404
|
+
</div>
|
|
405
|
+
</TabItem>
|
|
406
|
+
</SchemaTabs>
|
|
407
|
+
</div>
|
|
408
|
+
</TabItem>
|
|
409
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
410
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
411
|
+
string
|
|
412
|
+
</div>
|
|
413
|
+
</TabItem>
|
|
414
|
+
</SchemaTabs>
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
</details>
|
|
418
|
+
</SchemaItem>;
|
|
419
|
+
",
|
|
420
|
+
]
|
|
421
|
+
`;
|
|
422
|
+
|
|
423
|
+
exports[`createNodes anyOf should render primitives within anyOf 1`] = `
|
|
424
|
+
Array [
|
|
425
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
426
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
427
|
+
<summary style={{}}>
|
|
428
|
+
<span className={\\"openapi-schema__container\\"}>
|
|
429
|
+
<strong className={\\"openapi-schema__property\\"}>oneOfProperty</strong>
|
|
430
|
+
<span className={\\"openapi-schema__name\\"}>object</span>
|
|
431
|
+
</span>
|
|
432
|
+
</summary>
|
|
433
|
+
<div style={{ marginLeft: \\"1rem\\" }}>
|
|
434
|
+
<div>
|
|
435
|
+
<span className={\\"badge badge--info\\"} style={{ marginBottom: \\"1rem\\" }}>
|
|
436
|
+
anyOf
|
|
437
|
+
</span>
|
|
438
|
+
<SchemaTabs>
|
|
439
|
+
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
440
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
441
|
+
integer
|
|
442
|
+
</div>
|
|
443
|
+
</TabItem>
|
|
444
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
445
|
+
<div style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}>
|
|
446
|
+
boolean
|
|
447
|
+
</div>
|
|
448
|
+
</TabItem>
|
|
449
|
+
</SchemaTabs>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
</details>
|
|
453
|
+
</SchemaItem>;
|
|
454
|
+
",
|
|
455
|
+
]
|
|
456
|
+
`;
|
|
457
|
+
|
|
371
458
|
exports[`createNodes discriminator should handle basic discriminator with mapping 1`] = `
|
|
372
459
|
Array [
|
|
373
460
|
"<div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import { create } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createCallbackMethodEndpoint(method: String, path: String) {
|
|
11
|
+
return [
|
|
12
|
+
create("MethodEndpoint", {
|
|
13
|
+
method: method,
|
|
14
|
+
path: path,
|
|
15
|
+
context: "callback",
|
|
16
|
+
}),
|
|
17
|
+
"\n\n",
|
|
18
|
+
];
|
|
19
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
+
import { createCallbackMethodEndpoint } from "./createCallbackMethodEndpoint";
|
|
8
9
|
import { createDescription } from "./createDescription";
|
|
9
|
-
import { createMethodEndpoint } from "./createMethodEndpoint";
|
|
10
10
|
import { createRequestBodyDetails } from "./createRequestBodyDetails";
|
|
11
11
|
import { createStatusCodes } from "./createStatusCodes";
|
|
12
12
|
import { create } from "./utils";
|
|
@@ -78,7 +78,7 @@ export function createCallbacks({ callbacks }: Props) {
|
|
|
78
78
|
label: `${method.toUpperCase()} ${name}`,
|
|
79
79
|
value: `${method}-${name}`,
|
|
80
80
|
children: [
|
|
81
|
-
|
|
81
|
+
createCallbackMethodEndpoint(method, path),
|
|
82
82
|
// TODO: add `deprecation notice` when markdown support is added
|
|
83
83
|
createDescription(description),
|
|
84
84
|
createRequestBodyDetails({
|
|
@@ -8,5 +8,12 @@
|
|
|
8
8
|
import { create } from "./utils";
|
|
9
9
|
|
|
10
10
|
export function createMethodEndpoint(method: String, path: String) {
|
|
11
|
-
return [
|
|
11
|
+
return [
|
|
12
|
+
create("MethodEndpoint", {
|
|
13
|
+
method: method,
|
|
14
|
+
path: path,
|
|
15
|
+
context: "endpoint",
|
|
16
|
+
}),
|
|
17
|
+
"\n\n",
|
|
18
|
+
];
|
|
12
19
|
}
|
|
@@ -246,6 +246,70 @@ describe("createNodes", () => {
|
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
+
describe("anyOf", () => {
|
|
250
|
+
it("should render primitives within anyOf", async () => {
|
|
251
|
+
const schema: SchemaObject = {
|
|
252
|
+
type: "object",
|
|
253
|
+
properties: {
|
|
254
|
+
oneOfProperty: {
|
|
255
|
+
anyOf: [
|
|
256
|
+
{
|
|
257
|
+
type: "integer",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
type: "boolean",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
title: "One of int or bool",
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
expect(
|
|
269
|
+
await Promise.all(
|
|
270
|
+
createNodes(schema, "response").map(
|
|
271
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
272
|
+
)
|
|
273
|
+
)
|
|
274
|
+
).toMatchSnapshot();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("should render oneOf within anyOf", async () => {
|
|
278
|
+
const schema: SchemaObject = {
|
|
279
|
+
type: "object",
|
|
280
|
+
properties: {
|
|
281
|
+
oneOfProperty: {
|
|
282
|
+
anyOf: [
|
|
283
|
+
{
|
|
284
|
+
oneOf: [
|
|
285
|
+
{
|
|
286
|
+
type: "integer",
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: "boolean",
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
title: "An int or a bool",
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
type: "string",
|
|
296
|
+
},
|
|
297
|
+
],
|
|
298
|
+
title: "One of int or bool, or a string",
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
expect(
|
|
304
|
+
await Promise.all(
|
|
305
|
+
createNodes(schema, "response").map(
|
|
306
|
+
async (md: any) => await prettier.format(md, { parser: "babel" })
|
|
307
|
+
)
|
|
308
|
+
)
|
|
309
|
+
).toMatchSnapshot();
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
|
|
249
313
|
describe("allOf", () => {
|
|
250
314
|
it("should render same-level properties with allOf", async () => {
|
|
251
315
|
const schema: SchemaObject = {
|
|
@@ -104,6 +104,11 @@ function createAnyOneOf(schema: SchemaObject): any {
|
|
|
104
104
|
delete anyOneSchema.allOf;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
if (anyOneSchema.oneOf !== undefined) {
|
|
108
|
+
anyOneChildren.push(createNodes(anyOneSchema, SCHEMA_TYPE));
|
|
109
|
+
delete anyOneSchema.oneOf;
|
|
110
|
+
}
|
|
111
|
+
|
|
107
112
|
if (anyOneSchema.items !== undefined) {
|
|
108
113
|
anyOneChildren.push(createItems(anyOneSchema));
|
|
109
114
|
delete anyOneSchema.items;
|