docusaurus-plugin-openapi-docs 0.0.0-567 → 0.0.0-570
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/createAuthentication.js +45 -13
- package/lib/markdown/createStatusCodes.js +3 -1
- package/lib/markdown/index.js +1 -1
- package/lib/openapi/openapi.js +1 -1
- package/package.json +2 -2
- package/src/markdown/createAuthentication.ts +53 -17
- package/src/markdown/createStatusCodes.ts +38 -39
- package/src/markdown/index.ts +1 -1
- package/src/openapi/openapi.ts +1 -1
|
@@ -13,7 +13,7 @@ function createAuthentication(securitySchemes) {
|
|
|
13
13
|
if (!securitySchemes || !Object.keys(securitySchemes).length)
|
|
14
14
|
return "";
|
|
15
15
|
const createAuthenticationTable = (securityScheme) => {
|
|
16
|
-
const { bearerFormat, flows, name, scheme, type } = securityScheme;
|
|
16
|
+
const { bearerFormat, flows, name, scheme, type, openIdConnectUrl } = securityScheme;
|
|
17
17
|
const createSecuritySchemeTypeRow = () => (0, utils_1.create)("tr", {
|
|
18
18
|
children: [
|
|
19
19
|
(0, utils_1.create)("th", { children: "Security Scheme Type:" }),
|
|
@@ -25,7 +25,7 @@ function createAuthentication(securitySchemes) {
|
|
|
25
25
|
const { authorizationUrl, tokenUrl, refreshUrl, scopes } = flowObj;
|
|
26
26
|
return (0, utils_1.create)("tr", {
|
|
27
27
|
children: [
|
|
28
|
-
(0, utils_1.create)("th", { children:
|
|
28
|
+
(0, utils_1.create)("th", { children: `OAuth Flow (${flowType}):` }),
|
|
29
29
|
(0, utils_1.create)("td", {
|
|
30
30
|
children: [
|
|
31
31
|
(0, utils_1.guard)(tokenUrl, () => (0, utils_1.create)("p", { children: `Token URL: ${tokenUrl}` })),
|
|
@@ -76,12 +76,12 @@ function createAuthentication(securitySchemes) {
|
|
|
76
76
|
(0, utils_1.create)("td", { children: scheme }),
|
|
77
77
|
],
|
|
78
78
|
}),
|
|
79
|
-
(0, utils_1.create)("tr", {
|
|
79
|
+
(0, utils_1.guard)(bearerFormat, () => (0, utils_1.create)("tr", {
|
|
80
80
|
children: [
|
|
81
81
|
(0, utils_1.create)("th", { children: "Bearer format:" }),
|
|
82
82
|
(0, utils_1.create)("td", { children: bearerFormat }),
|
|
83
83
|
],
|
|
84
|
-
}),
|
|
84
|
+
})),
|
|
85
85
|
],
|
|
86
86
|
}),
|
|
87
87
|
}),
|
|
@@ -100,20 +100,51 @@ function createAuthentication(securitySchemes) {
|
|
|
100
100
|
}),
|
|
101
101
|
],
|
|
102
102
|
});
|
|
103
|
+
case "openIdConnect":
|
|
104
|
+
return (0, utils_1.create)("div", {
|
|
105
|
+
children: [
|
|
106
|
+
(0, utils_1.create)("table", {
|
|
107
|
+
children: (0, utils_1.create)("tbody", {
|
|
108
|
+
children: [
|
|
109
|
+
createSecuritySchemeTypeRow(),
|
|
110
|
+
(0, utils_1.guard)(openIdConnectUrl, () => (0, utils_1.create)("tr", {
|
|
111
|
+
children: [
|
|
112
|
+
(0, utils_1.create)("th", { children: "OpenID Connect URL:" }),
|
|
113
|
+
(0, utils_1.create)("td", { children: openIdConnectUrl }),
|
|
114
|
+
],
|
|
115
|
+
})),
|
|
116
|
+
],
|
|
117
|
+
}),
|
|
118
|
+
}),
|
|
119
|
+
],
|
|
120
|
+
});
|
|
103
121
|
default:
|
|
104
122
|
return "";
|
|
105
123
|
}
|
|
106
124
|
};
|
|
107
|
-
const formatTabLabel = (
|
|
108
|
-
const formattedLabel =
|
|
125
|
+
const formatTabLabel = (key, type, scheme) => {
|
|
126
|
+
const formattedLabel = key
|
|
109
127
|
.replace(/(_|-)/g, " ")
|
|
110
128
|
.trim()
|
|
111
129
|
.replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
|
|
112
130
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
113
131
|
.replace(/([A-Z])([A-Z][a-z])/g, "$1 $2");
|
|
114
|
-
const isOAuth =
|
|
115
|
-
const isApiKey =
|
|
116
|
-
|
|
132
|
+
const isOAuth = type === "oauth2";
|
|
133
|
+
const isApiKey = type === "apiKey";
|
|
134
|
+
const isHttpBasic = type === "http" && scheme === "basic";
|
|
135
|
+
const isHttpBearer = type === "http" && scheme === "bearer";
|
|
136
|
+
const isOpenId = type === "openIdConnect";
|
|
137
|
+
if (isOAuth)
|
|
138
|
+
return `OAuth 2.0: ${key}`;
|
|
139
|
+
if (isApiKey)
|
|
140
|
+
return `API Key: ${key}`;
|
|
141
|
+
if (isHttpBasic)
|
|
142
|
+
return "HTTP: Basic Auth";
|
|
143
|
+
if (isHttpBearer)
|
|
144
|
+
return "HTTP: Bearer Auth";
|
|
145
|
+
if (isOpenId)
|
|
146
|
+
return `OpenID Connect: ${key}`;
|
|
147
|
+
return formattedLabel;
|
|
117
148
|
};
|
|
118
149
|
return (0, utils_1.create)("div", {
|
|
119
150
|
children: [
|
|
@@ -122,10 +153,11 @@ function createAuthentication(securitySchemes) {
|
|
|
122
153
|
id: "authentication",
|
|
123
154
|
style: { marginBottom: "1rem" },
|
|
124
155
|
}),
|
|
125
|
-
(0, utils_1.create)("
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
156
|
+
(0, utils_1.create)("SchemaTabs", {
|
|
157
|
+
className: "openapi-tabs__security-schemes",
|
|
158
|
+
children: Object.entries(securitySchemes).map(([schemeKey, schemeObj]) => (0, utils_1.create)("TabItem", {
|
|
159
|
+
label: formatTabLabel(schemeKey, schemeObj.type, schemeObj.scheme),
|
|
160
|
+
value: `${schemeKey}`,
|
|
129
161
|
children: [
|
|
130
162
|
(0, createDescription_1.createDescription)(schemeObj.description),
|
|
131
163
|
createAuthenticationTable(schemeObj),
|
|
@@ -66,7 +66,9 @@ function createResponseHeaders(responseHeaders) {
|
|
|
66
66
|
style: { marginLeft: "1rem" },
|
|
67
67
|
children: [
|
|
68
68
|
Object.entries(responseHeaders).map(([headerName, headerObj]) => {
|
|
69
|
-
|
|
69
|
+
var _a, _b;
|
|
70
|
+
const { description, example } = headerObj;
|
|
71
|
+
const type = (_b = (_a = headerObj.schema) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : "any";
|
|
70
72
|
return (0, utils_1.create)("li", {
|
|
71
73
|
className: "schemaItem",
|
|
72
74
|
children: [
|
package/lib/markdown/index.js
CHANGED
|
@@ -48,7 +48,7 @@ exports.createApiPageMD = createApiPageMD;
|
|
|
48
48
|
function createInfoPageMD({ info: { title, version, description, contact, license, termsOfService, logo, darkLogo, }, securitySchemes, downloadUrl, }) {
|
|
49
49
|
return (0, utils_1.render)([
|
|
50
50
|
`import ApiLogo from "@theme/ApiLogo";\n`,
|
|
51
|
-
`import
|
|
51
|
+
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
52
52
|
`import TabItem from "@theme/TabItem";\n`,
|
|
53
53
|
`import Export from "@theme/ApiDemoPanel/Export";\n\n`,
|
|
54
54
|
(0, createVersionBadge_1.createVersionBadge)(version),
|
package/lib/openapi/openapi.js
CHANGED
|
@@ -66,7 +66,7 @@ function createItems(openapiData, options, sidebarOptions) {
|
|
|
66
66
|
let items = [];
|
|
67
67
|
const infoIdSpaces = openapiData.info.title.replace(" ", "-").toLowerCase();
|
|
68
68
|
const infoId = (0, kebabCase_1.default)(infoIdSpaces);
|
|
69
|
-
if (openapiData.info.description) {
|
|
69
|
+
if (openapiData.info.description || openapiData.info.title) {
|
|
70
70
|
// Only create an info page if we have a description.
|
|
71
71
|
const infoDescription = (_a = openapiData.info) === null || _a === void 0 ? void 0 : _a.description;
|
|
72
72
|
let splitDescription;
|
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-570",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "4d31250d34849be84d2b57115c8ee8de0e98d509"
|
|
72
72
|
}
|
|
@@ -13,7 +13,8 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
13
13
|
if (!securitySchemes || !Object.keys(securitySchemes).length) return "";
|
|
14
14
|
|
|
15
15
|
const createAuthenticationTable = (securityScheme: any) => {
|
|
16
|
-
const { bearerFormat, flows, name, scheme, type } =
|
|
16
|
+
const { bearerFormat, flows, name, scheme, type, openIdConnectUrl } =
|
|
17
|
+
securityScheme;
|
|
17
18
|
|
|
18
19
|
const createSecuritySchemeTypeRow = () =>
|
|
19
20
|
create("tr", {
|
|
@@ -30,7 +31,7 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
30
31
|
|
|
31
32
|
return create("tr", {
|
|
32
33
|
children: [
|
|
33
|
-
create("th", { children:
|
|
34
|
+
create("th", { children: `OAuth Flow (${flowType}):` }),
|
|
34
35
|
create("td", {
|
|
35
36
|
children: [
|
|
36
37
|
guard(tokenUrl, () =>
|
|
@@ -91,12 +92,14 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
91
92
|
create("td", { children: scheme }),
|
|
92
93
|
],
|
|
93
94
|
}),
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
guard(bearerFormat, () =>
|
|
96
|
+
create("tr", {
|
|
97
|
+
children: [
|
|
98
|
+
create("th", { children: "Bearer format:" }),
|
|
99
|
+
create("td", { children: bearerFormat }),
|
|
100
|
+
],
|
|
101
|
+
})
|
|
102
|
+
),
|
|
100
103
|
],
|
|
101
104
|
}),
|
|
102
105
|
}),
|
|
@@ -115,23 +118,51 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
115
118
|
}),
|
|
116
119
|
],
|
|
117
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
|
+
});
|
|
118
141
|
default:
|
|
119
142
|
return "";
|
|
120
143
|
}
|
|
121
144
|
};
|
|
122
145
|
|
|
123
|
-
const formatTabLabel = (
|
|
124
|
-
const formattedLabel =
|
|
146
|
+
const formatTabLabel = (key: string, type: string, scheme: string) => {
|
|
147
|
+
const formattedLabel = key
|
|
125
148
|
.replace(/(_|-)/g, " ")
|
|
126
149
|
.trim()
|
|
127
150
|
.replace(/\w\S*/g, (str) => str.charAt(0).toUpperCase() + str.substr(1))
|
|
128
151
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
129
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";
|
|
130
158
|
|
|
131
|
-
|
|
132
|
-
|
|
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}`;
|
|
133
164
|
|
|
134
|
-
return
|
|
165
|
+
return formattedLabel;
|
|
135
166
|
};
|
|
136
167
|
|
|
137
168
|
return create("div", {
|
|
@@ -141,12 +172,17 @@ export function createAuthentication(securitySchemes: SecuritySchemeObject) {
|
|
|
141
172
|
id: "authentication",
|
|
142
173
|
style: { marginBottom: "1rem" },
|
|
143
174
|
}),
|
|
144
|
-
create("
|
|
175
|
+
create("SchemaTabs", {
|
|
176
|
+
className: "openapi-tabs__security-schemes",
|
|
145
177
|
children: Object.entries(securitySchemes).map(
|
|
146
|
-
([
|
|
178
|
+
([schemeKey, schemeObj]) =>
|
|
147
179
|
create("TabItem", {
|
|
148
|
-
label: formatTabLabel(
|
|
149
|
-
|
|
180
|
+
label: formatTabLabel(
|
|
181
|
+
schemeKey,
|
|
182
|
+
schemeObj.type,
|
|
183
|
+
schemeObj.scheme
|
|
184
|
+
),
|
|
185
|
+
value: `${schemeKey}`,
|
|
150
186
|
children: [
|
|
151
187
|
createDescription(schemeObj.description),
|
|
152
188
|
createAuthenticationTable(schemeObj),
|
|
@@ -62,46 +62,45 @@ function createResponseHeaders(responseHeaders: any) {
|
|
|
62
62
|
create("ul", {
|
|
63
63
|
style: { marginLeft: "1rem" },
|
|
64
64
|
children: [
|
|
65
|
-
Object.entries(responseHeaders).map(
|
|
66
|
-
|
|
67
|
-
description,
|
|
68
|
-
|
|
69
|
-
example,
|
|
70
|
-
}: any = headerObj;
|
|
65
|
+
Object.entries(responseHeaders).map(
|
|
66
|
+
([headerName, headerObj]: [any, any]) => {
|
|
67
|
+
const { description, example }: any = headerObj;
|
|
68
|
+
const type = headerObj.schema?.type ?? "any";
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
70
|
+
return create("li", {
|
|
71
|
+
className: "schemaItem",
|
|
72
|
+
children: [
|
|
73
|
+
createDetailsSummary({
|
|
74
|
+
children: [
|
|
75
|
+
create("strong", { children: headerName }),
|
|
76
|
+
guard(type, () => [
|
|
77
|
+
create("span", {
|
|
78
|
+
style: { opacity: "0.6" },
|
|
79
|
+
children: ` ${type}`,
|
|
80
|
+
}),
|
|
81
|
+
]),
|
|
82
|
+
],
|
|
83
|
+
}),
|
|
84
|
+
create("div", {
|
|
85
|
+
children: [
|
|
86
|
+
guard(description, (description) =>
|
|
87
|
+
create("div", {
|
|
88
|
+
style: {
|
|
89
|
+
marginTop: ".5rem",
|
|
90
|
+
marginBottom: ".5rem",
|
|
91
|
+
},
|
|
92
|
+
children: [
|
|
93
|
+
guard(example, () => `Example: ${example}`),
|
|
94
|
+
createDescription(description),
|
|
95
|
+
],
|
|
96
|
+
})
|
|
97
|
+
),
|
|
98
|
+
],
|
|
99
|
+
}),
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
),
|
|
105
104
|
],
|
|
106
105
|
})
|
|
107
106
|
);
|
package/src/markdown/index.ts
CHANGED
|
@@ -88,7 +88,7 @@ export function createInfoPageMD({
|
|
|
88
88
|
}: InfoPageMetadata) {
|
|
89
89
|
return render([
|
|
90
90
|
`import ApiLogo from "@theme/ApiLogo";\n`,
|
|
91
|
-
`import
|
|
91
|
+
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
92
92
|
`import TabItem from "@theme/TabItem";\n`,
|
|
93
93
|
`import Export from "@theme/ApiDemoPanel/Export";\n\n`,
|
|
94
94
|
|
package/src/openapi/openapi.ts
CHANGED
|
@@ -88,7 +88,7 @@ function createItems(
|
|
|
88
88
|
const infoIdSpaces = openapiData.info.title.replace(" ", "-").toLowerCase();
|
|
89
89
|
const infoId = kebabCase(infoIdSpaces);
|
|
90
90
|
|
|
91
|
-
if (openapiData.info.description) {
|
|
91
|
+
if (openapiData.info.description || openapiData.info.title) {
|
|
92
92
|
// Only create an info page if we have a description.
|
|
93
93
|
const infoDescription = openapiData.info?.description;
|
|
94
94
|
let splitDescription: any;
|