docusaurus-theme-openapi-docs 5.0.2 → 5.1.1
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 +38 -15
- package/lib/markdown/schema.test.d.ts +1 -0
- package/lib/markdown/schema.test.js +86 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +4 -2
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +9 -6
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +9 -10
- package/lib/theme/ApiExplorer/Body/index.js +4 -5
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +96 -61
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +12 -1
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.d.ts +1 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.test.js +102 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.js +6 -5
- package/lib/theme/ApiExplorer/Export/index.js +9 -2
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +1 -2
- package/lib/theme/ApiExplorer/FormLabel/index.js +1 -2
- package/lib/theme/ApiExplorer/FormTextInput/index.js +1 -2
- package/lib/theme/ApiExplorer/LiveEditor/index.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +5 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +75 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +1 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +67 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +65 -1
- package/lib/theme/ApiExplorer/ParamOptions/index.js +2 -3
- package/lib/theme/ApiExplorer/Request/index.js +17 -18
- package/lib/theme/ApiExplorer/Response/index.js +54 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +57 -50
- package/lib/theme/ApiExplorer/Server/index.js +2 -3
- package/lib/theme/ApiItem/index.js +59 -33
- package/lib/theme/ApiTabs/index.d.ts +1 -1
- package/lib/theme/ApiTabs/index.js +7 -7
- package/lib/theme/DiscriminatorTabs/index.d.ts +1 -1
- package/lib/theme/DiscriminatorTabs/index.js +6 -5
- package/lib/theme/Example/index.js +3 -4
- package/lib/theme/MimeTabs/index.d.ts +1 -1
- package/lib/theme/MimeTabs/index.js +6 -5
- package/lib/theme/OperationTabs/index.d.ts +1 -1
- package/lib/theme/OperationTabs/index.js +6 -5
- package/lib/theme/ParamsDetails/index.js +1 -2
- package/lib/theme/ParamsItem/index.js +7 -8
- package/lib/theme/RequestSchema/index.js +57 -57
- package/lib/theme/ResponseExamples/index.js +3 -4
- package/lib/theme/ResponseSchema/index.js +26 -24
- package/lib/theme/Schema/index.js +148 -110
- package/lib/theme/Schema/normalize.d.ts +41 -0
- package/lib/theme/Schema/normalize.js +210 -0
- package/lib/theme/Schema/normalize.test.d.ts +1 -0
- package/lib/theme/Schema/normalize.test.js +271 -0
- package/lib/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/lib/theme/SchemaExpansion/context.d.ts +24 -0
- package/lib/theme/SchemaExpansion/context.js +187 -0
- package/lib/theme/SchemaExpansion/index.d.ts +4 -0
- package/lib/theme/SchemaExpansion/index.js +314 -0
- package/lib/theme/SchemaItem/index.js +9 -10
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +6 -5
- package/lib/theme/StatusCodes/index.js +2 -4
- package/lib/theme/TabItem/index.d.ts +5 -0
- package/lib/theme/TabItem/index.js +51 -0
- package/lib/theme/TabItem/styles.module.css +3 -0
- package/lib/theme/Tabs/index.d.ts +5 -0
- package/lib/theme/Tabs/index.js +148 -0
- package/lib/theme/Tabs/styles.module.css +7 -0
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +1 -93
- package/lib/theme/translationIds.js +0 -109
- package/lib/theme/utils/codeBlockUtils.d.ts +28 -0
- package/lib/theme/utils/codeBlockUtils.js +223 -0
- package/lib/theme/utils/reactUtils.d.ts +1 -0
- package/lib/theme/utils/reactUtils.js +23 -0
- package/lib/theme/utils/scrollUtils.d.ts +7 -0
- package/lib/theme/utils/scrollUtils.js +175 -0
- package/lib/theme/utils/tabsUtils.d.ts +47 -0
- package/lib/theme/utils/tabsUtils.js +299 -0
- package/lib/theme/utils/useCodeWordWrap.d.ts +8 -0
- package/lib/theme/utils/useCodeWordWrap.js +84 -0
- package/lib/theme/utils/useMutationObserver.d.ts +3 -0
- package/lib/theme/utils/useMutationObserver.js +34 -0
- package/package.json +4 -4
- package/src/markdown/schema.test.ts +102 -0
- package/src/markdown/schema.ts +42 -15
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +8 -7
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +1 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +9 -10
- package/src/theme/ApiExplorer/Body/index.tsx +7 -5
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +103 -59
- package/src/theme/ApiExplorer/CodeSnippets/languages.test.ts +109 -0
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +13 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +5 -5
- package/src/theme/ApiExplorer/Export/index.tsx +6 -2
- package/src/theme/ApiExplorer/FormFileUpload/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormLabel/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +1 -2
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +5 -3
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +20 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +1 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +15 -4
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +11 -1
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +2 -3
- package/src/theme/ApiExplorer/Request/index.tsx +23 -18
- package/src/theme/ApiExplorer/Response/index.tsx +63 -9
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +60 -52
- package/src/theme/ApiExplorer/Server/index.tsx +8 -3
- package/src/theme/ApiItem/index.tsx +43 -21
- package/src/theme/ApiTabs/index.tsx +8 -8
- package/src/theme/DiscriminatorTabs/index.tsx +6 -5
- package/src/theme/Example/index.tsx +3 -4
- package/src/theme/MimeTabs/index.tsx +9 -8
- package/src/theme/OperationTabs/index.tsx +5 -4
- package/src/theme/ParamsDetails/index.tsx +1 -2
- package/src/theme/ParamsItem/index.tsx +13 -8
- package/src/theme/RequestSchema/index.tsx +38 -40
- package/src/theme/ResponseExamples/index.tsx +3 -4
- package/src/theme/ResponseSchema/index.tsx +16 -17
- package/src/theme/Schema/index.tsx +154 -121
- package/src/theme/Schema/normalize.test.ts +288 -0
- package/src/theme/Schema/normalize.ts +224 -0
- package/src/theme/SchemaExpansion/_SchemaExpansion.scss +113 -0
- package/src/theme/SchemaExpansion/context.tsx +154 -0
- package/src/theme/SchemaExpansion/index.tsx +236 -0
- package/src/theme/SchemaItem/index.tsx +18 -10
- package/src/theme/SchemaTabs/index.tsx +6 -5
- package/src/theme/StatusCodes/index.tsx +2 -3
- package/src/theme/TabItem/index.tsx +61 -0
- package/src/theme/TabItem/styles.module.css +3 -0
- package/src/theme/Tabs/index.tsx +164 -0
- package/src/theme/Tabs/styles.module.css +7 -0
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +37 -106
- package/src/theme/utils/codeBlockUtils.ts +296 -0
- package/src/theme/utils/reactUtils.ts +22 -0
- package/src/theme/utils/scrollUtils.tsx +153 -0
- package/src/theme/utils/tabsUtils.tsx +329 -0
- package/src/theme/utils/useCodeWordWrap.ts +110 -0
- package/src/theme/utils/useMutationObserver.ts +43 -0
- package/src/theme-classic.d.ts +0 -96
- package/src/types.d.ts +27 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -12,7 +12,6 @@ import { translate } from "@docusaurus/Translate";
|
|
|
12
12
|
import Details from "@theme/Details";
|
|
13
13
|
import ParamsItem from "@theme/ParamsItem";
|
|
14
14
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
15
|
-
import { OPENAPI_PARAMS_DETAILS } from "@theme/translationIds";
|
|
16
15
|
|
|
17
16
|
interface Props {
|
|
18
17
|
parameters: any[];
|
|
@@ -35,7 +34,7 @@ const ParamsDetailsComponent: React.FC<Props> = ({ parameters }) => {
|
|
|
35
34
|
<h3 className="openapi-markdown__details-summary-header-params">
|
|
36
35
|
{translate(
|
|
37
36
|
{
|
|
38
|
-
id:
|
|
37
|
+
id: "theme.openapi.paramsDetails.parametersTitle",
|
|
39
38
|
message: "{type} Parameters",
|
|
40
39
|
},
|
|
41
40
|
{ type: type.charAt(0).toUpperCase() + type.slice(1) }
|
|
@@ -11,7 +11,6 @@ import { translate } from "@docusaurus/Translate";
|
|
|
11
11
|
import { Example } from "@theme/Example";
|
|
12
12
|
import Markdown from "@theme/Markdown";
|
|
13
13
|
/* eslint-disable import/no-extraneous-dependencies*/
|
|
14
|
-
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
15
14
|
import clsx from "clsx";
|
|
16
15
|
|
|
17
16
|
import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
|
|
@@ -41,11 +40,11 @@ export interface Props {
|
|
|
41
40
|
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
42
41
|
if (enumDescriptions?.length) {
|
|
43
42
|
const enumValue = translate({
|
|
44
|
-
id:
|
|
43
|
+
id: "theme.openapi.schemaItem.enumValue",
|
|
45
44
|
message: "Enum Value",
|
|
46
45
|
});
|
|
47
46
|
const description = translate({
|
|
48
|
-
id:
|
|
47
|
+
id: "theme.openapi.schemaItem.enumDescription",
|
|
49
48
|
message: "Description",
|
|
50
49
|
});
|
|
51
50
|
return `| ${enumValue} | ${description} |
|
|
@@ -92,13 +91,19 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
92
91
|
|
|
93
92
|
const renderSchemaRequired = guard(required, () => (
|
|
94
93
|
<span className="openapi-schema__required">
|
|
95
|
-
{translate({
|
|
94
|
+
{translate({
|
|
95
|
+
id: "theme.openapi.schemaItem.required",
|
|
96
|
+
message: "required",
|
|
97
|
+
})}
|
|
96
98
|
</span>
|
|
97
99
|
));
|
|
98
100
|
|
|
99
101
|
const renderDeprecated = guard(deprecated, () => (
|
|
100
102
|
<span className="openapi-schema__deprecated">
|
|
101
|
-
{translate({
|
|
103
|
+
{translate({
|
|
104
|
+
id: "theme.openapi.schemaItem.deprecated",
|
|
105
|
+
message: "deprecated",
|
|
106
|
+
})}
|
|
102
107
|
</span>
|
|
103
108
|
));
|
|
104
109
|
|
|
@@ -113,7 +118,7 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
113
118
|
return undefined;
|
|
114
119
|
}
|
|
115
120
|
const label = translate({
|
|
116
|
-
id:
|
|
121
|
+
id: "theme.openapi.schemaItem.constantValue",
|
|
117
122
|
message: "Constant value:",
|
|
118
123
|
});
|
|
119
124
|
return (
|
|
@@ -152,7 +157,7 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
152
157
|
<div>
|
|
153
158
|
<strong>
|
|
154
159
|
{translate({
|
|
155
|
-
id:
|
|
160
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
156
161
|
message: "Default value:",
|
|
157
162
|
})}{" "}
|
|
158
163
|
</strong>
|
|
@@ -166,7 +171,7 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
166
171
|
<div>
|
|
167
172
|
<strong>
|
|
168
173
|
{translate({
|
|
169
|
-
id:
|
|
174
|
+
id: "theme.openapi.schemaItem.defaultValue",
|
|
170
175
|
message: "Default value:",
|
|
171
176
|
})}{" "}
|
|
172
177
|
</strong>
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
ResponseExamples,
|
|
19
19
|
} from "@theme/ResponseExamples";
|
|
20
20
|
import SchemaNode from "@theme/Schema";
|
|
21
|
+
import SchemaExpansionControl from "@theme/SchemaExpansion";
|
|
21
22
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
22
23
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
23
24
|
import TabItem from "@theme/TabItem";
|
|
24
|
-
import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
25
25
|
import type { MediaTypeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
26
26
|
|
|
27
27
|
interface Props {
|
|
@@ -77,24 +77,23 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
77
77
|
open={true}
|
|
78
78
|
style={style}
|
|
79
79
|
summary={
|
|
80
|
-
|
|
81
|
-
<summary>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
</>
|
|
80
|
+
<summary className="openapi-markdown__details-summary--with-control">
|
|
81
|
+
<h3 className="openapi-markdown__details-summary-header-body">
|
|
82
|
+
{translate({
|
|
83
|
+
id: "theme.openapi.request.body.title",
|
|
84
|
+
message: title,
|
|
85
|
+
})}
|
|
86
|
+
{body.required === true && (
|
|
87
|
+
<span className="openapi-schema__required">
|
|
88
|
+
{translate({
|
|
89
|
+
id: "theme.openapi.schemaItem.required",
|
|
90
|
+
message: "required",
|
|
91
|
+
})}
|
|
92
|
+
</span>
|
|
93
|
+
)}
|
|
94
|
+
</h3>
|
|
95
|
+
<SchemaExpansionControl />
|
|
96
|
+
</summary>
|
|
98
97
|
}
|
|
99
98
|
>
|
|
100
99
|
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
@@ -164,27 +163,26 @@ const RequestSchemaComponent: React.FC<Props> = ({ title, body, style }) => {
|
|
|
164
163
|
open={true}
|
|
165
164
|
style={style}
|
|
166
165
|
summary={
|
|
167
|
-
|
|
168
|
-
<summary>
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
</>
|
|
166
|
+
<summary className="openapi-markdown__details-summary--with-control">
|
|
167
|
+
<h3 className="openapi-markdown__details-summary-header-body">
|
|
168
|
+
{translate({
|
|
169
|
+
id: "theme.openapi.request.body.title",
|
|
170
|
+
message: title,
|
|
171
|
+
})}
|
|
172
|
+
{firstBody.type === "array" && (
|
|
173
|
+
<span style={{ opacity: "0.6" }}> array</span>
|
|
174
|
+
)}
|
|
175
|
+
{body.required && (
|
|
176
|
+
<strong className="openapi-schema__required">
|
|
177
|
+
{translate({
|
|
178
|
+
id: "theme.openapi.schemaItem.required",
|
|
179
|
+
message: "required",
|
|
180
|
+
})}
|
|
181
|
+
</strong>
|
|
182
|
+
)}
|
|
183
|
+
</h3>
|
|
184
|
+
<SchemaExpansionControl />
|
|
185
|
+
</summary>
|
|
188
186
|
}
|
|
189
187
|
>
|
|
190
188
|
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|
|
@@ -11,7 +11,6 @@ import { translate } from "@docusaurus/Translate";
|
|
|
11
11
|
import CodeSamples from "@theme/CodeSamples";
|
|
12
12
|
import Markdown from "@theme/Markdown";
|
|
13
13
|
import TabItem from "@theme/TabItem";
|
|
14
|
-
import { OPENAPI_RESPONSE_EXAMPLES } from "@theme/translationIds";
|
|
15
14
|
import { sampleResponseFromSchema } from "docusaurus-plugin-openapi-docs/lib/openapi/createResponseExample";
|
|
16
15
|
import format from "xml-formatter";
|
|
17
16
|
|
|
@@ -115,7 +114,7 @@ export const ResponseExample: React.FC<ResponseExampleProps> = ({
|
|
|
115
114
|
// @ts-ignore
|
|
116
115
|
<TabItem
|
|
117
116
|
label={translate({
|
|
118
|
-
id:
|
|
117
|
+
id: "theme.openapi.responseExamples.example",
|
|
119
118
|
message: "Example",
|
|
120
119
|
})}
|
|
121
120
|
value="Example"
|
|
@@ -173,7 +172,7 @@ export const ExampleFromSchema: React.FC<ExampleFromSchemaProps> = ({
|
|
|
173
172
|
// @ts-ignore
|
|
174
173
|
<TabItem
|
|
175
174
|
label={translate({
|
|
176
|
-
id:
|
|
175
|
+
id: "theme.openapi.responseExamples.autoExample",
|
|
177
176
|
message: "Example (auto)",
|
|
178
177
|
})}
|
|
179
178
|
value="Example (auto)"
|
|
@@ -192,7 +191,7 @@ export const ExampleFromSchema: React.FC<ExampleFromSchemaProps> = ({
|
|
|
192
191
|
// @ts-ignore
|
|
193
192
|
<TabItem
|
|
194
193
|
label={translate({
|
|
195
|
-
id:
|
|
194
|
+
id: "theme.openapi.responseExamples.autoExample",
|
|
196
195
|
message: "Example (auto)",
|
|
197
196
|
})}
|
|
198
197
|
value="Example (auto)"
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
ResponseExamples,
|
|
19
19
|
} from "@theme/ResponseExamples";
|
|
20
20
|
import SchemaNode from "@theme/Schema";
|
|
21
|
+
import SchemaExpansionControl from "@theme/SchemaExpansion";
|
|
21
22
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
22
23
|
import SkeletonLoader from "@theme/SkeletonLoader";
|
|
23
24
|
import TabItem from "@theme/TabItem";
|
|
24
|
-
import { OPENAPI_SCHEMA, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
25
25
|
import type { MediaTypeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
26
26
|
|
|
27
27
|
interface Props {
|
|
@@ -71,7 +71,7 @@ const ResponseSchemaComponent: React.FC<Props> = ({
|
|
|
71
71
|
<TabItem key={mimeType} label={mimeType} value={mimeType}>
|
|
72
72
|
<div>
|
|
73
73
|
{translate({
|
|
74
|
-
id:
|
|
74
|
+
id: "theme.openapi.schema.noSchema",
|
|
75
75
|
message: "No schema",
|
|
76
76
|
})}
|
|
77
77
|
</div>
|
|
@@ -91,21 +91,20 @@ const ResponseSchemaComponent: React.FC<Props> = ({
|
|
|
91
91
|
open={true}
|
|
92
92
|
style={style}
|
|
93
93
|
summary={
|
|
94
|
-
|
|
95
|
-
<summary>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
</>
|
|
94
|
+
<summary className="openapi-markdown__details-summary--with-control">
|
|
95
|
+
<strong className="openapi-markdown__details-summary-response">
|
|
96
|
+
{title}
|
|
97
|
+
{body.required === true && (
|
|
98
|
+
<span className="openapi-schema__required">
|
|
99
|
+
{translate({
|
|
100
|
+
id: "theme.openapi.schemaItem.required",
|
|
101
|
+
message: "required",
|
|
102
|
+
})}
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
</strong>
|
|
106
|
+
<SchemaExpansionControl />
|
|
107
|
+
</summary>
|
|
109
108
|
}
|
|
110
109
|
>
|
|
111
110
|
<div style={{ textAlign: "left", marginLeft: "1rem" }}>
|