docusaurus-theme-openapi-docs 4.5.1 → 4.7.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 +14 -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 +322 -193
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +13 -0
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.js +133 -0
- 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/SchemaSelection/index.d.ts +2 -0
- package/lib/theme/ApiExplorer/SchemaSelection/index.js +36 -0
- package/lib/theme/ApiExplorer/SchemaSelection/slice.d.ts +37 -0
- package/lib/theme/ApiExplorer/SchemaSelection/slice.js +39 -0
- 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 +4 -0
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +21 -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 +10 -9
- package/lib/theme/ApiItem/index.js +13 -8
- package/lib/theme/ApiItem/store.d.ts +61 -43
- package/lib/theme/ApiItem/store.js +6 -2
- 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 +68 -48
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +97 -82
- package/lib/theme/Schema/index.d.ts +6 -0
- package/lib/theme/Schema/index.js +240 -31
- package/lib/theme/SchemaItem/index.js +64 -36
- package/lib/theme/SchemaTabs/index.d.ts +8 -1
- package/lib/theme/SchemaTabs/index.js +14 -2
- package/lib/theme/StatusCodes/index.d.ts +1 -1
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/styles.scss +15 -0
- package/lib/theme/translationIds.d.ts +90 -0
- package/lib/theme/translationIds.js +114 -0
- package/package.json +28 -28
- package/src/markdown/schema.ts +17 -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 +262 -198
- package/{lib/types.js → src/theme/ApiExplorer/Body/json2xml.d.ts} +2 -2
- package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +155 -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/SchemaSelection/index.ts +13 -0
- package/src/theme/ApiExplorer/SchemaSelection/slice.ts +46 -0
- 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 +5 -0
- 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 +13 -7
- package/src/theme/ApiItem/store.ts +2 -0
- 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 +60 -35
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +73 -61
- package/src/theme/Schema/index.tsx +307 -55
- package/src/theme/SchemaItem/index.tsx +51 -33
- package/src/theme/SchemaTabs/index.tsx +19 -5
- package/src/theme/StatusCodes/index.tsx +13 -3
- package/src/theme/styles.scss +15 -0
- package/src/theme/translationIds.ts +111 -0
- package/src/theme-openapi.d.ts +7 -275
- package/src/{types.ts → types.d.ts} +9 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +0 -3
- package/lib/types.d.ts +0 -46
|
@@ -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
|
);
|