docusaurus-theme-openapi-docs 4.7.0 → 5.0.0
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/index.js +2 -0
- package/lib/markdown/schema.js +63 -9
- package/lib/theme/ApiExplorer/Accept/index.js +2 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +6 -2
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +191 -38
- package/lib/theme/ApiExplorer/Body/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/index.js +86 -15
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
- package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
- package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
- package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
- package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
- package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
- package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
- package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
- package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
- package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
- package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
- package/lib/theme/ApiExplorer/MethodEndpoint/index.js +28 -0
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +6 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/lib/theme/ApiExplorer/Request/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/index.js +19 -5
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
- package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/lib/theme/ApiExplorer/Response/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Response/index.js +98 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +2 -2
- package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/Server/index.js +6 -3
- package/lib/theme/ApiExplorer/Server/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +5 -2
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
- package/lib/theme/ApiExplorer/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/index.js +1 -0
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
- package/lib/theme/ApiItem/hooks.d.ts +1 -0
- package/lib/theme/ApiItem/index.js +2 -1
- package/lib/theme/ApiItem/store.d.ts +6 -0
- package/lib/theme/ApiItem/store.js +11 -7
- package/lib/theme/ApiTabs/index.js +10 -11
- package/lib/theme/DiscriminatorTabs/index.js +10 -11
- package/lib/theme/MimeTabs/index.js +10 -11
- package/lib/theme/OperationTabs/index.js +10 -11
- package/lib/theme/ParamsDetails/index.js +2 -2
- package/lib/theme/ParamsItem/index.js +27 -0
- package/lib/theme/RequestSchema/index.d.ts +1 -1
- package/lib/theme/RequestSchema/index.js +174 -111
- package/lib/theme/ResponseHeaders/index.js +0 -1
- package/lib/theme/ResponseSchema/index.d.ts +1 -1
- package/lib/theme/Schema/index.d.ts +1 -1
- package/lib/theme/Schema/index.js +91 -23
- package/lib/theme/SchemaItem/index.js +6 -1
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +31 -12
- package/lib/theme/StatusCodes/index.d.ts +1 -1
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +3 -0
- package/lib/theme/translationIds.js +3 -0
- package/package.json +9 -8
- package/src/index.ts +2 -0
- package/src/markdown/schema.ts +69 -13
- package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +2 -5
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +119 -39
- package/src/theme/ApiExplorer/Body/index.tsx +88 -21
- package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +1 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
- package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
- package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
- package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/src/theme/ApiExplorer/FormItem/index.tsx +2 -17
- package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
- package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
- package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
- package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
- package/src/theme/ApiExplorer/MethodEndpoint/index.tsx +21 -0
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/src/theme/ApiExplorer/Request/index.tsx +22 -10
- package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
- package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/src/theme/ApiExplorer/Response/index.tsx +37 -17
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +2 -3
- package/src/theme/ApiExplorer/Server/index.tsx +10 -3
- package/src/theme/ApiExplorer/Server/slice.ts +1 -1
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +53 -6
- package/src/theme/ApiExplorer/index.tsx +2 -1
- package/src/theme/ApiItem/index.tsx +3 -2
- package/src/theme/ApiItem/store.ts +2 -0
- package/src/theme/ApiTabs/index.tsx +14 -19
- package/src/theme/DiscriminatorTabs/index.tsx +14 -19
- package/src/theme/MimeTabs/index.tsx +15 -19
- package/src/theme/OperationTabs/index.tsx +14 -19
- package/src/theme/ParamsDetails/index.tsx +2 -3
- package/src/theme/ParamsItem/index.tsx +25 -0
- package/src/theme/RequestSchema/index.tsx +144 -87
- package/src/theme/ResponseHeaders/index.tsx +1 -2
- package/src/theme/ResponseSchema/index.tsx +1 -1
- package/src/theme/Schema/index.tsx +112 -27
- package/src/theme/SchemaItem/index.tsx +6 -1
- package/src/theme/SchemaTabs/index.tsx +42 -21
- package/src/theme/StatusCodes/index.tsx +1 -1
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +3 -0
- package/src/theme-classic.d.ts +25 -1
- package/src/types.d.ts +15 -52
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js
CHANGED
|
@@ -38,6 +38,7 @@ function docusaurusThemeOpenAPI() {
|
|
|
38
38
|
resolve: {
|
|
39
39
|
fallback: {
|
|
40
40
|
buffer: require.resolve("buffer/"),
|
|
41
|
+
path: require.resolve("path-browserify"),
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
plugins: [
|
|
@@ -67,6 +68,7 @@ function docusaurusThemeOpenAPI() {
|
|
|
67
68
|
resolve: {
|
|
68
69
|
fallback: {
|
|
69
70
|
buffer: require.resolve("buffer/"),
|
|
71
|
+
path: require.resolve("path-browserify"),
|
|
70
72
|
},
|
|
71
73
|
},
|
|
72
74
|
plugins: [
|
package/lib/markdown/schema.js
CHANGED
|
@@ -10,6 +10,38 @@ exports.getSchemaName = getSchemaName;
|
|
|
10
10
|
exports.getQualifierMessage = getQualifierMessage;
|
|
11
11
|
const Translate_1 = require("@docusaurus/Translate");
|
|
12
12
|
const translationIds_1 = require("../theme/translationIds");
|
|
13
|
+
/**
|
|
14
|
+
* Extracts enum values from a schema, including when wrapped in allOf.
|
|
15
|
+
*/
|
|
16
|
+
function getEnumFromSchema(schema) {
|
|
17
|
+
if (schema.enum) {
|
|
18
|
+
return schema.enum;
|
|
19
|
+
}
|
|
20
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
21
|
+
for (const item of schema.allOf) {
|
|
22
|
+
if (item.enum) {
|
|
23
|
+
return item.enum;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Extracts the type from a schema, including when wrapped in allOf.
|
|
31
|
+
*/
|
|
32
|
+
function getTypeFromSchema(schema) {
|
|
33
|
+
if (schema.type) {
|
|
34
|
+
return schema.type;
|
|
35
|
+
}
|
|
36
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
37
|
+
for (const item of schema.allOf) {
|
|
38
|
+
if (item.type) {
|
|
39
|
+
return item.type;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
13
45
|
function prettyName(schema, circular) {
|
|
14
46
|
// Handle enum-only schemas (valid in JSON Schema)
|
|
15
47
|
// When enum is present without explicit type, treat as string
|
|
@@ -26,6 +58,12 @@ function prettyName(schema, circular) {
|
|
|
26
58
|
return schema.allOf[0];
|
|
27
59
|
}
|
|
28
60
|
}
|
|
61
|
+
// Check if allOf contains an enum - if so, return the type from allOf
|
|
62
|
+
const enumFromAllOf = getEnumFromSchema(schema);
|
|
63
|
+
if (enumFromAllOf) {
|
|
64
|
+
const typeFromAllOf = getTypeFromSchema(schema);
|
|
65
|
+
return typeFromAllOf ?? "string";
|
|
66
|
+
}
|
|
29
67
|
return "object";
|
|
30
68
|
}
|
|
31
69
|
if (schema.oneOf) {
|
|
@@ -72,23 +110,33 @@ function getQualifierMessage(schema) {
|
|
|
72
110
|
message: "Possible values:",
|
|
73
111
|
})}** `;
|
|
74
112
|
let qualifierGroups = [];
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
113
|
+
// Check for enum in array items (directly or inside allOf)
|
|
114
|
+
if (schema.items) {
|
|
115
|
+
const itemsEnum = getEnumFromSchema(schema.items);
|
|
116
|
+
if (itemsEnum) {
|
|
117
|
+
qualifierGroups.push(`[${itemsEnum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
78
118
|
}
|
|
79
119
|
}
|
|
80
120
|
if (schema.minLength || schema.maxLength) {
|
|
81
121
|
let lengthQualifier = "";
|
|
82
122
|
let minLength;
|
|
83
123
|
let maxLength;
|
|
124
|
+
const charactersMessage = (0, Translate_1.translate)({
|
|
125
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.CHARACTERS,
|
|
126
|
+
message: "characters",
|
|
127
|
+
});
|
|
128
|
+
const nonEmptyMessage = (0, Translate_1.translate)({
|
|
129
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.NON_EMPTY,
|
|
130
|
+
message: "non-empty",
|
|
131
|
+
});
|
|
84
132
|
if (schema.minLength && schema.minLength > 1) {
|
|
85
|
-
minLength = `\`>= ${schema.minLength}
|
|
133
|
+
minLength = `\`>= ${schema.minLength} ${charactersMessage}\``;
|
|
86
134
|
}
|
|
87
135
|
if (schema.minLength && schema.minLength === 1) {
|
|
88
|
-
minLength =
|
|
136
|
+
minLength = `\`${nonEmptyMessage}\``;
|
|
89
137
|
}
|
|
90
138
|
if (schema.maxLength) {
|
|
91
|
-
maxLength = `\`<= ${schema.maxLength}
|
|
139
|
+
maxLength = `\`<= ${schema.maxLength} ${charactersMessage}\``;
|
|
92
140
|
}
|
|
93
141
|
if (minLength && !maxLength) {
|
|
94
142
|
lengthQualifier += minLength;
|
|
@@ -138,7 +186,11 @@ function getQualifierMessage(schema) {
|
|
|
138
186
|
qualifierGroups.push(minmaxQualifier);
|
|
139
187
|
}
|
|
140
188
|
if (schema.pattern) {
|
|
141
|
-
|
|
189
|
+
const expressionMessage = (0, Translate_1.translate)({
|
|
190
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.EXPRESSION,
|
|
191
|
+
message: "Value must match regular expression",
|
|
192
|
+
});
|
|
193
|
+
qualifierGroups.push(`${expressionMessage} \`${schema.pattern}\``);
|
|
142
194
|
}
|
|
143
195
|
// Check if discriminator mapping
|
|
144
196
|
const discriminator = schema;
|
|
@@ -146,8 +198,10 @@ function getQualifierMessage(schema) {
|
|
|
146
198
|
const values = Object.keys(discriminator.mapping);
|
|
147
199
|
qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
|
|
148
200
|
}
|
|
149
|
-
|
|
150
|
-
|
|
201
|
+
// Check for enum directly on schema or inside allOf
|
|
202
|
+
const schemaEnum = getEnumFromSchema(schema);
|
|
203
|
+
if (schemaEnum) {
|
|
204
|
+
qualifierGroups.push(`[${schemaEnum.map((e) => `\`${e}\``).join(", ")}]`);
|
|
151
205
|
}
|
|
152
206
|
if (schema.minItems) {
|
|
153
207
|
qualifierGroups.push(`\`>= ${schema.minItems}\``);
|
|
@@ -27,8 +27,9 @@ function Accept() {
|
|
|
27
27
|
}
|
|
28
28
|
return react_1.default.createElement(
|
|
29
29
|
FormItem_1.default,
|
|
30
|
-
|
|
30
|
+
null,
|
|
31
31
|
react_1.default.createElement(FormSelect_1.default, {
|
|
32
|
+
label: "Accept",
|
|
32
33
|
value: value,
|
|
33
34
|
options: options,
|
|
34
35
|
onChange: (e) => dispatch((0, slice_1.setAccept)(e.target.value)),
|
|
@@ -39,13 +39,12 @@ function Authorization() {
|
|
|
39
39
|
optionKeys.length > 1 &&
|
|
40
40
|
react_1.default.createElement(
|
|
41
41
|
FormItem_1.default,
|
|
42
|
-
|
|
42
|
+
null,
|
|
43
|
+
react_1.default.createElement(FormSelect_1.default, {
|
|
43
44
|
label: (0, Translate_1.translate)({
|
|
44
45
|
id: translationIds_1.OPENAPI_AUTH.SECURITY_SCHEME,
|
|
45
46
|
message: "Security Scheme",
|
|
46
47
|
}),
|
|
47
|
-
},
|
|
48
|
-
react_1.default.createElement(FormSelect_1.default, {
|
|
49
48
|
options: optionKeys,
|
|
50
49
|
value: selected,
|
|
51
50
|
onChange: (e) => {
|
|
@@ -57,14 +56,12 @@ function Authorization() {
|
|
|
57
56
|
if (a.type === "http" && a.scheme === "bearer") {
|
|
58
57
|
return react_1.default.createElement(
|
|
59
58
|
FormItem_1.default,
|
|
60
|
-
{
|
|
59
|
+
{ key: a.key + "-bearer" },
|
|
60
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
61
61
|
label: (0, Translate_1.translate)({
|
|
62
62
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
63
63
|
message: "Bearer Token",
|
|
64
64
|
}),
|
|
65
|
-
key: a.key + "-bearer",
|
|
66
|
-
},
|
|
67
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
68
65
|
placeholder: (0, Translate_1.translate)({
|
|
69
66
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
70
67
|
message: "Bearer Token",
|
|
@@ -87,14 +84,12 @@ function Authorization() {
|
|
|
87
84
|
if (a.type === "oauth2") {
|
|
88
85
|
return react_1.default.createElement(
|
|
89
86
|
FormItem_1.default,
|
|
90
|
-
{
|
|
87
|
+
{ key: a.key + "-oauth2" },
|
|
88
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
91
89
|
label: (0, Translate_1.translate)({
|
|
92
90
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
93
91
|
message: "Bearer Token",
|
|
94
92
|
}),
|
|
95
|
-
key: a.key + "-oauth2",
|
|
96
|
-
},
|
|
97
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
98
93
|
placeholder: (0, Translate_1.translate)({
|
|
99
94
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
100
95
|
message: "Bearer Token",
|
|
@@ -120,13 +115,12 @@ function Authorization() {
|
|
|
120
115
|
{ key: a.key + "-basic" },
|
|
121
116
|
react_1.default.createElement(
|
|
122
117
|
FormItem_1.default,
|
|
123
|
-
|
|
118
|
+
null,
|
|
119
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
124
120
|
label: (0, Translate_1.translate)({
|
|
125
121
|
id: translationIds_1.OPENAPI_AUTH.USERNAME,
|
|
126
122
|
message: "Username",
|
|
127
123
|
}),
|
|
128
|
-
},
|
|
129
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
130
124
|
placeholder: (0, Translate_1.translate)({
|
|
131
125
|
id: translationIds_1.OPENAPI_AUTH.USERNAME,
|
|
132
126
|
message: "Username",
|
|
@@ -146,13 +140,12 @@ function Authorization() {
|
|
|
146
140
|
),
|
|
147
141
|
react_1.default.createElement(
|
|
148
142
|
FormItem_1.default,
|
|
149
|
-
|
|
143
|
+
null,
|
|
144
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
150
145
|
label: (0, Translate_1.translate)({
|
|
151
146
|
id: translationIds_1.OPENAPI_AUTH.PASSWORD,
|
|
152
147
|
message: "Password",
|
|
153
148
|
}),
|
|
154
|
-
},
|
|
155
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
156
149
|
placeholder: (0, Translate_1.translate)({
|
|
157
150
|
id: translationIds_1.OPENAPI_AUTH.PASSWORD,
|
|
158
151
|
message: "Password",
|
|
@@ -176,8 +169,9 @@ function Authorization() {
|
|
|
176
169
|
if (a.type === "apiKey") {
|
|
177
170
|
return react_1.default.createElement(
|
|
178
171
|
FormItem_1.default,
|
|
179
|
-
{
|
|
172
|
+
{ key: a.key + "-apikey" },
|
|
180
173
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
174
|
+
label: `${a.key}`,
|
|
181
175
|
placeholder: `${a.key}`,
|
|
182
176
|
password: true,
|
|
183
177
|
value: data[a.key].apiKey ?? "",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
-
import { SecurityRequirementObject, SecuritySchemeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
2
|
+
import type { SecurityRequirementObject, SecuritySchemeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
3
|
import { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
|
|
4
4
|
export declare function createAuth({ security, securitySchemes, options: opts, }: {
|
|
5
5
|
security?: SecurityRequirementObject[];
|
|
@@ -92,10 +92,6 @@ function FileArrayFormBodyItem({ id, description }) {
|
|
|
92
92
|
);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
let maxIndex = 0;
|
|
96
|
-
newItems.keys().forEach((item) => {
|
|
97
|
-
maxIndex = item > maxIndex ? item : maxIndex;
|
|
98
|
-
});
|
|
99
95
|
newItems.set(index, {
|
|
100
96
|
src: `/path/to/${file.name}`,
|
|
101
97
|
content: file,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
2
|
+
import type { SchemaObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
3
|
interface FormBodyItemProps {
|
|
4
4
|
schemaObject: SchemaObject;
|
|
5
5
|
id: string;
|
|
6
6
|
schema: SchemaObject;
|
|
7
|
+
label?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
exampleValue?: SchemaObject["example"];
|
|
10
|
+
fieldEncoding?: string;
|
|
7
11
|
}
|
|
8
|
-
export default function FormBodyItem({ schemaObject, id, schema, }: FormBodyItemProps): React.JSX.Element;
|
|
12
|
+
export default function FormBodyItem({ schemaObject, id, schema, label, required, exampleValue, fieldEncoding, }: FormBodyItemProps): React.JSX.Element;
|
|
9
13
|
export {};
|
|
@@ -5,6 +5,62 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
(function () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
@@ -12,67 +68,156 @@ var __importDefault =
|
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
70
|
exports.default = FormBodyItem;
|
|
15
|
-
const react_1 =
|
|
71
|
+
const react_1 = __importStar(require("react"));
|
|
16
72
|
const FormFileUpload_1 = __importDefault(
|
|
17
73
|
require("@theme/ApiExplorer/FormFileUpload")
|
|
18
74
|
);
|
|
75
|
+
const FormLabel_1 = __importDefault(require("@theme/ApiExplorer/FormLabel"));
|
|
19
76
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
20
77
|
const FormTextInput_1 = __importDefault(
|
|
21
78
|
require("@theme/ApiExplorer/FormTextInput")
|
|
22
79
|
);
|
|
23
80
|
const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
|
|
24
81
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
25
|
-
const slice_1 = require("../slice");
|
|
26
82
|
const FileArrayFormBodyItem_1 = __importDefault(
|
|
27
83
|
require("../FileArrayFormBodyItem")
|
|
28
84
|
);
|
|
29
|
-
|
|
85
|
+
const slice_1 = require("../slice");
|
|
86
|
+
const slice_2 = require("../../EncodingSelection/slice");
|
|
87
|
+
function FormBodyItem({
|
|
88
|
+
schemaObject,
|
|
89
|
+
id,
|
|
90
|
+
schema,
|
|
91
|
+
label,
|
|
92
|
+
required,
|
|
93
|
+
exampleValue,
|
|
94
|
+
fieldEncoding,
|
|
95
|
+
}) {
|
|
30
96
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
97
|
+
// Parse comma-separated encoding contentType into selectable options
|
|
98
|
+
const encodingOptions = fieldEncoding
|
|
99
|
+
? fieldEncoding
|
|
100
|
+
.split(",")
|
|
101
|
+
.map((t) => t.trim())
|
|
102
|
+
.filter(Boolean)
|
|
103
|
+
: [];
|
|
104
|
+
const hasMultipleEncodings = encodingOptions.length > 1;
|
|
105
|
+
// Initialize with the first declared content type
|
|
106
|
+
const [selectedEncoding, setSelectedEncoding] = (0, react_1.useState)(
|
|
107
|
+
encodingOptions[0] ?? ""
|
|
108
|
+
);
|
|
109
|
+
// Seed Redux with the first declared encoding on mount so the code snippet
|
|
110
|
+
// reflects a content type immediately, even before the user interacts.
|
|
111
|
+
// The empty dep array is intentional: `fieldEncoding` comes from a static
|
|
112
|
+
// spec value that never changes for the lifetime of this component instance,
|
|
113
|
+
// and re-seeding on every render would fight user selections.
|
|
114
|
+
(0, react_1.useEffect)(() => {
|
|
115
|
+
if (encodingOptions[0]) {
|
|
116
|
+
dispatch(
|
|
117
|
+
(0, slice_2.setFieldEncoding)({
|
|
118
|
+
field: id,
|
|
119
|
+
contentType: encodingOptions[0],
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
+
}, []);
|
|
125
|
+
const [value, setValue] = (0, react_1.useState)(() => {
|
|
126
|
+
let initialValue = exampleValue ?? "";
|
|
127
|
+
if (schemaObject.type === "object" && exampleValue) {
|
|
128
|
+
initialValue = JSON.stringify(exampleValue, null, 2);
|
|
129
|
+
}
|
|
130
|
+
return initialValue;
|
|
131
|
+
});
|
|
132
|
+
(0, react_1.useEffect)(() => {
|
|
133
|
+
if (value) {
|
|
134
|
+
dispatch((0, slice_1.setStringFormBody)({ key: id, value }));
|
|
135
|
+
} else {
|
|
136
|
+
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
137
|
+
}
|
|
138
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
139
|
+
}, []);
|
|
31
140
|
if (
|
|
32
141
|
schemaObject.type === "array" &&
|
|
33
142
|
schemaObject.items?.format === "binary"
|
|
34
143
|
) {
|
|
35
|
-
return react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
144
|
+
return react_1.default.createElement(
|
|
145
|
+
react_1.default.Fragment,
|
|
146
|
+
null,
|
|
147
|
+
label &&
|
|
148
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
149
|
+
label: label,
|
|
150
|
+
required: required,
|
|
151
|
+
}),
|
|
152
|
+
react_1.default.createElement(FileArrayFormBodyItem_1.default, {
|
|
153
|
+
id: id,
|
|
154
|
+
description: schemaObject.description,
|
|
155
|
+
})
|
|
156
|
+
);
|
|
39
157
|
}
|
|
40
158
|
if (schemaObject.format === "binary") {
|
|
41
|
-
return react_1.default.createElement(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
159
|
+
return react_1.default.createElement(
|
|
160
|
+
react_1.default.Fragment,
|
|
161
|
+
null,
|
|
162
|
+
label &&
|
|
163
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
164
|
+
label: label,
|
|
165
|
+
required: required,
|
|
166
|
+
}),
|
|
167
|
+
hasMultipleEncodings &&
|
|
168
|
+
react_1.default.createElement(
|
|
169
|
+
"div",
|
|
170
|
+
{ style: { marginTop: "0.5rem" } },
|
|
171
|
+
react_1.default.createElement(FormSelect_1.default, {
|
|
172
|
+
label: "Content-Type",
|
|
173
|
+
options: encodingOptions,
|
|
174
|
+
value: selectedEncoding,
|
|
175
|
+
onChange: (e) => {
|
|
176
|
+
const ct = e.target.value;
|
|
177
|
+
setSelectedEncoding(ct);
|
|
178
|
+
dispatch(
|
|
179
|
+
(0, slice_2.setFieldEncoding)({ field: id, contentType: ct })
|
|
180
|
+
);
|
|
54
181
|
},
|
|
55
182
|
})
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
183
|
+
),
|
|
184
|
+
react_1.default.createElement(FormFileUpload_1.default, {
|
|
185
|
+
placeholder: schemaObject.description || id,
|
|
186
|
+
onChange: (file) => {
|
|
187
|
+
if (file === undefined) {
|
|
188
|
+
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
dispatch(
|
|
192
|
+
(0, slice_1.setFileFormBody)({
|
|
193
|
+
key: id,
|
|
194
|
+
value: {
|
|
195
|
+
src: `/path/to/${file.name}`,
|
|
196
|
+
content: file,
|
|
197
|
+
},
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
})
|
|
68
202
|
);
|
|
203
|
+
}
|
|
204
|
+
if (schemaObject.type === "object") {
|
|
69
205
|
return react_1.default.createElement(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
206
|
+
react_1.default.Fragment,
|
|
207
|
+
null,
|
|
208
|
+
label &&
|
|
209
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
210
|
+
label: label,
|
|
211
|
+
required: required,
|
|
212
|
+
}),
|
|
213
|
+
react_1.default.createElement(
|
|
214
|
+
LiveEditor_1.default,
|
|
215
|
+
{
|
|
216
|
+
action: (code) =>
|
|
217
|
+
dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
|
|
218
|
+
},
|
|
219
|
+
value
|
|
220
|
+
)
|
|
76
221
|
);
|
|
77
222
|
}
|
|
78
223
|
if (
|
|
@@ -80,9 +225,13 @@ function FormBodyItem({ schemaObject, id, schema }) {
|
|
|
80
225
|
schemaObject.enum.every((value) => typeof value === "string")
|
|
81
226
|
) {
|
|
82
227
|
return react_1.default.createElement(FormSelect_1.default, {
|
|
228
|
+
label: label,
|
|
229
|
+
required: required,
|
|
230
|
+
value: value,
|
|
83
231
|
options: ["---", ...schemaObject.enum],
|
|
84
232
|
onChange: (e) => {
|
|
85
233
|
const val = e.target.value;
|
|
234
|
+
setValue(val);
|
|
86
235
|
if (val === "---") {
|
|
87
236
|
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
88
237
|
} else {
|
|
@@ -98,10 +247,14 @@ function FormBodyItem({ schemaObject, id, schema }) {
|
|
|
98
247
|
}
|
|
99
248
|
// TODO: support all the other types.
|
|
100
249
|
return react_1.default.createElement(FormTextInput_1.default, {
|
|
250
|
+
label: label,
|
|
251
|
+
required: required,
|
|
252
|
+
value: value,
|
|
101
253
|
paramName: id,
|
|
102
254
|
isRequired: Array.isArray(schema.required) && schema.required.includes(id),
|
|
103
255
|
placeholder: schemaObject.description || id,
|
|
104
256
|
onChange: (e) => {
|
|
257
|
+
setValue(e.target.value);
|
|
105
258
|
dispatch(
|
|
106
259
|
(0, slice_1.setStringFormBody)({ key: id, value: e.target.value })
|
|
107
260
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
2
|
+
import type { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
3
3
|
export interface Props {
|
|
4
4
|
jsonRequestBodyExample: string;
|
|
5
5
|
requestBodyMetadata?: RequestBodyObject;
|