docusaurus-plugin-openapi-docs 0.0.0-1000
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/LICENSE +21 -0
- package/README.md +361 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +709 -0
- package/lib/markdown/createArrayBracket.d.ts +2 -0
- package/lib/markdown/createArrayBracket.js +36 -0
- package/lib/markdown/createAuthentication.d.ts +2 -0
- package/lib/markdown/createAuthentication.js +171 -0
- package/lib/markdown/createAuthorization.d.ts +1 -0
- package/lib/markdown/createAuthorization.js +15 -0
- package/lib/markdown/createCallbackMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createCallbackMethodEndpoint.js +20 -0
- package/lib/markdown/createCallbacks.d.ts +6 -0
- package/lib/markdown/createCallbacks.js +77 -0
- package/lib/markdown/createContactInfo.d.ts +2 -0
- package/lib/markdown/createContactInfo.js +39 -0
- package/lib/markdown/createDeprecationNotice.d.ts +6 -0
- package/lib/markdown/createDeprecationNotice.js +20 -0
- package/lib/markdown/createDescription.d.ts +1 -0
- package/lib/markdown/createDescription.js +13 -0
- package/lib/markdown/createDetails.d.ts +2 -0
- package/lib/markdown/createDetails.js +17 -0
- package/lib/markdown/createDetailsSummary.d.ts +2 -0
- package/lib/markdown/createDetailsSummary.js +17 -0
- package/lib/markdown/createDownload.d.ts +1 -0
- package/lib/markdown/createDownload.js +16 -0
- package/lib/markdown/createHeading.d.ts +1 -0
- package/lib/markdown/createHeading.js +20 -0
- package/lib/markdown/createLicense.d.ts +2 -0
- package/lib/markdown/createLicense.js +32 -0
- package/lib/markdown/createLogo.d.ts +2 -0
- package/lib/markdown/createLogo.js +18 -0
- package/lib/markdown/createMethodEndpoint.d.ts +1 -0
- package/lib/markdown/createMethodEndpoint.js +20 -0
- package/lib/markdown/createParamsDetails.d.ts +6 -0
- package/lib/markdown/createParamsDetails.js +18 -0
- package/lib/markdown/createRequestBodyDetails.d.ts +13 -0
- package/lib/markdown/createRequestBodyDetails.js +13 -0
- package/lib/markdown/createRequestHeader.d.ts +1 -0
- package/lib/markdown/createRequestHeader.js +21 -0
- package/lib/markdown/createRequestSchema.d.ts +14 -0
- package/lib/markdown/createRequestSchema.js +20 -0
- package/lib/markdown/createResponseSchema.d.ts +14 -0
- package/lib/markdown/createResponseSchema.js +20 -0
- package/lib/markdown/createSchema.d.ts +9 -0
- package/lib/markdown/createSchema.js +668 -0
- package/lib/markdown/createSchema.test.d.ts +1 -0
- package/lib/markdown/createSchema.test.js +913 -0
- package/lib/markdown/createStatusCodes.d.ts +9 -0
- package/lib/markdown/createStatusCodes.js +63 -0
- package/lib/markdown/createTermsOfService.d.ts +1 -0
- package/lib/markdown/createTermsOfService.js +31 -0
- package/lib/markdown/createVendorExtensions.d.ts +1 -0
- package/lib/markdown/createVendorExtensions.js +24 -0
- package/lib/markdown/createVersionBadge.d.ts +1 -0
- package/lib/markdown/createVersionBadge.js +19 -0
- package/lib/markdown/index.d.ts +5 -0
- package/lib/markdown/index.js +92 -0
- package/lib/markdown/schema.d.ts +3 -0
- package/lib/markdown/schema.js +154 -0
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +181 -0
- package/lib/markdown/utils.d.ts +20 -0
- package/lib/markdown/utils.js +68 -0
- package/lib/openapi/createRequestExample.d.ts +2 -0
- package/lib/openapi/createRequestExample.js +191 -0
- package/lib/openapi/createResponseExample.d.ts +2 -0
- package/lib/openapi/createResponseExample.js +192 -0
- package/lib/openapi/index.d.ts +1 -0
- package/lib/openapi/index.js +12 -0
- package/lib/openapi/openapi.d.ts +12 -0
- package/lib/openapi/openapi.js +544 -0
- package/lib/openapi/openapi.test.d.ts +1 -0
- package/lib/openapi/openapi.test.js +33 -0
- package/lib/openapi/types.d.ts +354 -0
- package/lib/openapi/types.js +8 -0
- package/lib/openapi/utils/loadAndResolveSpec.d.ts +2 -0
- package/lib/openapi/utils/loadAndResolveSpec.js +153 -0
- package/lib/openapi/utils/services/OpenAPIParser.d.ts +52 -0
- package/lib/openapi/utils/services/OpenAPIParser.js +343 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.d.ts +100 -0
- package/lib/openapi/utils/services/RedocNormalizedOptions.js +170 -0
- package/lib/openapi/utils/types/index.d.ts +2 -0
- package/lib/openapi/utils/types/index.js +23 -0
- package/lib/openapi/utils/types/open-api.d.ts +305 -0
- package/lib/openapi/utils/types/open-api.js +8 -0
- package/lib/openapi/utils/types.d.ts +306 -0
- package/lib/openapi/utils/types.js +8 -0
- package/lib/openapi/utils/utils/JsonPointer.d.ts +51 -0
- package/lib/openapi/utils/utils/JsonPointer.js +95 -0
- package/lib/openapi/utils/utils/helpers.d.ts +43 -0
- package/lib/openapi/utils/utils/helpers.js +230 -0
- package/lib/openapi/utils/utils/index.d.ts +3 -0
- package/lib/openapi/utils/utils/index.js +25 -0
- package/lib/openapi/utils/utils/openapi.d.ts +40 -0
- package/lib/openapi/utils/utils/openapi.js +605 -0
- package/lib/options.d.ts +2 -0
- package/lib/options.js +69 -0
- package/lib/sidebars/index.d.ts +4 -0
- package/lib/sidebars/index.js +226 -0
- package/lib/sidebars/utils.d.ts +2 -0
- package/lib/sidebars/utils.js +30 -0
- package/lib/types.d.ts +135 -0
- package/lib/types.js +8 -0
- package/package.json +69 -0
- package/src/index.ts +945 -0
- package/src/markdown/__snapshots__/createSchema.test.ts.snap +1605 -0
- package/src/markdown/createArrayBracket.ts +35 -0
- package/src/markdown/createAuthentication.ts +201 -0
- package/src/markdown/createAuthorization.ts +13 -0
- package/src/markdown/createCallbackMethodEndpoint.ts +19 -0
- package/src/markdown/createCallbacks.ts +101 -0
- package/src/markdown/createContactInfo.ts +41 -0
- package/src/markdown/createDeprecationNotice.ts +31 -0
- package/src/markdown/createDescription.ts +12 -0
- package/src/markdown/createDetails.ts +16 -0
- package/src/markdown/createDetailsSummary.ts +16 -0
- package/src/markdown/createDownload.ts +15 -0
- package/src/markdown/createHeading.ts +23 -0
- package/src/markdown/createLicense.ts +34 -0
- package/src/markdown/createLogo.ts +21 -0
- package/src/markdown/createMethodEndpoint.ts +19 -0
- package/src/markdown/createParamsDetails.ts +22 -0
- package/src/markdown/createRequestBodyDetails.ts +24 -0
- package/src/markdown/createRequestHeader.ts +24 -0
- package/src/markdown/createRequestSchema.ts +32 -0
- package/src/markdown/createResponseSchema.ts +32 -0
- package/src/markdown/createSchema.test.ts +1075 -0
- package/src/markdown/createSchema.ts +862 -0
- package/src/markdown/createStatusCodes.ts +63 -0
- package/src/markdown/createTermsOfService.ts +30 -0
- package/src/markdown/createVendorExtensions.ts +22 -0
- package/src/markdown/createVersionBadge.ts +22 -0
- package/src/markdown/index.ts +144 -0
- package/src/markdown/schema.test.ts +208 -0
- package/src/markdown/schema.ts +185 -0
- package/src/markdown/utils.ts +89 -0
- package/src/openapi/__fixtures__/examples/openapi.yaml +49 -0
- package/src/openapi/createRequestExample.ts +235 -0
- package/src/openapi/createResponseExample.ts +238 -0
- package/src/openapi/index.ts +8 -0
- package/src/openapi/openapi.test.ts +40 -0
- package/src/openapi/openapi.ts +697 -0
- package/src/openapi/types.ts +455 -0
- package/src/openapi/utils/loadAndResolveSpec.ts +171 -0
- package/src/openapi/utils/services/OpenAPIParser.ts +434 -0
- package/src/openapi/utils/services/RedocNormalizedOptions.ts +330 -0
- package/src/openapi/utils/types/index.ts +10 -0
- package/src/openapi/utils/types/open-api.ts +303 -0
- package/src/openapi/utils/types.ts +303 -0
- package/src/openapi/utils/utils/JsonPointer.ts +99 -0
- package/src/openapi/utils/utils/helpers.ts +239 -0
- package/src/openapi/utils/utils/index.ts +11 -0
- package/src/openapi/utils/utils/openapi.ts +771 -0
- package/src/openapi-to-postmanv2.d.ts +10 -0
- package/src/options.ts +77 -0
- package/src/plugin-content-docs-types.d.ts +42 -0
- package/src/plugin-openapi.d.ts +87 -0
- package/src/postman-collection.d.ts +10 -0
- package/src/sidebars/index.ts +322 -0
- package/src/sidebars/utils.ts +29 -0
- package/src/types.ts +176 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,35 @@
|
|
|
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 createOpeningArrayBracket() {
|
|
11
|
+
return create("li", {
|
|
12
|
+
children: create("div", {
|
|
13
|
+
style: {
|
|
14
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
15
|
+
opacity: "0.6",
|
|
16
|
+
marginLeft: "-.5rem",
|
|
17
|
+
paddingBottom: ".5rem",
|
|
18
|
+
},
|
|
19
|
+
children: ["Array ["],
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createClosingArrayBracket() {
|
|
25
|
+
return create("li", {
|
|
26
|
+
children: create("div", {
|
|
27
|
+
style: {
|
|
28
|
+
fontSize: "var(--ifm-code-font-size)",
|
|
29
|
+
opacity: "0.6",
|
|
30
|
+
marginLeft: "-.5rem",
|
|
31
|
+
},
|
|
32
|
+
children: ["]"],
|
|
33
|
+
}),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
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 { createDescription } from "./createDescription";
|
|
9
|
+
import { create, guard } from "./utils";
|
|
10
|
+
import { OAuthFlowObject, SecuritySchemeObject } from "../openapi/types";
|
|
11
|
+
|
|
12
|
+
export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
13
|
+
if (!securitySchemes || !Object.keys(securitySchemes).length) return "";
|
|
14
|
+
|
|
15
|
+
const createAuthenticationTable = (securityScheme: any) => {
|
|
16
|
+
const { bearerFormat, flows, name, scheme, type, openIdConnectUrl } =
|
|
17
|
+
securityScheme;
|
|
18
|
+
|
|
19
|
+
const createSecuritySchemeTypeRow = () =>
|
|
20
|
+
create("tr", {
|
|
21
|
+
children: [
|
|
22
|
+
create("th", { children: "Security Scheme Type:" }),
|
|
23
|
+
create("td", { children: type }),
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const createOAuthFlowRows = () => {
|
|
28
|
+
const flowRows = Object.entries(flows).map(([flowType, flowObj]) => {
|
|
29
|
+
const { authorizationUrl, tokenUrl, refreshUrl, scopes } =
|
|
30
|
+
flowObj as OAuthFlowObject;
|
|
31
|
+
|
|
32
|
+
return create("tr", {
|
|
33
|
+
children: [
|
|
34
|
+
create("th", { children: `OAuth Flow (${flowType}):` }),
|
|
35
|
+
create("td", {
|
|
36
|
+
children: [
|
|
37
|
+
guard(tokenUrl, () =>
|
|
38
|
+
create("div", { children: `Token URL: ${tokenUrl}` })
|
|
39
|
+
),
|
|
40
|
+
guard(authorizationUrl, () =>
|
|
41
|
+
create("div", {
|
|
42
|
+
children: `Authorization URL: ${authorizationUrl}`,
|
|
43
|
+
})
|
|
44
|
+
),
|
|
45
|
+
guard(refreshUrl, () =>
|
|
46
|
+
create("div", { children: `Refresh URL: ${refreshUrl}` })
|
|
47
|
+
),
|
|
48
|
+
create("span", { children: "Scopes:" }),
|
|
49
|
+
create("ul", {
|
|
50
|
+
children: Object.entries(scopes).map(([scope, description]) =>
|
|
51
|
+
create("li", { children: `${scope}: ${description}` })
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
],
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return flowRows.join("");
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
switch (type) {
|
|
64
|
+
case "apiKey":
|
|
65
|
+
return create("div", {
|
|
66
|
+
children: [
|
|
67
|
+
create("table", {
|
|
68
|
+
children: create("tbody", {
|
|
69
|
+
children: [
|
|
70
|
+
createSecuritySchemeTypeRow(),
|
|
71
|
+
create("tr", {
|
|
72
|
+
children: [
|
|
73
|
+
create("th", { children: "Header parameter name:" }),
|
|
74
|
+
create("td", { children: name }),
|
|
75
|
+
],
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
78
|
+
}),
|
|
79
|
+
}),
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
case "http":
|
|
83
|
+
return create("div", {
|
|
84
|
+
children: [
|
|
85
|
+
create("table", {
|
|
86
|
+
children: create("tbody", {
|
|
87
|
+
children: [
|
|
88
|
+
createSecuritySchemeTypeRow(),
|
|
89
|
+
create("tr", {
|
|
90
|
+
children: [
|
|
91
|
+
create("th", { children: "HTTP Authorization Scheme:" }),
|
|
92
|
+
create("td", { children: scheme }),
|
|
93
|
+
],
|
|
94
|
+
}),
|
|
95
|
+
guard(bearerFormat, () =>
|
|
96
|
+
create("tr", {
|
|
97
|
+
children: [
|
|
98
|
+
create("th", { children: "Bearer format:" }),
|
|
99
|
+
create("td", { children: bearerFormat }),
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
),
|
|
103
|
+
],
|
|
104
|
+
}),
|
|
105
|
+
}),
|
|
106
|
+
],
|
|
107
|
+
});
|
|
108
|
+
case "oauth2":
|
|
109
|
+
return create("div", {
|
|
110
|
+
children: [
|
|
111
|
+
create("table", {
|
|
112
|
+
children: create("tbody", {
|
|
113
|
+
children: [
|
|
114
|
+
createSecuritySchemeTypeRow(),
|
|
115
|
+
createOAuthFlowRows(),
|
|
116
|
+
],
|
|
117
|
+
}),
|
|
118
|
+
}),
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
case "openIdConnect":
|
|
122
|
+
return create("div", {
|
|
123
|
+
children: [
|
|
124
|
+
create("table", {
|
|
125
|
+
children: create("tbody", {
|
|
126
|
+
children: [
|
|
127
|
+
createSecuritySchemeTypeRow(),
|
|
128
|
+
guard(openIdConnectUrl, () =>
|
|
129
|
+
create("tr", {
|
|
130
|
+
children: [
|
|
131
|
+
create("th", { children: "OpenID Connect URL:" }),
|
|
132
|
+
create("td", { children: openIdConnectUrl }),
|
|
133
|
+
],
|
|
134
|
+
})
|
|
135
|
+
),
|
|
136
|
+
],
|
|
137
|
+
}),
|
|
138
|
+
}),
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
default:
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const formatTabLabel = (key: string, type: string, scheme: string) => {
|
|
147
|
+
const formattedLabel = key
|
|
148
|
+
.replace(/(_|-)/g, " ")
|
|
149
|
+
.trim()
|
|
150
|
+
.replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
|
|
151
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
152
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
|
|
153
|
+
const isOAuth = type === "oauth2";
|
|
154
|
+
const isApiKey = type === "apiKey";
|
|
155
|
+
const isHttpBasic = type === "http" && scheme === "basic";
|
|
156
|
+
const isHttpBearer = type === "http" && scheme === "bearer";
|
|
157
|
+
const isOpenId = type === "openIdConnect";
|
|
158
|
+
|
|
159
|
+
if (isOAuth) return `OAuth 2.0: ${key}`;
|
|
160
|
+
if (isApiKey) return `API Key: ${key}`;
|
|
161
|
+
if (isHttpBasic) return "HTTP: Basic Auth";
|
|
162
|
+
if (isHttpBearer) return "HTTP: Bearer Auth";
|
|
163
|
+
if (isOpenId) return `OpenID Connect: ${key}`;
|
|
164
|
+
|
|
165
|
+
return formattedLabel;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return create("div", {
|
|
169
|
+
children: [
|
|
170
|
+
create(
|
|
171
|
+
"Heading",
|
|
172
|
+
{
|
|
173
|
+
children: "Authentication",
|
|
174
|
+
id: "authentication",
|
|
175
|
+
as: "h2",
|
|
176
|
+
className: "openapi-tabs__heading",
|
|
177
|
+
},
|
|
178
|
+
{ inline: true }
|
|
179
|
+
),
|
|
180
|
+
create("SchemaTabs", {
|
|
181
|
+
className: "openapi-tabs__security-schemes",
|
|
182
|
+
children: Object.entries(securitySchemes).map(
|
|
183
|
+
([schemeKey, schemeObj]) =>
|
|
184
|
+
create("TabItem", {
|
|
185
|
+
label: formatTabLabel(
|
|
186
|
+
schemeKey,
|
|
187
|
+
schemeObj.type,
|
|
188
|
+
schemeObj.scheme
|
|
189
|
+
),
|
|
190
|
+
value: `${schemeKey}`,
|
|
191
|
+
children: [
|
|
192
|
+
createDescription(schemeObj.description),
|
|
193
|
+
createAuthenticationTable(schemeObj),
|
|
194
|
+
],
|
|
195
|
+
})
|
|
196
|
+
),
|
|
197
|
+
}),
|
|
198
|
+
],
|
|
199
|
+
style: { marginBottom: "2rem" },
|
|
200
|
+
});
|
|
201
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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 { createCallbackMethodEndpoint } from "./createCallbackMethodEndpoint";
|
|
9
|
+
import { createDescription } from "./createDescription";
|
|
10
|
+
import { createRequestBodyDetails } from "./createRequestBodyDetails";
|
|
11
|
+
import { createStatusCodes } from "./createStatusCodes";
|
|
12
|
+
import { create } from "./utils";
|
|
13
|
+
import { MediaTypeObject } from "../openapi/types";
|
|
14
|
+
import { ApiItem } from "../types";
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
callbacks: ApiItem["callbacks"];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface RequestBodyProps {
|
|
21
|
+
title: string;
|
|
22
|
+
body: {
|
|
23
|
+
content?: {
|
|
24
|
+
[key: string]: MediaTypeObject;
|
|
25
|
+
};
|
|
26
|
+
description?: string;
|
|
27
|
+
required?: boolean;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createCallbacks({ callbacks }: Props) {
|
|
32
|
+
if (callbacks === undefined) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const callbacksNames = Object.keys(callbacks);
|
|
37
|
+
if (callbacksNames.length === 0) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return create("div", {
|
|
42
|
+
children: [
|
|
43
|
+
create("div", {
|
|
44
|
+
className: "openapi__divider",
|
|
45
|
+
}),
|
|
46
|
+
create(
|
|
47
|
+
"Heading",
|
|
48
|
+
{
|
|
49
|
+
children: "Callbacks",
|
|
50
|
+
id: "callbacks",
|
|
51
|
+
as: "h2",
|
|
52
|
+
className: "openapi-tabs__heading",
|
|
53
|
+
},
|
|
54
|
+
{ inline: true }
|
|
55
|
+
),
|
|
56
|
+
create("OperationTabs", {
|
|
57
|
+
className: "openapi-tabs__operation",
|
|
58
|
+
children: callbacksNames.flatMap((name) => {
|
|
59
|
+
const path = Object.keys(callbacks[name])[0];
|
|
60
|
+
const methods = new Map([
|
|
61
|
+
["delete", callbacks[name][path].delete],
|
|
62
|
+
["get", callbacks[name][path].get],
|
|
63
|
+
["head", callbacks[name][path].head],
|
|
64
|
+
["options", callbacks[name][path].options],
|
|
65
|
+
["patch", callbacks[name][path].patch],
|
|
66
|
+
["post", callbacks[name][path].post],
|
|
67
|
+
["put", callbacks[name][path].put],
|
|
68
|
+
["trace", callbacks[name][path].trace],
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
return Array.from(methods).flatMap(([method, operationObject]) => {
|
|
72
|
+
if (!operationObject) return [];
|
|
73
|
+
|
|
74
|
+
const { description, requestBody, responses } = operationObject;
|
|
75
|
+
|
|
76
|
+
return [
|
|
77
|
+
create("TabItem", {
|
|
78
|
+
label: `${method.toUpperCase()} ${name}`,
|
|
79
|
+
value: `${method}-${name}`,
|
|
80
|
+
children: [
|
|
81
|
+
createCallbackMethodEndpoint(method, path),
|
|
82
|
+
// TODO: add `deprecation notice` when markdown support is added
|
|
83
|
+
createDescription(description),
|
|
84
|
+
createRequestBodyDetails({
|
|
85
|
+
title: "Body",
|
|
86
|
+
body: requestBody,
|
|
87
|
+
} as RequestBodyProps),
|
|
88
|
+
createStatusCodes({
|
|
89
|
+
id: "callbacks-responses",
|
|
90
|
+
label: "Callbacks Responses",
|
|
91
|
+
responses,
|
|
92
|
+
}),
|
|
93
|
+
],
|
|
94
|
+
}),
|
|
95
|
+
];
|
|
96
|
+
});
|
|
97
|
+
}),
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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, guard } from "./utils";
|
|
9
|
+
import { ContactObject } from "../openapi/types";
|
|
10
|
+
|
|
11
|
+
export function createContactInfo(contact: ContactObject) {
|
|
12
|
+
if (!contact || !Object.keys(contact).length) return "";
|
|
13
|
+
const { name, url, email } = contact;
|
|
14
|
+
|
|
15
|
+
return create("div", {
|
|
16
|
+
style: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "column",
|
|
19
|
+
marginBottom: "var(--ifm-paragraph-margin-bottom)",
|
|
20
|
+
},
|
|
21
|
+
children: [
|
|
22
|
+
create("h3", {
|
|
23
|
+
style: {
|
|
24
|
+
marginBottom: "0.25rem",
|
|
25
|
+
},
|
|
26
|
+
children: "Contact",
|
|
27
|
+
}),
|
|
28
|
+
create("span", {
|
|
29
|
+
children: [
|
|
30
|
+
guard(name, () => `${name}: `),
|
|
31
|
+
guard(email, () => `[${email}](mailto:${email})`),
|
|
32
|
+
],
|
|
33
|
+
}),
|
|
34
|
+
guard(url, () =>
|
|
35
|
+
create("span", {
|
|
36
|
+
children: ["URL: ", `[${url}](${url})`],
|
|
37
|
+
})
|
|
38
|
+
),
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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 { clean, guard, Props, render } from "./utils";
|
|
9
|
+
|
|
10
|
+
function createAdmonition({ children }: Props) {
|
|
11
|
+
return `:::caution deprecated\n\n${render(children)}\n\n:::`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface DeprecationNoticeProps {
|
|
15
|
+
deprecated?: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function createDeprecationNotice({
|
|
20
|
+
deprecated,
|
|
21
|
+
description,
|
|
22
|
+
}: DeprecationNoticeProps) {
|
|
23
|
+
return guard(deprecated, () =>
|
|
24
|
+
createAdmonition({
|
|
25
|
+
children:
|
|
26
|
+
description && description.length > 0
|
|
27
|
+
? clean(description)
|
|
28
|
+
: "This endpoint has been deprecated and may be replaced or removed in future versions of the API.",
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -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 { clean } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createDescription(description: string | undefined) {
|
|
11
|
+
return `\n\n${clean(description)}\n\n`;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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, Props } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createDetails({ children, style, ...rest }: Props) {
|
|
11
|
+
return create("details", {
|
|
12
|
+
style: { ...style },
|
|
13
|
+
...rest,
|
|
14
|
+
children,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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, Props } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createDetailsSummary({ children, style, ...rest }: Props) {
|
|
11
|
+
return create("summary", {
|
|
12
|
+
style: { ...style },
|
|
13
|
+
...rest,
|
|
14
|
+
children,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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, guard } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createDownload(url: string | undefined) {
|
|
11
|
+
return guard(url, (url) => [
|
|
12
|
+
create("Export", { url: url, proxy: undefined }),
|
|
13
|
+
`\n\n`,
|
|
14
|
+
]);
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 { clean, create } from "./utils";
|
|
9
|
+
|
|
10
|
+
export function createHeading(heading: string) {
|
|
11
|
+
return [
|
|
12
|
+
create(
|
|
13
|
+
"Heading",
|
|
14
|
+
{
|
|
15
|
+
children: clean(heading),
|
|
16
|
+
as: "h1",
|
|
17
|
+
className: "openapi__heading",
|
|
18
|
+
},
|
|
19
|
+
{ inline: true }
|
|
20
|
+
),
|
|
21
|
+
`\n\n`,
|
|
22
|
+
];
|
|
23
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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, guard } from "./utils";
|
|
9
|
+
import { LicenseObject } from "../openapi/types";
|
|
10
|
+
|
|
11
|
+
export function createLicense(license: LicenseObject) {
|
|
12
|
+
if (!license || !Object.keys(license).length) return "";
|
|
13
|
+
const { name, url } = license;
|
|
14
|
+
|
|
15
|
+
return create("div", {
|
|
16
|
+
style: {
|
|
17
|
+
marginBottom: "var(--ifm-paragraph-margin-bottom)",
|
|
18
|
+
},
|
|
19
|
+
children: [
|
|
20
|
+
create("h3", {
|
|
21
|
+
style: {
|
|
22
|
+
marginBottom: "0.25rem",
|
|
23
|
+
},
|
|
24
|
+
children: "License",
|
|
25
|
+
}),
|
|
26
|
+
guard(url, () =>
|
|
27
|
+
create("a", {
|
|
28
|
+
href: url,
|
|
29
|
+
children: name ?? url,
|
|
30
|
+
})
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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, guard } from "./utils";
|
|
9
|
+
import { LogoObject } from "../openapi/types";
|
|
10
|
+
|
|
11
|
+
export function createLogo(
|
|
12
|
+
logo: LogoObject | undefined,
|
|
13
|
+
darkLogo: LogoObject | undefined
|
|
14
|
+
) {
|
|
15
|
+
return guard(logo || darkLogo, () => [
|
|
16
|
+
create("ApiLogo", {
|
|
17
|
+
logo: logo,
|
|
18
|
+
darkLogo: darkLogo,
|
|
19
|
+
}),
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
@@ -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 createMethodEndpoint(method: String, path: String) {
|
|
11
|
+
return [
|
|
12
|
+
create("MethodEndpoint", {
|
|
13
|
+
method: method,
|
|
14
|
+
path: path,
|
|
15
|
+
context: "endpoint",
|
|
16
|
+
}),
|
|
17
|
+
"\n\n",
|
|
18
|
+
];
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
import { ApiItem } from "../types";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
parameters: ApiItem["parameters"];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function createParamsDetails({ parameters }: Props) {
|
|
16
|
+
return [
|
|
17
|
+
create("ParamsDetails", {
|
|
18
|
+
parameters: parameters,
|
|
19
|
+
}),
|
|
20
|
+
"\n\n",
|
|
21
|
+
];
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 { createRequestSchema } from "./createRequestSchema";
|
|
9
|
+
import { MediaTypeObject } from "../openapi/types";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
title: string;
|
|
13
|
+
body: {
|
|
14
|
+
content?: {
|
|
15
|
+
[key: string]: MediaTypeObject;
|
|
16
|
+
};
|
|
17
|
+
description?: string;
|
|
18
|
+
required?: boolean;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createRequestBodyDetails({ title, body }: Props) {
|
|
23
|
+
return createRequestSchema({ title, body });
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 createRequestHeader(header: string) {
|
|
11
|
+
return [
|
|
12
|
+
create(
|
|
13
|
+
"Heading",
|
|
14
|
+
{
|
|
15
|
+
children: header,
|
|
16
|
+
id: header.replace(" ", "-").toLowerCase(),
|
|
17
|
+
as: "h2",
|
|
18
|
+
className: "openapi-tabs__heading",
|
|
19
|
+
},
|
|
20
|
+
{ inline: true }
|
|
21
|
+
),
|
|
22
|
+
`\n\n`,
|
|
23
|
+
];
|
|
24
|
+
}
|