docusaurus-plugin-openapi-docs 0.0.0-619 → 0.0.0-684
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 +3 -3
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +16 -0
- package/lib/markdown/createDeprecationNotice.js +1 -1
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +14 -0
- package/lib/markdown/createParamsDetails.js +3 -1
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +13 -0
- package/lib/markdown/createRequestSchema.js +19 -15
- package/lib/markdown/createResponseSchema.js +7 -7
- package/lib/markdown/createSchema.js +97 -77
- package/lib/markdown/createSchema.test.d.ts +1 -0
- package/lib/markdown/createSchema.test.js +73 -0
- package/lib/markdown/createStatusCodes.js +38 -35
- package/lib/markdown/index.d.ts +1 -1
- package/lib/markdown/index.js +15 -6
- package/lib/openapi/openapi.js +29 -13
- package/lib/openapi/openapi.test.js +1 -0
- package/lib/options.js +1 -2
- package/lib/sidebars/index.js +2 -2
- package/lib/types.d.ts +3 -1
- package/package.json +8 -16
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +98 -0
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createDeprecationNotice.ts +1 -1
- package/src/markdown/createHeading.ts +18 -0
- package/src/markdown/createMethodEndpoint.ts +12 -0
- package/src/markdown/createParamsDetails.ts +3 -1
- package/src/markdown/createRequestHeader.ts +10 -0
- package/src/markdown/createRequestSchema.ts +20 -15
- package/src/markdown/createResponseSchema.ts +8 -7
- package/src/markdown/createSchema.test.ts +56 -0
- package/src/markdown/createSchema.ts +106 -83
- package/src/markdown/createStatusCodes.ts +38 -35
- package/src/markdown/index.ts +17 -5
- package/src/openapi/openapi.test.ts +1 -0
- package/src/openapi/openapi.ts +25 -4
- package/src/options.ts +1 -2
- package/src/sidebars/index.ts +2 -2
- package/src/types.ts +3 -1
package/lib/markdown/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ApiPageMetadata, InfoPageMetadata, TagPageMetadata } from "../types";
|
|
2
|
-
export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, extensions, parameters, requestBody, responses, }, frontMatter, }: ApiPageMetadata): string;
|
|
2
|
+
export declare function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, }, infoPath, frontMatter, }: ApiPageMetadata): string;
|
|
3
3
|
export declare function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }: InfoPageMetadata): string;
|
|
4
4
|
export declare function createTagPageMD({ tag: { description } }: TagPageMetadata): string;
|
package/lib/markdown/index.js
CHANGED
|
@@ -8,39 +8,48 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.createTagPageMD = exports.createInfoPageMD = exports.createApiPageMD = void 0;
|
|
10
10
|
const createAuthentication_1 = require("./createAuthentication");
|
|
11
|
+
const createAuthorization_1 = require("./createAuthorization");
|
|
11
12
|
const createContactInfo_1 = require("./createContactInfo");
|
|
12
13
|
const createDeprecationNotice_1 = require("./createDeprecationNotice");
|
|
13
14
|
const createDescription_1 = require("./createDescription");
|
|
14
15
|
const createDownload_1 = require("./createDownload");
|
|
16
|
+
const createHeading_1 = require("./createHeading");
|
|
15
17
|
const createLicense_1 = require("./createLicense");
|
|
16
18
|
const createLogo_1 = require("./createLogo");
|
|
19
|
+
const createMethodEndpoint_1 = require("./createMethodEndpoint");
|
|
17
20
|
const createParamsDetails_1 = require("./createParamsDetails");
|
|
18
21
|
const createRequestBodyDetails_1 = require("./createRequestBodyDetails");
|
|
22
|
+
const createRequestHeader_1 = require("./createRequestHeader");
|
|
19
23
|
const createStatusCodes_1 = require("./createStatusCodes");
|
|
20
24
|
const createTermsOfService_1 = require("./createTermsOfService");
|
|
21
25
|
const createVendorExtensions_1 = require("./createVendorExtensions");
|
|
22
26
|
const createVersionBadge_1 = require("./createVersionBadge");
|
|
23
27
|
const utils_1 = require("./utils");
|
|
24
|
-
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, extensions, parameters, requestBody, responses, }, frontMatter, }) {
|
|
28
|
+
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, method, path, extensions, parameters, requestBody, responses, }, infoPath, frontMatter, }) {
|
|
25
29
|
return (0, utils_1.render)([
|
|
26
30
|
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
31
|
+
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
32
|
+
`import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
|
|
33
|
+
`import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";\n`,
|
|
27
34
|
`import MimeTabs from "@theme/MimeTabs";\n`,
|
|
28
35
|
`import ParamsItem from "@theme/ParamsItem";\n`,
|
|
29
36
|
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
30
37
|
`import SchemaItem from "@theme/SchemaItem";\n`,
|
|
31
38
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
32
|
-
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
33
39
|
`import TabItem from "@theme/TabItem";\n\n`,
|
|
34
|
-
|
|
40
|
+
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
41
|
+
(0, createMethodEndpoint_1.createMethodEndpoint)(method, path),
|
|
42
|
+
infoPath && (0, createAuthorization_1.createAuthorization)(infoPath),
|
|
35
43
|
frontMatter.show_extensions && (0, createVendorExtensions_1.createVendorExtensions)(extensions),
|
|
36
44
|
(0, createDeprecationNotice_1.createDeprecationNotice)({ deprecated, description: deprecatedDescription }),
|
|
37
45
|
(0, createDescription_1.createDescription)(description),
|
|
46
|
+
(0, createRequestHeader_1.createRequestHeader)("Request"),
|
|
38
47
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "path" }),
|
|
39
48
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "query" }),
|
|
40
49
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "header" }),
|
|
41
50
|
(0, createParamsDetails_1.createParamsDetails)({ parameters, type: "cookie" }),
|
|
42
51
|
(0, createRequestBodyDetails_1.createRequestBodyDetails)({
|
|
43
|
-
title: "
|
|
52
|
+
title: "Body",
|
|
44
53
|
body: requestBody,
|
|
45
54
|
}),
|
|
46
55
|
(0, createStatusCodes_1.createStatusCodes)({ responses }),
|
|
@@ -52,10 +61,10 @@ function createInfoPageMD({ info: { title, version, description, contact, licens
|
|
|
52
61
|
`import ApiLogo from "@theme/ApiLogo";\n`,
|
|
53
62
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
54
63
|
`import TabItem from "@theme/TabItem";\n`,
|
|
55
|
-
`import Export from "@theme/
|
|
64
|
+
`import Export from "@theme/ApiExplorer/Export";\n\n`,
|
|
56
65
|
(0, createVersionBadge_1.createVersionBadge)(version),
|
|
57
66
|
(0, createDownload_1.createDownload)(downloadUrl),
|
|
58
|
-
|
|
67
|
+
(0, createHeading_1.createHeading)(title.replace(utils_1.lessThan, "<").replace(utils_1.greaterThan, ">")),
|
|
59
68
|
(0, createLogo_1.createLogo)(logo, darkLogo),
|
|
60
69
|
(0, createDescription_1.createDescription)(description),
|
|
61
70
|
(0, createAuthentication_1.createAuthentication)(securitySchemes),
|
package/lib/openapi/openapi.js
CHANGED
|
@@ -61,7 +61,7 @@ async function createPostmanCollection(openapiData) {
|
|
|
61
61
|
return await jsonToCollection(data);
|
|
62
62
|
}
|
|
63
63
|
function createItems(openapiData, options, sidebarOptions) {
|
|
64
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0
|
|
64
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
|
|
65
65
|
// TODO: Find a better way to handle this
|
|
66
66
|
let items = [];
|
|
67
67
|
const infoIdSpaces = openapiData.info.title.replace(" ", "-").toLowerCase();
|
|
@@ -132,12 +132,20 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
let jsonRequestBodyExample;
|
|
135
|
-
const
|
|
135
|
+
const content = (_m = operationObject.requestBody) === null || _m === void 0 ? void 0 : _m.content;
|
|
136
|
+
let body;
|
|
137
|
+
for (let key in content) {
|
|
138
|
+
if (key.toLowerCase() === "application/json" ||
|
|
139
|
+
key.toLowerCase() === "application/json; charset=utf-8") {
|
|
140
|
+
body = content[key];
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
136
144
|
if (body === null || body === void 0 ? void 0 : body.schema) {
|
|
137
145
|
jsonRequestBodyExample = (0, createRequestExample_1.sampleRequestFromSchema)(body.schema);
|
|
138
146
|
}
|
|
139
147
|
// Handle vendor JSON media types
|
|
140
|
-
const bodyContent = (
|
|
148
|
+
const bodyContent = (_o = operationObject.requestBody) === null || _o === void 0 ? void 0 : _o.content;
|
|
141
149
|
if (bodyContent) {
|
|
142
150
|
const firstBodyContentKey = Object.keys(bodyContent)[0];
|
|
143
151
|
if (firstBodyContentKey.endsWith("+json")) {
|
|
@@ -204,15 +212,15 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
204
212
|
}
|
|
205
213
|
}
|
|
206
214
|
// Gather x-webhooks endpoints
|
|
207
|
-
for (let [path, pathObject] of Object.entries((
|
|
215
|
+
for (let [path, pathObject] of Object.entries((_p = openapiData["x-webhooks"]) !== null && _p !== void 0 ? _p : {})) {
|
|
208
216
|
path = "webhook";
|
|
209
217
|
const { $ref, description, parameters, servers, summary, ...rest } = pathObject;
|
|
210
218
|
for (let [method, operationObject] of Object.entries({ ...rest })) {
|
|
211
219
|
method = "event";
|
|
212
|
-
const title = (
|
|
220
|
+
const title = (_r = (_q = operationObject.summary) !== null && _q !== void 0 ? _q : operationObject.operationId) !== null && _r !== void 0 ? _r : "Missing summary";
|
|
213
221
|
if (operationObject.description === undefined) {
|
|
214
222
|
operationObject.description =
|
|
215
|
-
(
|
|
223
|
+
(_t = (_s = operationObject.summary) !== null && _s !== void 0 ? _s : operationObject.operationId) !== null && _t !== void 0 ? _t : "";
|
|
216
224
|
}
|
|
217
225
|
const baseId = operationObject.operationId
|
|
218
226
|
? (0, kebabCase_1.default)(operationObject.operationId)
|
|
@@ -224,10 +232,10 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
224
232
|
extensions.push({ key, value });
|
|
225
233
|
}
|
|
226
234
|
}
|
|
227
|
-
const servers = (
|
|
228
|
-
const security = (
|
|
235
|
+
const servers = (_v = (_u = operationObject.servers) !== null && _u !== void 0 ? _u : pathObject.servers) !== null && _v !== void 0 ? _v : openapiData.servers;
|
|
236
|
+
const security = (_w = operationObject.security) !== null && _w !== void 0 ? _w : openapiData.security;
|
|
229
237
|
// Add security schemes so we know how to handle security.
|
|
230
|
-
const securitySchemes = (
|
|
238
|
+
const securitySchemes = (_x = openapiData.components) === null || _x === void 0 ? void 0 : _x.securitySchemes;
|
|
231
239
|
// Make sure schemes are lowercase. See: https://github.com/cloud-annotations/docusaurus-plugin-openapi/issues/79
|
|
232
240
|
if (securitySchemes) {
|
|
233
241
|
for (let securityScheme of Object.values(securitySchemes)) {
|
|
@@ -237,12 +245,20 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
237
245
|
}
|
|
238
246
|
}
|
|
239
247
|
let jsonRequestBodyExample;
|
|
240
|
-
const
|
|
248
|
+
const content = (_y = operationObject.requestBody) === null || _y === void 0 ? void 0 : _y.content;
|
|
249
|
+
let body;
|
|
250
|
+
for (let key in content) {
|
|
251
|
+
if (key.toLowerCase() === "application/json" ||
|
|
252
|
+
key.toLowerCase() === "application/json; charset=utf-8") {
|
|
253
|
+
body = content[key];
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
241
257
|
if (body === null || body === void 0 ? void 0 : body.schema) {
|
|
242
258
|
jsonRequestBodyExample = (0, createRequestExample_1.sampleRequestFromSchema)(body.schema);
|
|
243
259
|
}
|
|
244
260
|
// Handle vendor JSON media types
|
|
245
|
-
const bodyContent = (
|
|
261
|
+
const bodyContent = (_z = operationObject.requestBody) === null || _z === void 0 ? void 0 : _z.content;
|
|
246
262
|
if (bodyContent) {
|
|
247
263
|
const firstBodyContentKey = Object.keys(bodyContent)[0];
|
|
248
264
|
if (firstBodyContentKey.endsWith("+json")) {
|
|
@@ -310,7 +326,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
310
326
|
}
|
|
311
327
|
if ((sidebarOptions === null || sidebarOptions === void 0 ? void 0 : sidebarOptions.categoryLinkSource) === "tag") {
|
|
312
328
|
// Get global tags
|
|
313
|
-
const tags = (
|
|
329
|
+
const tags = (_0 = openapiData.tags) !== null && _0 !== void 0 ? _0 : [];
|
|
314
330
|
// Get operation tags
|
|
315
331
|
const apiItems = items.filter((item) => {
|
|
316
332
|
return item.type === "api";
|
|
@@ -357,7 +373,7 @@ function bindCollectionToApiItems(items, postmanCollection) {
|
|
|
357
373
|
const method = item.request.method.toLowerCase();
|
|
358
374
|
const path = item.request.url
|
|
359
375
|
.getPath({ unresolved: true }) // unresolved returns "/:variableName" instead of "/<type>"
|
|
360
|
-
.replace(
|
|
376
|
+
.replace(/(?<![a-z0-9-_]+):([a-z0-9-_]+)/gi, "{$1}"); // replace "/:variableName" with "/{variableName}"
|
|
361
377
|
const apiItem = items.find((item) => {
|
|
362
378
|
if (item.type === "info" || item.type === "tag") {
|
|
363
379
|
return false;
|
|
@@ -10,6 +10,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
14
|
const utils_1 = require("@docusaurus/utils");
|
|
14
15
|
const _1 = require(".");
|
|
15
16
|
// npx jest packages/docusaurus-plugin-openapi/src/openapi/openapi.test.ts --watch
|
package/lib/options.js
CHANGED
|
@@ -10,8 +10,7 @@ exports.OptionsSchema = void 0;
|
|
|
10
10
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
11
|
const sidebarOptions = utils_validation_1.Joi.object({
|
|
12
12
|
groupPathsBy: utils_validation_1.Joi.string().valid("tag"),
|
|
13
|
-
|
|
14
|
-
categoryLinkSource: utils_validation_1.Joi.string().valid("tag", "info", "none"),
|
|
13
|
+
categoryLinkSource: utils_validation_1.Joi.string().valid("tag", "info", "auto"),
|
|
15
14
|
customProps: utils_validation_1.Joi.object(),
|
|
16
15
|
sidebarCollapsible: utils_validation_1.Joi.boolean(),
|
|
17
16
|
sidebarCollapsed: utils_validation_1.Joi.boolean(),
|
package/lib/sidebars/index.js
CHANGED
|
@@ -90,6 +90,7 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
90
90
|
};
|
|
91
91
|
});
|
|
92
92
|
// TODO: perhaps move this into a getLinkConfig() function
|
|
93
|
+
// Default to no link config (spindowns only)
|
|
93
94
|
let linkConfig = undefined;
|
|
94
95
|
if (taggedInfoObject !== undefined && categoryLinkSource === "info") {
|
|
95
96
|
linkConfig = {
|
|
@@ -107,8 +108,7 @@ function groupByTags(items, sidebarOptions, options, tags, docPath) {
|
|
|
107
108
|
id: basePath === "" || undefined ? `${tagId}` : `${basePath}/${tagId}`,
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
|
|
111
|
-
if (categoryLinkSource === undefined) {
|
|
111
|
+
if (categoryLinkSource === "auto") {
|
|
112
112
|
linkConfig = {
|
|
113
113
|
type: "generated-index",
|
|
114
114
|
title: tag,
|
package/lib/types.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface MarkdownGenerator {
|
|
|
32
32
|
}
|
|
33
33
|
export interface SidebarOptions {
|
|
34
34
|
groupPathsBy?: string;
|
|
35
|
-
categoryLinkSource?:
|
|
35
|
+
categoryLinkSource?: "info" | "tag" | "auto";
|
|
36
36
|
customProps?: {
|
|
37
37
|
[key: string]: unknown;
|
|
38
38
|
};
|
|
@@ -66,6 +66,8 @@ export interface ApiMetadataBase {
|
|
|
66
66
|
permalink: string;
|
|
67
67
|
sidebarPosition?: number;
|
|
68
68
|
frontMatter: Record<string, unknown>;
|
|
69
|
+
method?: string;
|
|
70
|
+
path?: string;
|
|
69
71
|
}
|
|
70
72
|
export interface ApiPageMetadata extends ApiMetadataBase {
|
|
71
73
|
json?: string;
|
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-684",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -28,45 +28,37 @@
|
|
|
28
28
|
"watch": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@docusaurus/
|
|
32
|
-
"@docusaurus/types": ">=2.0.1 <2.3.0",
|
|
31
|
+
"@docusaurus/types": ">=2.4.1 <=2.4.3",
|
|
33
32
|
"@types/fs-extra": "^9.0.13",
|
|
34
|
-
"@types/js-yaml": "^4.0.5",
|
|
35
33
|
"@types/json-pointer": "^1.0.31",
|
|
36
34
|
"@types/json-schema": "^7.0.9",
|
|
37
35
|
"@types/lodash": "^4.14.176",
|
|
38
|
-
"@types/mustache": "^4.1.2"
|
|
39
|
-
"utility-types": "^3.10.0"
|
|
36
|
+
"@types/mustache": "^4.1.2"
|
|
40
37
|
},
|
|
41
38
|
"dependencies": {
|
|
42
39
|
"@apidevtools/json-schema-ref-parser": "^10.1.0",
|
|
43
|
-
"@docusaurus/
|
|
44
|
-
"@docusaurus/
|
|
45
|
-
"@docusaurus/utils": ">=2.
|
|
46
|
-
"@docusaurus/utils-validation": ">=2.0.1 <2.3.0",
|
|
40
|
+
"@docusaurus/plugin-content-docs": ">=2.4.1 <=2.4.3",
|
|
41
|
+
"@docusaurus/utils": ">=2.4.1 <=2.4.3",
|
|
42
|
+
"@docusaurus/utils-validation": ">=2.4.1 <=2.4.3",
|
|
47
43
|
"@paloaltonetworks/openapi-to-postmanv2": "3.1.0-hotfix.1",
|
|
48
44
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
49
45
|
"@redocly/openapi-core": "^1.0.0-beta.125",
|
|
50
46
|
"chalk": "^4.1.2",
|
|
51
47
|
"clsx": "^1.1.1",
|
|
52
48
|
"fs-extra": "^9.0.1",
|
|
53
|
-
"js-yaml": "^4.1.0",
|
|
54
49
|
"json-pointer": "^0.6.2",
|
|
55
|
-
"json-refs": "^3.0.15",
|
|
56
50
|
"json-schema-merge-allof": "^0.8.1",
|
|
57
51
|
"lodash": "^4.17.20",
|
|
58
52
|
"mustache": "^4.2.0",
|
|
59
53
|
"slugify": "^1.6.5",
|
|
60
54
|
"swagger2openapi": "^7.0.8",
|
|
61
|
-
"url-template": "^3.0.0",
|
|
62
|
-
"webpack": "^5.61.0",
|
|
63
55
|
"xml-formatter": "^2.6.1"
|
|
64
56
|
},
|
|
65
57
|
"peerDependencies": {
|
|
66
|
-
"react": "^16.8.4 || ^17.0.0"
|
|
58
|
+
"react": "^16.8.4 || ^17.0.0 || ^18.0.0"
|
|
67
59
|
},
|
|
68
60
|
"engines": {
|
|
69
61
|
"node": ">=14"
|
|
70
62
|
},
|
|
71
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "41e64c25b3d3fe78e1ccc9617048c8cd4a4c4019"
|
|
72
64
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`createNodes should create readable MODs for oneOf primitive properties 1`] = `
|
|
4
|
+
Array [
|
|
5
|
+
"<SchemaItem collapsible={true} className={\\"schemaItem\\"}>
|
|
6
|
+
<details style={{}} className={\\"openapi-markdown__details\\"}>
|
|
7
|
+
<summary style={{}}>
|
|
8
|
+
<strong>oneOfProperty</strong>
|
|
9
|
+
<span style={{ opacity: \\"0.6\\" }}> object</span>
|
|
10
|
+
</summary>
|
|
11
|
+
<div style={{ marginLeft: \\"1rem\\" }}></div>
|
|
12
|
+
<div>
|
|
13
|
+
<span className={\\"badge badge--info\\"}>oneOf</span>
|
|
14
|
+
<SchemaTabs>
|
|
15
|
+
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
|
|
16
|
+
<SchemaItem
|
|
17
|
+
collapsible={false}
|
|
18
|
+
name={\\"noseLength\\"}
|
|
19
|
+
required={true}
|
|
20
|
+
schemaName={\\"number\\"}
|
|
21
|
+
qualifierMessage={undefined}
|
|
22
|
+
schema={{ type: \\"number\\" }}
|
|
23
|
+
></SchemaItem>
|
|
24
|
+
</TabItem>
|
|
25
|
+
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
|
|
26
|
+
<li>
|
|
27
|
+
<div
|
|
28
|
+
style={{
|
|
29
|
+
fontSize: \\"var(--ifm-code-font-size)\\",
|
|
30
|
+
opacity: \\"0.6\\",
|
|
31
|
+
marginLeft: \\"-.5rem\\",
|
|
32
|
+
paddingBottom: \\".5rem\\",
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
Array [
|
|
36
|
+
</div>
|
|
37
|
+
</li>
|
|
38
|
+
<div
|
|
39
|
+
style={{
|
|
40
|
+
marginTop: \\".5rem\\",
|
|
41
|
+
marginBottom: \\".5rem\\",
|
|
42
|
+
marginLeft: \\"1rem\\",
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
string
|
|
46
|
+
</div>
|
|
47
|
+
<li>
|
|
48
|
+
<div
|
|
49
|
+
style={{
|
|
50
|
+
fontSize: \\"var(--ifm-code-font-size)\\",
|
|
51
|
+
opacity: \\"0.6\\",
|
|
52
|
+
marginLeft: \\"-.5rem\\",
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
]
|
|
56
|
+
</div>
|
|
57
|
+
</li>
|
|
58
|
+
</TabItem>
|
|
59
|
+
<TabItem label={\\"MOD3\\"} value={\\"2-item-properties\\"}>
|
|
60
|
+
<div
|
|
61
|
+
style={{
|
|
62
|
+
marginTop: \\".5rem\\",
|
|
63
|
+
marginBottom: \\".5rem\\",
|
|
64
|
+
marginLeft: \\"1rem\\",
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
boolean
|
|
68
|
+
</div>
|
|
69
|
+
</TabItem>
|
|
70
|
+
<TabItem label={\\"MOD4\\"} value={\\"3-item-properties\\"}>
|
|
71
|
+
<div
|
|
72
|
+
style={{
|
|
73
|
+
marginTop: \\".5rem\\",
|
|
74
|
+
marginBottom: \\".5rem\\",
|
|
75
|
+
marginLeft: \\"1rem\\",
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
number
|
|
79
|
+
</div>
|
|
80
|
+
</TabItem>
|
|
81
|
+
<TabItem label={\\"MOD5\\"} value={\\"4-item-properties\\"}>
|
|
82
|
+
<div
|
|
83
|
+
style={{
|
|
84
|
+
marginTop: \\".5rem\\",
|
|
85
|
+
marginBottom: \\".5rem\\",
|
|
86
|
+
marginLeft: \\"1rem\\",
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
string
|
|
90
|
+
</div>
|
|
91
|
+
</TabItem>
|
|
92
|
+
</SchemaTabs>
|
|
93
|
+
</div>
|
|
94
|
+
</details>
|
|
95
|
+
</SchemaItem>;
|
|
96
|
+
",
|
|
97
|
+
]
|
|
98
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 createAuthorization(infoPath: string) {
|
|
11
|
+
if (!infoPath) return undefined;
|
|
12
|
+
return [create("SecuritySchemes", { infoPath: infoPath }), "\n\n"];
|
|
13
|
+
}
|
|
@@ -24,7 +24,7 @@ export function createDeprecationNotice({
|
|
|
24
24
|
createAdmonition({
|
|
25
25
|
children:
|
|
26
26
|
description ??
|
|
27
|
-
"This endpoint has been deprecated and may be removed in future versions of the API.",
|
|
27
|
+
"This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
|
|
28
28
|
})
|
|
29
29
|
);
|
|
30
30
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 createHeading(heading: string) {
|
|
11
|
+
return [
|
|
12
|
+
create("h1", {
|
|
13
|
+
className: "openapi__heading",
|
|
14
|
+
children: `${heading}`,
|
|
15
|
+
}),
|
|
16
|
+
`\n\n`,
|
|
17
|
+
];
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 createMethodEndpoint(method: String, path: String) {
|
|
11
|
+
return [create("MethodEndpoint", { method: method, path: path }), "\n\n"];
|
|
12
|
+
}
|
|
@@ -25,13 +25,15 @@ export function createParamsDetails({ parameters, type }: Props) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
return createDetails({
|
|
28
|
+
className: "openapi-markdown__details",
|
|
28
29
|
"data-collapsed": false,
|
|
29
30
|
open: true,
|
|
30
31
|
style: { marginBottom: "1rem" },
|
|
31
32
|
children: [
|
|
32
33
|
createDetailsSummary({
|
|
33
34
|
children: [
|
|
34
|
-
create("
|
|
35
|
+
create("h3", {
|
|
36
|
+
className: "openapi-markdown__details-summary-header-params",
|
|
35
37
|
children: `${
|
|
36
38
|
type.charAt(0).toUpperCase() + type.slice(1)
|
|
37
39
|
} Parameters`,
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
export function createRequestHeader(header: string) {
|
|
9
|
+
return `## ${header}\n\n`;
|
|
10
|
+
}
|
|
@@ -39,6 +39,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
39
39
|
|
|
40
40
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
41
41
|
return create("MimeTabs", {
|
|
42
|
+
className: "openapi-tabs__mime",
|
|
42
43
|
schemaType: "request",
|
|
43
44
|
children: mimeTypes.map((mimeType) => {
|
|
44
45
|
const firstBody = body.content![mimeType].schema;
|
|
@@ -55,21 +56,23 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
55
56
|
value: `${mimeType}`,
|
|
56
57
|
children: [
|
|
57
58
|
createDetails({
|
|
59
|
+
className: "openapi-markdown__details mime",
|
|
58
60
|
"data-collapsed": false,
|
|
59
61
|
open: true,
|
|
60
62
|
...rest,
|
|
61
63
|
children: [
|
|
62
64
|
createDetailsSummary({
|
|
63
|
-
|
|
65
|
+
className: "openapi-markdown__details-summary-mime",
|
|
64
66
|
children: [
|
|
65
|
-
create("
|
|
67
|
+
create("h3", {
|
|
68
|
+
className:
|
|
69
|
+
"openapi-markdown__details-summary-header-body",
|
|
70
|
+
children: `${title}`,
|
|
71
|
+
}),
|
|
66
72
|
guard(body.required && body.required === true, () => [
|
|
67
|
-
create("
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
color: "var(--openapi-required)",
|
|
71
|
-
},
|
|
72
|
-
children: " required",
|
|
73
|
+
create("span", {
|
|
74
|
+
className: "openapi-schema__required",
|
|
75
|
+
children: "required",
|
|
73
76
|
}),
|
|
74
77
|
]),
|
|
75
78
|
],
|
|
@@ -112,20 +115,25 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
return create("MimeTabs", {
|
|
118
|
+
className: "openapi-tabs__mime",
|
|
115
119
|
children: [
|
|
116
120
|
create("TabItem", {
|
|
117
121
|
label: randomFirstKey,
|
|
118
122
|
value: `${randomFirstKey}-schema`,
|
|
119
123
|
children: [
|
|
120
124
|
createDetails({
|
|
125
|
+
className: "openapi-markdown__details mime",
|
|
121
126
|
"data-collapsed": false,
|
|
122
127
|
open: true,
|
|
123
128
|
...rest,
|
|
124
129
|
children: [
|
|
125
130
|
createDetailsSummary({
|
|
126
|
-
|
|
131
|
+
className: "openapi-markdown__details-summary-mime",
|
|
127
132
|
children: [
|
|
128
|
-
create("
|
|
133
|
+
create("h3", {
|
|
134
|
+
className: "openapi-markdown__details-summary-header-body",
|
|
135
|
+
children: `${title}`,
|
|
136
|
+
}),
|
|
129
137
|
guard(firstBody.type === "array", (format) =>
|
|
130
138
|
create("span", {
|
|
131
139
|
style: { opacity: "0.6" },
|
|
@@ -134,11 +142,8 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
134
142
|
),
|
|
135
143
|
guard(body.required, () => [
|
|
136
144
|
create("strong", {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
color: "var(--openapi-required)",
|
|
140
|
-
},
|
|
141
|
-
children: " required",
|
|
145
|
+
className: "openapi-schema__required",
|
|
146
|
+
children: "required",
|
|
142
147
|
}),
|
|
143
148
|
]),
|
|
144
149
|
],
|
|
@@ -44,6 +44,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
44
44
|
|
|
45
45
|
if (mimeTypes && mimeTypes.length) {
|
|
46
46
|
return create("MimeTabs", {
|
|
47
|
+
className: "openapi-tabs__mime",
|
|
47
48
|
schemaType: "response",
|
|
48
49
|
children: mimeTypes.map((mimeType: any) => {
|
|
49
50
|
const responseExamples = body.content![mimeType].examples;
|
|
@@ -70,6 +71,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
70
71
|
value: `${mimeType}`,
|
|
71
72
|
children: [
|
|
72
73
|
create("SchemaTabs", {
|
|
74
|
+
className: "openapi-tabs__schema",
|
|
73
75
|
// TODO: determine if we should persist this
|
|
74
76
|
// groupId: "schema-tabs",
|
|
75
77
|
children: [
|
|
@@ -79,23 +81,22 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
79
81
|
value: `${title}`,
|
|
80
82
|
children: [
|
|
81
83
|
createDetails({
|
|
84
|
+
className: "openapi-markdown__details response",
|
|
82
85
|
"data-collapsed": false,
|
|
83
86
|
open: true,
|
|
84
87
|
...rest,
|
|
85
88
|
children: [
|
|
86
89
|
createDetailsSummary({
|
|
87
|
-
|
|
90
|
+
className:
|
|
91
|
+
"openapi-markdown__details-summary-response",
|
|
88
92
|
children: [
|
|
89
93
|
create("strong", { children: `${title}` }),
|
|
90
94
|
guard(
|
|
91
95
|
body.required && body.required === true,
|
|
92
96
|
() => [
|
|
93
|
-
create("
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
color: "var(--openapi-required)",
|
|
97
|
-
},
|
|
98
|
-
children: " required",
|
|
97
|
+
create("span", {
|
|
98
|
+
className: "openapi-schema__required",
|
|
99
|
+
children: "required",
|
|
99
100
|
}),
|
|
100
101
|
]
|
|
101
102
|
),
|