docusaurus-theme-openapi-docs 4.5.0 → 4.6.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/markdown/schema.js +9 -1
- package/lib/theme/ApiExplorer/Accept/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/Authorization/index.js +50 -9
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +145 -3
- package/lib/theme/ApiExplorer/Authorization/slice.js +3 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +126 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +110 -0
- package/lib/theme/ApiExplorer/Body/index.js +94 -100
- package/lib/theme/ApiExplorer/Body/slice.d.ts +1056 -11
- package/lib/theme/ApiExplorer/Body/slice.js +22 -2
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +37 -26
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +3 -3
- package/lib/theme/ApiExplorer/CodeTabs/index.js +2 -2
- package/lib/theme/ApiExplorer/ContentType/slice.d.ts +5 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +6 -1
- package/lib/theme/ApiExplorer/FormItem/index.js +6 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/FormTextInput/index.js +8 -1
- package/lib/theme/ApiExplorer/LiveEditor/index.js +11 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +15 -5
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +12 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +11 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.js +11 -1
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +0 -4
- package/lib/theme/ApiExplorer/ParamOptions/slice.js +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +110 -17
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +7 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +94 -24
- package/lib/theme/ApiExplorer/Response/index.js +34 -14
- package/lib/theme/ApiExplorer/Response/slice.d.ts +31 -7
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +208 -69
- package/lib/theme/ApiExplorer/Server/index.js +16 -2
- package/lib/theme/ApiExplorer/Server/slice.d.ts +49 -3
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -57
- package/lib/theme/ApiExplorer/index.js +11 -1
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +19 -0
- package/lib/theme/ApiExplorer/{persistanceMiddleware.js → persistenceMiddleware.js} +16 -9
- package/lib/theme/ApiExplorer/storage-utils.d.ts +2 -2
- package/lib/theme/ApiExplorer/storage-utils.js +3 -3
- package/lib/theme/ApiItem/Layout/index.d.ts +1 -1
- package/lib/theme/ApiItem/hooks.d.ts +9 -9
- package/lib/theme/ApiItem/index.js +12 -8
- package/lib/theme/ApiItem/store.d.ts +55 -43
- package/lib/theme/ApiTabs/index.js +6 -1
- package/lib/theme/Example/_Example.scss +11 -0
- package/lib/theme/Example/index.d.ts +24 -0
- package/lib/theme/Example/index.js +170 -0
- package/lib/theme/ParamsDetails/index.js +9 -1
- package/lib/theme/ParamsItem/index.d.ts +1 -1
- package/lib/theme/ParamsItem/index.js +43 -74
- package/lib/theme/RequestSchema/index.js +18 -4
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +97 -82
- package/lib/theme/Schema/index.js +106 -23
- package/lib/theme/SchemaItem/index.js +64 -36
- package/lib/theme/SchemaTabs/index.js +4 -1
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/styles.scss +5 -0
- package/lib/theme/translationIds.d.ts +90 -0
- package/lib/theme/translationIds.js +114 -0
- package/lib/types.d.ts +9 -1
- package/package.json +28 -28
- package/src/markdown/schema.ts +11 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +51 -10
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +77 -0
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +120 -0
- package/src/theme/ApiExplorer/Body/index.tsx +87 -107
- package/src/theme/ApiExplorer/Body/json2xml.d.ts +8 -0
- package/src/theme/ApiExplorer/Body/slice.ts +40 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +43 -29
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +5 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +6 -5
- package/src/theme/ApiExplorer/ContentType/index.tsx +1 -1
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +6 -1
- package/src/theme/ApiExplorer/FormItem/index.tsx +8 -1
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +10 -1
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +11 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +16 -6
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -3
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +10 -2
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/index.tsx +108 -17
- package/src/theme/ApiExplorer/Request/makeRequest.ts +106 -25
- package/src/theme/ApiExplorer/Response/index.tsx +30 -8
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +157 -69
- package/src/theme/ApiExplorer/Server/index.tsx +12 -4
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +47 -63
- package/src/theme/ApiExplorer/index.tsx +10 -1
- package/src/theme/ApiExplorer/{persistanceMiddleware.ts → persistenceMiddleware.ts} +23 -13
- package/src/theme/ApiExplorer/storage-utils.ts +4 -4
- package/src/theme/ApiItem/Layout/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +12 -7
- package/src/theme/ApiTabs/index.tsx +6 -1
- package/src/theme/Example/_Example.scss +11 -0
- package/src/theme/Example/index.tsx +168 -0
- package/src/theme/Markdown/index.d.ts +8 -0
- package/src/theme/ParamsDetails/index.tsx +10 -1
- package/src/theme/ParamsItem/index.tsx +38 -54
- package/src/theme/RequestSchema/index.tsx +19 -4
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +73 -61
- package/src/theme/Schema/index.tsx +128 -33
- package/src/theme/SchemaItem/index.tsx +51 -33
- package/src/theme/SchemaTabs/index.tsx +4 -1
- package/src/theme/StatusCodes/index.tsx +13 -2
- package/src/theme/styles.scss +5 -0
- package/src/theme/translationIds.ts +111 -0
- package/src/theme-openapi.d.ts +7 -275
- package/src/types.ts +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +0 -3
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
import { Example } from "@theme/Example";
|
|
10
12
|
import Markdown from "@theme/Markdown";
|
|
11
|
-
import SchemaTabs from "@theme/SchemaTabs";
|
|
12
|
-
import TabItem from "@theme/TabItem";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
+
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
14
15
|
import clsx from "clsx";
|
|
15
16
|
|
|
16
17
|
import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
|
|
17
|
-
import { guard
|
|
18
|
+
import { guard } from "../../markdown/utils";
|
|
18
19
|
|
|
19
20
|
export interface ExampleObject {
|
|
20
21
|
summary?: string;
|
|
@@ -28,7 +29,7 @@ export interface Props {
|
|
|
28
29
|
param: {
|
|
29
30
|
description: string;
|
|
30
31
|
example: any;
|
|
31
|
-
examples: Record<string, ExampleObject
|
|
32
|
+
examples: Record<string, ExampleObject> | undefined;
|
|
32
33
|
name: string;
|
|
33
34
|
required: boolean;
|
|
34
35
|
deprecated: boolean;
|
|
@@ -39,7 +40,15 @@ export interface Props {
|
|
|
39
40
|
|
|
40
41
|
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
41
42
|
if (enumDescriptions?.length) {
|
|
42
|
-
|
|
43
|
+
const enumValue = translate({
|
|
44
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
45
|
+
message: "Enum Value",
|
|
46
|
+
});
|
|
47
|
+
const description = translate({
|
|
48
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
49
|
+
message: "Description",
|
|
50
|
+
});
|
|
51
|
+
return `| ${enumValue} | ${description} |
|
|
43
52
|
| ---- | ----- |
|
|
44
53
|
${enumDescriptions
|
|
45
54
|
.map((desc) => {
|
|
@@ -53,19 +62,14 @@ ${enumDescriptions
|
|
|
53
62
|
};
|
|
54
63
|
|
|
55
64
|
function ParamsItem({ param, ...rest }: Props) {
|
|
56
|
-
const {
|
|
57
|
-
description,
|
|
58
|
-
example,
|
|
59
|
-
examples,
|
|
60
|
-
name,
|
|
61
|
-
required,
|
|
62
|
-
deprecated,
|
|
63
|
-
enumDescriptions,
|
|
64
|
-
} = param;
|
|
65
|
+
const { description, name, required, deprecated, enumDescriptions } = param;
|
|
65
66
|
|
|
66
67
|
let schema = param.schema;
|
|
67
68
|
let defaultValue: string | undefined;
|
|
68
69
|
|
|
70
|
+
let examples = param.examples ?? (schema?.examples as any[] | undefined);
|
|
71
|
+
let example = param.example ?? schema?.example;
|
|
72
|
+
|
|
69
73
|
if (!schema) {
|
|
70
74
|
schema = { type: "any" };
|
|
71
75
|
}
|
|
@@ -87,11 +91,15 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
87
91
|
));
|
|
88
92
|
|
|
89
93
|
const renderSchemaRequired = guard(required, () => (
|
|
90
|
-
<span className="openapi-schema__required">
|
|
94
|
+
<span className="openapi-schema__required">
|
|
95
|
+
{translate({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })}
|
|
96
|
+
</span>
|
|
91
97
|
));
|
|
92
98
|
|
|
93
99
|
const renderDeprecated = guard(deprecated, () => (
|
|
94
|
-
<span className="openapi-schema__deprecated">
|
|
100
|
+
<span className="openapi-schema__deprecated">
|
|
101
|
+
{translate({ id: OPENAPI_SCHEMA_ITEM.DEPRECATED, message: "deprecated" })}
|
|
102
|
+
</span>
|
|
95
103
|
));
|
|
96
104
|
|
|
97
105
|
const renderQualifier = guard(getQualifierMessage(schema), (qualifier) => (
|
|
@@ -118,7 +126,12 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
118
126
|
if (typeof defaultValue === "string") {
|
|
119
127
|
return (
|
|
120
128
|
<div>
|
|
121
|
-
<strong>
|
|
129
|
+
<strong>
|
|
130
|
+
{translate({
|
|
131
|
+
id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
|
|
132
|
+
message: "Default value:",
|
|
133
|
+
})}{" "}
|
|
134
|
+
</strong>
|
|
122
135
|
<span>
|
|
123
136
|
<code>{defaultValue}</code>
|
|
124
137
|
</span>
|
|
@@ -127,7 +140,12 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
127
140
|
}
|
|
128
141
|
return (
|
|
129
142
|
<div>
|
|
130
|
-
<strong>
|
|
143
|
+
<strong>
|
|
144
|
+
{translate({
|
|
145
|
+
id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
|
|
146
|
+
message: "Default value:",
|
|
147
|
+
})}{" "}
|
|
148
|
+
</strong>
|
|
131
149
|
<span>
|
|
132
150
|
<code>{JSON.stringify(defaultValue)}</code>
|
|
133
151
|
</span>
|
|
@@ -137,40 +155,6 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
137
155
|
return undefined;
|
|
138
156
|
}
|
|
139
157
|
|
|
140
|
-
const renderExample = guard(toString(example), (example) => (
|
|
141
|
-
<div>
|
|
142
|
-
<strong>Example: </strong>
|
|
143
|
-
{example}
|
|
144
|
-
</div>
|
|
145
|
-
));
|
|
146
|
-
|
|
147
|
-
const renderExamples = guard(examples, (examples) => {
|
|
148
|
-
const exampleEntries = Object.entries(examples);
|
|
149
|
-
return (
|
|
150
|
-
<>
|
|
151
|
-
<strong>Examples:</strong>
|
|
152
|
-
<SchemaTabs>
|
|
153
|
-
{exampleEntries.map(([exampleName, exampleProperties]) => (
|
|
154
|
-
// @ts-ignore
|
|
155
|
-
<TabItem value={exampleName} label={exampleName}>
|
|
156
|
-
{exampleProperties.summary && <p>{exampleProperties.summary}</p>}
|
|
157
|
-
{exampleProperties.description && (
|
|
158
|
-
<p>
|
|
159
|
-
<strong>Description: </strong>
|
|
160
|
-
<span>{exampleProperties.description}</span>
|
|
161
|
-
</p>
|
|
162
|
-
)}
|
|
163
|
-
<p>
|
|
164
|
-
<strong>Example: </strong>
|
|
165
|
-
<code>{exampleProperties.value}</code>
|
|
166
|
-
</p>
|
|
167
|
-
</TabItem>
|
|
168
|
-
))}
|
|
169
|
-
</SchemaTabs>
|
|
170
|
-
</>
|
|
171
|
-
);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
158
|
return (
|
|
175
159
|
<div className="openapi-params__list-item">
|
|
176
160
|
<span className="openapi-schema__container">
|
|
@@ -192,8 +176,8 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
192
176
|
{renderDescription}
|
|
193
177
|
{renderEnumDescriptions}
|
|
194
178
|
{renderDefaultValue()}
|
|
195
|
-
{
|
|
196
|
-
{
|
|
179
|
+
<Example example={example} />
|
|
180
|
+
<Example examples={examples} />
|
|
197
181
|
</div>
|
|
198
182
|
);
|
|
199
183
|
}
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
12
|
+
|
|
10
13
|
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
14
|
import Details from "@theme/Details";
|
|
12
15
|
import Markdown from "@theme/Markdown";
|
|
@@ -64,10 +67,16 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
64
67
|
<>
|
|
65
68
|
<summary>
|
|
66
69
|
<h3 className="openapi-markdown__details-summary-header-body">
|
|
67
|
-
{
|
|
70
|
+
{translate({
|
|
71
|
+
id: OPENAPI_REQUEST.BODY_TITLE,
|
|
72
|
+
message: title,
|
|
73
|
+
})}
|
|
68
74
|
{body.required === true && (
|
|
69
75
|
<span className="openapi-schema__required">
|
|
70
|
-
|
|
76
|
+
{translate({
|
|
77
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
78
|
+
message: "required",
|
|
79
|
+
})}
|
|
71
80
|
</span>
|
|
72
81
|
)}
|
|
73
82
|
</h3>
|
|
@@ -114,13 +123,19 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
114
123
|
<>
|
|
115
124
|
<summary>
|
|
116
125
|
<h3 className="openapi-markdown__details-summary-header-body">
|
|
117
|
-
{
|
|
126
|
+
{translate({
|
|
127
|
+
id: OPENAPI_REQUEST.BODY_TITLE,
|
|
128
|
+
message: title,
|
|
129
|
+
})}
|
|
118
130
|
{firstBody.type === "array" && (
|
|
119
131
|
<span style={{ opacity: "0.6" }}> array</span>
|
|
120
132
|
)}
|
|
121
133
|
{body.required && (
|
|
122
134
|
<strong className="openapi-schema__required">
|
|
123
|
-
|
|
135
|
+
{translate({
|
|
136
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
137
|
+
message: "required",
|
|
138
|
+
})}
|
|
124
139
|
</strong>
|
|
125
140
|
)}
|
|
126
141
|
</h3>
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import CodeSamples from "@theme/CodeSamples";
|
|
11
12
|
import Markdown from "@theme/Markdown";
|
|
12
13
|
import TabItem from "@theme/TabItem";
|
|
14
|
+
import { OPENAPI_RESPONSE_EXAMPLES } from "@theme/translationIds";
|
|
13
15
|
import { sampleResponseFromSchema } from "docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample";
|
|
14
16
|
import format from "xml-formatter";
|
|
15
17
|
|
|
@@ -111,7 +113,13 @@ export const ResponseExample: React.FC<ResponseExampleProps> = ({
|
|
|
111
113
|
|
|
112
114
|
return (
|
|
113
115
|
// @ts-ignore
|
|
114
|
-
<TabItem
|
|
116
|
+
<TabItem
|
|
117
|
+
label={translate({
|
|
118
|
+
id: OPENAPI_RESPONSE_EXAMPLES.EXAMPLE,
|
|
119
|
+
message: "Example",
|
|
120
|
+
})}
|
|
121
|
+
value="Example"
|
|
122
|
+
>
|
|
115
123
|
{responseExample.summary && (
|
|
116
124
|
<Markdown className="openapi-example__summary">
|
|
117
125
|
{responseExample.summary}
|
|
@@ -163,7 +171,13 @@ export const ExampleFromSchema: React.FC<ExampleFromSchemaProps> = ({
|
|
|
163
171
|
}
|
|
164
172
|
return (
|
|
165
173
|
// @ts-ignore
|
|
166
|
-
<TabItem
|
|
174
|
+
<TabItem
|
|
175
|
+
label={translate({
|
|
176
|
+
id: OPENAPI_RESPONSE_EXAMPLES.AUTO_EXAMPLE,
|
|
177
|
+
message: "Example (auto)",
|
|
178
|
+
})}
|
|
179
|
+
value="Example (auto)"
|
|
180
|
+
>
|
|
167
181
|
<CodeSamples example={xmlExample} language="xml" />
|
|
168
182
|
</TabItem>
|
|
169
183
|
);
|
|
@@ -176,7 +190,13 @@ export const ExampleFromSchema: React.FC<ExampleFromSchemaProps> = ({
|
|
|
176
190
|
) {
|
|
177
191
|
return (
|
|
178
192
|
// @ts-ignore
|
|
179
|
-
<TabItem
|
|
193
|
+
<TabItem
|
|
194
|
+
label={translate({
|
|
195
|
+
id: OPENAPI_RESPONSE_EXAMPLES.AUTO_EXAMPLE,
|
|
196
|
+
message: "Example (auto)",
|
|
197
|
+
})}
|
|
198
|
+
value="Example (auto)"
|
|
199
|
+
>
|
|
180
200
|
<CodeSamples
|
|
181
201
|
example={JSON.stringify(responseExample, null, 2)}
|
|
182
202
|
language="json"
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
10
|
import BrowserOnly from "@docusaurus/BrowserOnly";
|
|
11
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
12
|
import Details from "@theme/Details";
|
|
12
13
|
import Markdown from "@theme/Markdown";
|
|
13
14
|
import MimeTabs from "@theme/MimeTabs"; // Assume these components exist
|
|
@@ -20,6 +21,7 @@ import SchemaNode from "@theme/Schema";
|
|
|
20
21
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
21
22
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
22
23
|
import TabItem from "@theme/TabItem";
|
|
24
|
+
import { OPENAPI_SCHEMA, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
23
25
|
import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
|
|
24
26
|
|
|
25
27
|
interface Props {
|
|
@@ -54,76 +56,86 @@ const ResponseSchemaComponent: React.FC<Props> = ({
|
|
|
54
56
|
return (
|
|
55
57
|
<MimeTabs className="openapi-tabs__mime" schemaType="response">
|
|
56
58
|
{mimeTypes.map((mimeType: any) => {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const mediaTypeObject = body.content?.[mimeType];
|
|
60
|
+
const responseExamples = mediaTypeObject?.examples;
|
|
61
|
+
const responseExample = mediaTypeObject?.example;
|
|
62
|
+
const firstBody = mediaTypeObject?.schema;
|
|
61
63
|
|
|
62
64
|
if (
|
|
63
|
-
firstBody
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
!firstBody ||
|
|
66
|
+
(firstBody.properties &&
|
|
67
|
+
Object.keys(firstBody.properties).length === 0)
|
|
66
68
|
) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (firstBody) {
|
|
71
69
|
return (
|
|
72
70
|
// @ts-ignore
|
|
73
71
|
<TabItem key={mimeType} label={mimeType} value={mimeType}>
|
|
74
|
-
<
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
open={true}
|
|
81
|
-
style={style}
|
|
82
|
-
summary={
|
|
83
|
-
<>
|
|
84
|
-
<summary>
|
|
85
|
-
<strong className="openapi-markdown__details-summary-response">
|
|
86
|
-
{title}
|
|
87
|
-
{body.required === true && (
|
|
88
|
-
<span className="openapi-schema__required">
|
|
89
|
-
required
|
|
90
|
-
</span>
|
|
91
|
-
)}
|
|
92
|
-
</strong>
|
|
93
|
-
</summary>
|
|
94
|
-
</>
|
|
95
|
-
}
|
|
96
|
-
>
|
|
97
|
-
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
98
|
-
{body.description && (
|
|
99
|
-
<div
|
|
100
|
-
style={{ marginTop: "1rem", marginBottom: "1rem" }}
|
|
101
|
-
>
|
|
102
|
-
<Markdown>{body.description}</Markdown>
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
105
|
-
</div>
|
|
106
|
-
<ul style={{ marginLeft: "1rem" }}>
|
|
107
|
-
<SchemaNode schema={firstBody} schemaType="response" />
|
|
108
|
-
</ul>
|
|
109
|
-
</Details>
|
|
110
|
-
</TabItem>
|
|
111
|
-
{firstBody &&
|
|
112
|
-
ExampleFromSchema({
|
|
113
|
-
schema: firstBody,
|
|
114
|
-
mimeType: mimeType,
|
|
115
|
-
})}
|
|
116
|
-
|
|
117
|
-
{responseExamples &&
|
|
118
|
-
ResponseExamples({ responseExamples, mimeType })}
|
|
119
|
-
|
|
120
|
-
{responseExample &&
|
|
121
|
-
ResponseExample({ responseExample, mimeType })}
|
|
122
|
-
</SchemaTabs>
|
|
72
|
+
<div>
|
|
73
|
+
{translate({
|
|
74
|
+
id: OPENAPI_SCHEMA.NO_SCHEMA,
|
|
75
|
+
message: "No schema",
|
|
76
|
+
})}
|
|
77
|
+
</div>
|
|
123
78
|
</TabItem>
|
|
124
79
|
);
|
|
125
80
|
}
|
|
126
|
-
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
<TabItem key={mimeType} label={mimeType} value={mimeType}>
|
|
85
|
+
<SchemaTabs className="openapi-tabs__schema">
|
|
86
|
+
{/* @ts-ignore */}
|
|
87
|
+
<TabItem key={title} label={title} value={title}>
|
|
88
|
+
<Details
|
|
89
|
+
className="openapi-markdown__details response"
|
|
90
|
+
data-collapsed={false}
|
|
91
|
+
open={true}
|
|
92
|
+
style={style}
|
|
93
|
+
summary={
|
|
94
|
+
<>
|
|
95
|
+
<summary>
|
|
96
|
+
<strong className="openapi-markdown__details-summary-response">
|
|
97
|
+
{title}
|
|
98
|
+
{body.required === true && (
|
|
99
|
+
<span className="openapi-schema__required">
|
|
100
|
+
{translate({
|
|
101
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
102
|
+
message: "required",
|
|
103
|
+
})}
|
|
104
|
+
</span>
|
|
105
|
+
)}
|
|
106
|
+
</strong>
|
|
107
|
+
</summary>
|
|
108
|
+
</>
|
|
109
|
+
}
|
|
110
|
+
>
|
|
111
|
+
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
112
|
+
{body.description && (
|
|
113
|
+
<div
|
|
114
|
+
style={{ marginTop: "1rem", marginBottom: "1rem" }}
|
|
115
|
+
>
|
|
116
|
+
<Markdown>{body.description}</Markdown>
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
<ul style={{ marginLeft: "1rem" }}>
|
|
121
|
+
<SchemaNode schema={firstBody} schemaType="response" />
|
|
122
|
+
</ul>
|
|
123
|
+
</Details>
|
|
124
|
+
</TabItem>
|
|
125
|
+
{firstBody &&
|
|
126
|
+
ExampleFromSchema({
|
|
127
|
+
schema: firstBody,
|
|
128
|
+
mimeType: mimeType,
|
|
129
|
+
})}
|
|
130
|
+
|
|
131
|
+
{responseExamples &&
|
|
132
|
+
ResponseExamples({ responseExamples, mimeType })}
|
|
133
|
+
|
|
134
|
+
{responseExample &&
|
|
135
|
+
ResponseExample({ responseExample, mimeType })}
|
|
136
|
+
</SchemaTabs>
|
|
137
|
+
</TabItem>
|
|
138
|
+
);
|
|
127
139
|
})}
|
|
128
140
|
</MimeTabs>
|
|
129
141
|
);
|