docusaurus-plugin-openapi-docs 0.0.0-411 → 0.0.0-412
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.
|
@@ -53,6 +53,21 @@ function createResponseHeaders(responseHeaders) {
|
|
|
53
53
|
],
|
|
54
54
|
}));
|
|
55
55
|
}
|
|
56
|
+
function createResponseExamples(responseExamples) {
|
|
57
|
+
return Object.entries(responseExamples).map(([exampleName, exampleValue]) => {
|
|
58
|
+
const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
|
|
59
|
+
let finalFormattedName = camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
|
|
60
|
+
return (0, utils_1.create)("TabItem", {
|
|
61
|
+
label: `${finalFormattedName}`,
|
|
62
|
+
value: `${finalFormattedName}`,
|
|
63
|
+
children: [
|
|
64
|
+
(0, utils_1.create)("ResponseSamples", {
|
|
65
|
+
responseExample: JSON.stringify(exampleValue.value, null, 2),
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}
|
|
56
71
|
function createStatusCodes({ responses }) {
|
|
57
72
|
if (responses === undefined) {
|
|
58
73
|
return undefined;
|
|
@@ -66,6 +81,9 @@ function createStatusCodes({ responses }) {
|
|
|
66
81
|
(0, utils_1.create)("ApiTabs", {
|
|
67
82
|
children: codes.map((code) => {
|
|
68
83
|
const responseHeaders = responses[code].headers;
|
|
84
|
+
const responseContent = responses[code].content;
|
|
85
|
+
const responseContentKey = responseContent && Object.keys(responseContent)[0];
|
|
86
|
+
const responseExamples = responseContentKey && responseContent[responseContentKey].examples;
|
|
69
87
|
return (0, utils_1.create)("TabItem", {
|
|
70
88
|
label: code,
|
|
71
89
|
value: code,
|
|
@@ -73,28 +91,62 @@ function createStatusCodes({ responses }) {
|
|
|
73
91
|
(0, utils_1.create)("div", {
|
|
74
92
|
children: (0, createDescription_1.createDescription)(responses[code].description),
|
|
75
93
|
}),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
(0, utils_2.guard)(responseExamples, () => (0, utils_1.create)("SchemaTabs", {
|
|
95
|
+
children: [
|
|
96
|
+
(0, utils_1.create)("TabTtem", {
|
|
97
|
+
label: "Schema",
|
|
98
|
+
value: "Schema",
|
|
99
|
+
children: [
|
|
100
|
+
responseHeaders &&
|
|
101
|
+
(0, createDetails_1.createDetails)({
|
|
102
|
+
"data-collaposed": false,
|
|
103
|
+
open: true,
|
|
104
|
+
style: { textAlign: "left" },
|
|
105
|
+
children: [
|
|
106
|
+
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
107
|
+
children: [
|
|
108
|
+
(0, utils_1.create)("strong", {
|
|
109
|
+
children: "Response Headers",
|
|
110
|
+
}),
|
|
111
|
+
],
|
|
112
|
+
}),
|
|
113
|
+
createResponseHeaders(responseHeaders),
|
|
114
|
+
],
|
|
115
|
+
}),
|
|
116
|
+
(0, utils_1.create)("div", {
|
|
117
|
+
children: (0, createSchemaDetails_1.createSchemaDetails)({
|
|
118
|
+
title: "Schema",
|
|
119
|
+
body: {
|
|
120
|
+
content: responses[code].content,
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
],
|
|
125
|
+
}),
|
|
126
|
+
createResponseExamples(responseExamples),
|
|
127
|
+
],
|
|
128
|
+
})),
|
|
129
|
+
(0, utils_2.guard)(responseHeaders, () => (0, createDetails_1.createDetails)({
|
|
130
|
+
"data-collaposed": false,
|
|
131
|
+
open: true,
|
|
132
|
+
style: { textAlign: "left" },
|
|
133
|
+
children: [
|
|
134
|
+
(0, createDetailsSummary_1.createDetailsSummary)({
|
|
135
|
+
children: [
|
|
136
|
+
(0, utils_1.create)("strong", { children: "Response Headers" }),
|
|
137
|
+
],
|
|
138
|
+
}),
|
|
139
|
+
createResponseHeaders(responseHeaders),
|
|
140
|
+
],
|
|
141
|
+
})),
|
|
142
|
+
(0, utils_2.guard)(!responseExamples, () => (0, utils_1.create)("div", {
|
|
91
143
|
children: (0, createSchemaDetails_1.createSchemaDetails)({
|
|
92
144
|
title: "Schema",
|
|
93
145
|
body: {
|
|
94
146
|
content: responses[code].content,
|
|
95
147
|
},
|
|
96
148
|
}),
|
|
97
|
-
}),
|
|
149
|
+
})),
|
|
98
150
|
],
|
|
99
151
|
});
|
|
100
152
|
}),
|
package/lib/markdown/index.js
CHANGED
|
@@ -22,9 +22,10 @@ const createVersionBadge_1 = require("./createVersionBadge");
|
|
|
22
22
|
const utils_1 = require("./utils");
|
|
23
23
|
function createApiPageMD({ title, api: { deprecated, "x-deprecated-description": deprecatedDescription, description, parameters, requestBody, responses, }, }) {
|
|
24
24
|
return (0, utils_1.render)([
|
|
25
|
+
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
25
26
|
`import ParamsItem from "@theme/ParamsItem";\n`,
|
|
27
|
+
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
26
28
|
`import SchemaItem from "@theme/SchemaItem"\n`,
|
|
27
|
-
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
28
29
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
29
30
|
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
30
31
|
`import TabItem from "@theme/TabItem";\n\n`,
|
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-412",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=14"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "6e093b9e84f83993a01f0922aaddb27d367d7485"
|
|
71
71
|
}
|
|
@@ -67,6 +67,26 @@ function createResponseHeaders(responseHeaders: any) {
|
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
function createResponseExamples(responseExamples: any) {
|
|
71
|
+
return Object.entries(responseExamples).map(
|
|
72
|
+
([exampleName, exampleValue]: any) => {
|
|
73
|
+
const camelToSpaceName = exampleName.replace(/([A-Z])/g, " $1");
|
|
74
|
+
let finalFormattedName =
|
|
75
|
+
camelToSpaceName.charAt(0).toUpperCase() + camelToSpaceName.slice(1);
|
|
76
|
+
|
|
77
|
+
return create("TabItem", {
|
|
78
|
+
label: `${finalFormattedName}`,
|
|
79
|
+
value: `${finalFormattedName}`,
|
|
80
|
+
children: [
|
|
81
|
+
create("ResponseSamples", {
|
|
82
|
+
responseExample: JSON.stringify(exampleValue.value, null, 2),
|
|
83
|
+
}),
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
export function createStatusCodes({ responses }: Props) {
|
|
71
91
|
if (responses === undefined) {
|
|
72
92
|
return undefined;
|
|
@@ -82,6 +102,12 @@ export function createStatusCodes({ responses }: Props) {
|
|
|
82
102
|
create("ApiTabs", {
|
|
83
103
|
children: codes.map((code) => {
|
|
84
104
|
const responseHeaders: any = responses[code].headers;
|
|
105
|
+
const responseContent: any = responses[code].content;
|
|
106
|
+
const responseContentKey: any =
|
|
107
|
+
responseContent && Object.keys(responseContent)[0];
|
|
108
|
+
const responseExamples: any =
|
|
109
|
+
responseContentKey && responseContent[responseContentKey].examples;
|
|
110
|
+
|
|
85
111
|
return create("TabItem", {
|
|
86
112
|
label: code,
|
|
87
113
|
value: code,
|
|
@@ -89,7 +115,44 @@ export function createStatusCodes({ responses }: Props) {
|
|
|
89
115
|
create("div", {
|
|
90
116
|
children: createDescription(responses[code].description),
|
|
91
117
|
}),
|
|
92
|
-
|
|
118
|
+
guard(responseExamples, () =>
|
|
119
|
+
create("SchemaTabs", {
|
|
120
|
+
children: [
|
|
121
|
+
create("TabTtem", {
|
|
122
|
+
label: "Schema",
|
|
123
|
+
value: "Schema",
|
|
124
|
+
children: [
|
|
125
|
+
responseHeaders &&
|
|
126
|
+
createDetails({
|
|
127
|
+
"data-collaposed": false,
|
|
128
|
+
open: true,
|
|
129
|
+
style: { textAlign: "left" },
|
|
130
|
+
children: [
|
|
131
|
+
createDetailsSummary({
|
|
132
|
+
children: [
|
|
133
|
+
create("strong", {
|
|
134
|
+
children: "Response Headers",
|
|
135
|
+
}),
|
|
136
|
+
],
|
|
137
|
+
}),
|
|
138
|
+
createResponseHeaders(responseHeaders),
|
|
139
|
+
],
|
|
140
|
+
}),
|
|
141
|
+
create("div", {
|
|
142
|
+
children: createSchemaDetails({
|
|
143
|
+
title: "Schema",
|
|
144
|
+
body: {
|
|
145
|
+
content: responses[code].content,
|
|
146
|
+
},
|
|
147
|
+
}),
|
|
148
|
+
}),
|
|
149
|
+
],
|
|
150
|
+
}),
|
|
151
|
+
createResponseExamples(responseExamples),
|
|
152
|
+
],
|
|
153
|
+
})
|
|
154
|
+
),
|
|
155
|
+
guard(responseHeaders, () =>
|
|
93
156
|
createDetails({
|
|
94
157
|
"data-collaposed": false,
|
|
95
158
|
open: true,
|
|
@@ -102,15 +165,18 @@ export function createStatusCodes({ responses }: Props) {
|
|
|
102
165
|
}),
|
|
103
166
|
createResponseHeaders(responseHeaders),
|
|
104
167
|
],
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
168
|
+
})
|
|
169
|
+
),
|
|
170
|
+
guard(!responseExamples, () =>
|
|
171
|
+
create("div", {
|
|
172
|
+
children: createSchemaDetails({
|
|
173
|
+
title: "Schema",
|
|
174
|
+
body: {
|
|
175
|
+
content: responses[code].content,
|
|
176
|
+
},
|
|
177
|
+
}),
|
|
178
|
+
})
|
|
179
|
+
),
|
|
114
180
|
],
|
|
115
181
|
});
|
|
116
182
|
}),
|
package/src/markdown/index.ts
CHANGED
|
@@ -38,9 +38,10 @@ export function createApiPageMD({
|
|
|
38
38
|
},
|
|
39
39
|
}: ApiPageMetadata) {
|
|
40
40
|
return render([
|
|
41
|
+
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
41
42
|
`import ParamsItem from "@theme/ParamsItem";\n`,
|
|
43
|
+
`import ResponseSamples from "@theme/ResponseSamples";\n`,
|
|
42
44
|
`import SchemaItem from "@theme/SchemaItem"\n`,
|
|
43
|
-
`import ApiTabs from "@theme/ApiTabs";\n`,
|
|
44
45
|
`import SchemaTabs from "@theme/SchemaTabs";\n`,
|
|
45
46
|
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
|
|
46
47
|
`import TabItem from "@theme/TabItem";\n\n`,
|