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,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import { ClosingArrayBracket, OpeningArrayBracket } from "@theme/ArrayBrackets";
|
|
11
12
|
import Details from "@theme/Details";
|
|
12
13
|
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
|
|
@@ -14,6 +15,7 @@ import Markdown from "@theme/Markdown";
|
|
|
14
15
|
import SchemaItem from "@theme/SchemaItem";
|
|
15
16
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
16
17
|
import TabItem from "@theme/TabItem";
|
|
18
|
+
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
17
19
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
20
|
import { merge } from "allof-merge";
|
|
19
21
|
import clsx from "clsx";
|
|
@@ -89,12 +91,29 @@ const Summary: React.FC<SummaryProps> = ({
|
|
|
89
91
|
{(isRequired || deprecated || nullable) && (
|
|
90
92
|
<span className="openapi-schema__divider" />
|
|
91
93
|
)}
|
|
92
|
-
{nullable &&
|
|
94
|
+
{nullable && (
|
|
95
|
+
<span className="openapi-schema__nullable">
|
|
96
|
+
{translate({
|
|
97
|
+
id: OPENAPI_SCHEMA_ITEM.NULLABLE,
|
|
98
|
+
message: "nullable",
|
|
99
|
+
})}
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
93
102
|
{isRequired && (
|
|
94
|
-
<span className="openapi-schema__required">
|
|
103
|
+
<span className="openapi-schema__required">
|
|
104
|
+
{translate({
|
|
105
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
106
|
+
message: "required",
|
|
107
|
+
})}
|
|
108
|
+
</span>
|
|
95
109
|
)}
|
|
96
110
|
{deprecated && (
|
|
97
|
-
<span className="openapi-schema__deprecated">
|
|
111
|
+
<span className="openapi-schema__deprecated">
|
|
112
|
+
{translate({
|
|
113
|
+
id: OPENAPI_SCHEMA_ITEM.DEPRECATED,
|
|
114
|
+
message: "deprecated",
|
|
115
|
+
})}
|
|
116
|
+
</span>
|
|
98
117
|
)}
|
|
99
118
|
</span>
|
|
100
119
|
</summary>
|
|
@@ -108,28 +127,59 @@ interface SchemaProps {
|
|
|
108
127
|
}
|
|
109
128
|
|
|
110
129
|
const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
111
|
-
const
|
|
130
|
+
const key = schema.oneOf ? "oneOf" : "anyOf";
|
|
131
|
+
const type = schema.oneOf
|
|
132
|
+
? translate({ id: OPENAPI_SCHEMA_ITEM.ONE_OF, message: "oneOf" })
|
|
133
|
+
: translate({ id: OPENAPI_SCHEMA_ITEM.ANY_OF, message: "anyOf" });
|
|
134
|
+
|
|
135
|
+
// Generate a unique ID for this anyOf/oneOf to prevent tab value collisions
|
|
136
|
+
const uniqueId = React.useMemo(
|
|
137
|
+
() => Math.random().toString(36).substring(7),
|
|
138
|
+
[]
|
|
139
|
+
);
|
|
140
|
+
|
|
112
141
|
return (
|
|
113
142
|
<>
|
|
114
143
|
<span className="badge badge--info" style={{ marginBottom: "1rem" }}>
|
|
115
144
|
{type}
|
|
116
145
|
</span>
|
|
117
|
-
<SchemaTabs>
|
|
118
|
-
{schema[
|
|
119
|
-
|
|
146
|
+
<SchemaTabs groupId={`schema-${uniqueId}`} lazy>
|
|
147
|
+
{schema[key]?.map((anyOneSchema: any, index: number) => {
|
|
148
|
+
// Use getSchemaName to include format info (e.g., "string<date-time>")
|
|
149
|
+
const computedSchemaName = getSchemaName(anyOneSchema);
|
|
150
|
+
|
|
151
|
+
// Determine label for the tab
|
|
152
|
+
// Prefer explicit title, then computed schema name, then raw type
|
|
153
|
+
let label =
|
|
154
|
+
anyOneSchema.title || computedSchemaName || anyOneSchema.type;
|
|
155
|
+
if (!label) {
|
|
156
|
+
if (anyOneSchema.oneOf) {
|
|
157
|
+
label = translate({
|
|
158
|
+
id: OPENAPI_SCHEMA_ITEM.ONE_OF,
|
|
159
|
+
message: "oneOf",
|
|
160
|
+
});
|
|
161
|
+
} else if (anyOneSchema.anyOf) {
|
|
162
|
+
label = translate({
|
|
163
|
+
id: OPENAPI_SCHEMA_ITEM.ANY_OF,
|
|
164
|
+
message: "anyOf",
|
|
165
|
+
});
|
|
166
|
+
} else {
|
|
167
|
+
label = `Option ${index + 1}`;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
120
170
|
return (
|
|
121
171
|
// @ts-ignore
|
|
122
172
|
<TabItem
|
|
123
173
|
key={index}
|
|
124
174
|
label={label}
|
|
125
|
-
value={`${index}-item
|
|
175
|
+
value={`${uniqueId}-${index}-item`}
|
|
126
176
|
>
|
|
127
177
|
{/* Handle primitive types directly */}
|
|
128
178
|
{(isPrimitive(anyOneSchema) || anyOneSchema.const) && (
|
|
129
179
|
<SchemaItem
|
|
130
180
|
collapsible={false}
|
|
131
181
|
name={undefined}
|
|
132
|
-
schemaName={
|
|
182
|
+
schemaName={computedSchemaName}
|
|
133
183
|
qualifierMessage={getQualifierMessage(anyOneSchema)}
|
|
134
184
|
schema={anyOneSchema}
|
|
135
185
|
discriminator={false}
|
|
@@ -146,7 +196,7 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
146
196
|
<SchemaItem
|
|
147
197
|
collapsible={false}
|
|
148
198
|
name={undefined}
|
|
149
|
-
schemaName={
|
|
199
|
+
schemaName={computedSchemaName}
|
|
150
200
|
qualifierMessage={getQualifierMessage(anyOneSchema)}
|
|
151
201
|
schema={anyOneSchema}
|
|
152
202
|
discriminator={false}
|
|
@@ -155,9 +205,11 @@ const AnyOneOf: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
155
205
|
)}
|
|
156
206
|
|
|
157
207
|
{/* Handle actual object types with properties or nested schemas */}
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
|
|
208
|
+
{/* Note: In OpenAPI, properties implies type: object even if not explicitly set */}
|
|
209
|
+
{(anyOneSchema.type === "object" || !anyOneSchema.type) &&
|
|
210
|
+
anyOneSchema.properties && (
|
|
211
|
+
<Properties schema={anyOneSchema} schemaType={schemaType} />
|
|
212
|
+
)}
|
|
161
213
|
{anyOneSchema.allOf && (
|
|
162
214
|
<SchemaNode schema={anyOneSchema} schemaType={schemaType} />
|
|
163
215
|
)}
|
|
@@ -254,7 +306,12 @@ const PropertyDiscriminator: React.FC<SchemaEdgeProps> = ({
|
|
|
254
306
|
)}
|
|
255
307
|
{required && <span className="openapi-schema__divider"></span>}
|
|
256
308
|
{required && (
|
|
257
|
-
<span className="openapi-schema__required">
|
|
309
|
+
<span className="openapi-schema__required">
|
|
310
|
+
{translate({
|
|
311
|
+
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
312
|
+
message: "required",
|
|
313
|
+
})}
|
|
314
|
+
</span>
|
|
258
315
|
)}
|
|
259
316
|
</span>
|
|
260
317
|
<div style={{ marginLeft: "1rem" }}>
|
|
@@ -672,7 +729,7 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
|
|
|
672
729
|
);
|
|
673
730
|
}
|
|
674
731
|
|
|
675
|
-
if (schema.items?.anyOf || schema.items?.oneOf) {
|
|
732
|
+
if (schema.items?.anyOf || schema.items?.oneOf || schema.items?.allOf) {
|
|
676
733
|
return (
|
|
677
734
|
<SchemaNodeDetails
|
|
678
735
|
name={name}
|
|
@@ -725,9 +782,7 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
|
|
|
725
782
|
name={name}
|
|
726
783
|
schemaName={mergedSchemaName}
|
|
727
784
|
required={
|
|
728
|
-
Array.isArray(
|
|
729
|
-
? mergedSchemas.required.includes(name)
|
|
730
|
-
: mergedSchemas.required
|
|
785
|
+
Array.isArray(required) ? required.includes(name) : required
|
|
731
786
|
}
|
|
732
787
|
nullable={mergedSchemas.nullable}
|
|
733
788
|
schema={mergedSchemas}
|
|
@@ -742,9 +797,7 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
|
|
|
742
797
|
name={name}
|
|
743
798
|
schemaName={mergedSchemaName}
|
|
744
799
|
required={
|
|
745
|
-
Array.isArray(
|
|
746
|
-
? mergedSchemas.required.includes(name)
|
|
747
|
-
: mergedSchemas.required
|
|
800
|
+
Array.isArray(required) ? required.includes(name) : required
|
|
748
801
|
}
|
|
749
802
|
nullable={mergedSchemas.nullable}
|
|
750
803
|
schema={mergedSchemas}
|
|
@@ -754,18 +807,18 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
|
|
|
754
807
|
}
|
|
755
808
|
|
|
756
809
|
if (mergedSchemas.items?.properties) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
?
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
810
|
+
return (
|
|
811
|
+
<SchemaNodeDetails
|
|
812
|
+
name={name}
|
|
813
|
+
schemaName={mergedSchemaName}
|
|
814
|
+
required={
|
|
815
|
+
Array.isArray(required) ? required.includes(name) : required
|
|
816
|
+
}
|
|
817
|
+
nullable={mergedSchemas.nullable}
|
|
818
|
+
schema={mergedSchemas}
|
|
819
|
+
schemaType={schemaType}
|
|
820
|
+
/>
|
|
821
|
+
);
|
|
769
822
|
}
|
|
770
823
|
|
|
771
824
|
return (
|
|
@@ -836,6 +889,48 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
836
889
|
|
|
837
890
|
// Handle allOf, oneOf, anyOf without discriminators
|
|
838
891
|
if (schema.allOf) {
|
|
892
|
+
// Check if allOf contains multiple oneOf/anyOf items that should be rendered separately
|
|
893
|
+
const oneOfItems = schema.allOf.filter(
|
|
894
|
+
(item: any) => item.oneOf || item.anyOf
|
|
895
|
+
);
|
|
896
|
+
const hasMultipleChoices = oneOfItems.length > 1;
|
|
897
|
+
|
|
898
|
+
if (hasMultipleChoices) {
|
|
899
|
+
// Render each oneOf/anyOf constraint first, then shared properties
|
|
900
|
+
const mergedSchemas = mergeAllOf(schema) as SchemaObject;
|
|
901
|
+
|
|
902
|
+
if (
|
|
903
|
+
(schemaType === "request" && mergedSchemas.readOnly) ||
|
|
904
|
+
(schemaType === "response" && mergedSchemas.writeOnly)
|
|
905
|
+
) {
|
|
906
|
+
return null;
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
return (
|
|
910
|
+
<div>
|
|
911
|
+
{/* Render all oneOf/anyOf constraints first */}
|
|
912
|
+
{schema.allOf.map((item: any, index: number) => {
|
|
913
|
+
if (item.oneOf || item.anyOf) {
|
|
914
|
+
return (
|
|
915
|
+
<div key={index}>
|
|
916
|
+
<AnyOneOf schema={item} schemaType={schemaType} />
|
|
917
|
+
</div>
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
return null;
|
|
921
|
+
})}
|
|
922
|
+
{/* Then render shared properties from the merge */}
|
|
923
|
+
{mergedSchemas.properties && (
|
|
924
|
+
<Properties schema={mergedSchemas} schemaType={schemaType} />
|
|
925
|
+
)}
|
|
926
|
+
{mergedSchemas.items && (
|
|
927
|
+
<Items schema={mergedSchemas} schemaType={schemaType} />
|
|
928
|
+
)}
|
|
929
|
+
</div>
|
|
930
|
+
);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
// For other allOf cases, use standard merge behavior
|
|
839
934
|
const mergedSchemas = mergeAllOf(schema) as SchemaObject;
|
|
840
935
|
|
|
841
936
|
if (
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
import React, { ReactNode } from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
import { Example } from "@theme/Example";
|
|
10
12
|
import Markdown from "@theme/Markdown";
|
|
13
|
+
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
11
14
|
import clsx from "clsx";
|
|
12
15
|
|
|
13
16
|
import { guard } from "../../markdown/utils";
|
|
@@ -36,7 +39,15 @@ const transformEnumDescriptions = (
|
|
|
36
39
|
|
|
37
40
|
const getEnumDescriptionMarkdown = (enumDescriptions?: [string, string][]) => {
|
|
38
41
|
if (enumDescriptions?.length) {
|
|
39
|
-
|
|
42
|
+
const enumValue = translate({
|
|
43
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_VALUE,
|
|
44
|
+
message: "Enum Value",
|
|
45
|
+
});
|
|
46
|
+
const description = translate({
|
|
47
|
+
id: OPENAPI_SCHEMA_ITEM.ENUM_DESCRIPTION,
|
|
48
|
+
message: "Description",
|
|
49
|
+
});
|
|
50
|
+
return `| ${enumValue} | ${description} |
|
|
40
51
|
| ---- | ----- |
|
|
41
52
|
${enumDescriptions
|
|
42
53
|
.map((desc) => {
|
|
@@ -63,6 +74,7 @@ export default function SchemaItem(props: Props) {
|
|
|
63
74
|
let schemaDescription;
|
|
64
75
|
let defaultValue: string | undefined;
|
|
65
76
|
let example: string | undefined;
|
|
77
|
+
let examples: string[] | undefined;
|
|
66
78
|
let nullable;
|
|
67
79
|
let enumDescriptions: [string, string][] = [];
|
|
68
80
|
let constValue: string | undefined;
|
|
@@ -73,6 +85,7 @@ export default function SchemaItem(props: Props) {
|
|
|
73
85
|
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
|
|
74
86
|
defaultValue = schema.default;
|
|
75
87
|
example = schema.example;
|
|
88
|
+
examples = schema.examples;
|
|
76
89
|
nullable =
|
|
77
90
|
schema.nullable ||
|
|
78
91
|
(Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
|
|
@@ -81,15 +94,23 @@ export default function SchemaItem(props: Props) {
|
|
|
81
94
|
|
|
82
95
|
const renderRequired = guard(
|
|
83
96
|
Array.isArray(required) ? required.includes(name) : required,
|
|
84
|
-
() =>
|
|
97
|
+
() => (
|
|
98
|
+
<span className="openapi-schema__required">
|
|
99
|
+
{translate({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })}
|
|
100
|
+
</span>
|
|
101
|
+
)
|
|
85
102
|
);
|
|
86
103
|
|
|
87
104
|
const renderDeprecated = guard(deprecated, () => (
|
|
88
|
-
<span className="openapi-schema__deprecated">
|
|
105
|
+
<span className="openapi-schema__deprecated">
|
|
106
|
+
{translate({ id: OPENAPI_SCHEMA_ITEM.DEPRECATED, message: "deprecated" })}
|
|
107
|
+
</span>
|
|
89
108
|
));
|
|
90
109
|
|
|
91
110
|
const renderNullable = guard(nullable, () => (
|
|
92
|
-
<span className="openapi-schema__nullable">
|
|
111
|
+
<span className="openapi-schema__nullable">
|
|
112
|
+
{translate({ id: OPENAPI_SCHEMA_ITEM.NULLABLE, message: "nullable" })}
|
|
113
|
+
</span>
|
|
93
114
|
));
|
|
94
115
|
|
|
95
116
|
const renderEnumDescriptions = guard(
|
|
@@ -120,7 +141,12 @@ export default function SchemaItem(props: Props) {
|
|
|
120
141
|
if (typeof defaultValue === "string") {
|
|
121
142
|
return (
|
|
122
143
|
<div>
|
|
123
|
-
<strong>
|
|
144
|
+
<strong>
|
|
145
|
+
{translate({
|
|
146
|
+
id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
|
|
147
|
+
message: "Default value:",
|
|
148
|
+
})}{" "}
|
|
149
|
+
</strong>
|
|
124
150
|
<span>
|
|
125
151
|
<code>{defaultValue}</code>
|
|
126
152
|
</span>
|
|
@@ -129,7 +155,12 @@ export default function SchemaItem(props: Props) {
|
|
|
129
155
|
}
|
|
130
156
|
return (
|
|
131
157
|
<div>
|
|
132
|
-
<strong>
|
|
158
|
+
<strong>
|
|
159
|
+
{translate({
|
|
160
|
+
id: OPENAPI_SCHEMA_ITEM.DEFAULT_VALUE,
|
|
161
|
+
message: "Default value:",
|
|
162
|
+
})}{" "}
|
|
163
|
+
</strong>
|
|
133
164
|
<span>
|
|
134
165
|
<code>{JSON.stringify(defaultValue)}</code>
|
|
135
166
|
</span>
|
|
@@ -139,36 +170,17 @@ export default function SchemaItem(props: Props) {
|
|
|
139
170
|
return undefined;
|
|
140
171
|
}
|
|
141
172
|
|
|
142
|
-
function renderExample() {
|
|
143
|
-
if (example !== undefined) {
|
|
144
|
-
if (typeof example === "string") {
|
|
145
|
-
return (
|
|
146
|
-
<div>
|
|
147
|
-
<strong>Example: </strong>
|
|
148
|
-
<span>
|
|
149
|
-
<code>{example}</code>
|
|
150
|
-
</span>
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
return (
|
|
155
|
-
<div>
|
|
156
|
-
<strong>Example: </strong>
|
|
157
|
-
<span>
|
|
158
|
-
<code>{JSON.stringify(example)}</code>
|
|
159
|
-
</span>
|
|
160
|
-
</div>
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
173
|
function renderConstValue() {
|
|
167
174
|
if (constValue !== undefined) {
|
|
168
175
|
if (typeof constValue === "string") {
|
|
169
176
|
return (
|
|
170
177
|
<div>
|
|
171
|
-
<strong>
|
|
178
|
+
<strong>
|
|
179
|
+
{translate({
|
|
180
|
+
id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
|
|
181
|
+
message: "Constant value:",
|
|
182
|
+
})}{" "}
|
|
183
|
+
</strong>
|
|
172
184
|
<span>
|
|
173
185
|
<code>{constValue}</code>
|
|
174
186
|
</span>
|
|
@@ -177,7 +189,12 @@ export default function SchemaItem(props: Props) {
|
|
|
177
189
|
}
|
|
178
190
|
return (
|
|
179
191
|
<div>
|
|
180
|
-
<strong>
|
|
192
|
+
<strong>
|
|
193
|
+
{translate({
|
|
194
|
+
id: OPENAPI_SCHEMA_ITEM.CONSTANT_VALUE,
|
|
195
|
+
message: "Constant value:",
|
|
196
|
+
})}{" "}
|
|
197
|
+
</strong>
|
|
181
198
|
<span>
|
|
182
199
|
<code>{JSON.stringify(constValue)}</code>
|
|
183
200
|
</span>
|
|
@@ -212,7 +229,8 @@ export default function SchemaItem(props: Props) {
|
|
|
212
229
|
{renderQualifierMessage}
|
|
213
230
|
{renderConstValue()}
|
|
214
231
|
{renderDefaultValue()}
|
|
215
|
-
{
|
|
232
|
+
<Example example={example} />
|
|
233
|
+
<Example examples={examples} />
|
|
216
234
|
{collapsibleSchemaContent ?? collapsibleSchemaContent}
|
|
217
235
|
</div>
|
|
218
236
|
);
|
|
@@ -115,7 +115,10 @@ function TabList({
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
return (
|
|
118
|
-
<div
|
|
118
|
+
<div
|
|
119
|
+
className="openapi-tabs__schema-tabs-container"
|
|
120
|
+
style={{ marginBottom: "1rem" }}
|
|
121
|
+
>
|
|
119
122
|
{showTabArrows && (
|
|
120
123
|
<button
|
|
121
124
|
className="openapi-tabs__arrow left"
|
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
|
|
10
12
|
import ApiTabs from "@theme/ApiTabs";
|
|
11
13
|
import Details from "@theme/Details";
|
|
12
14
|
import Markdown from "@theme/Markdown";
|
|
13
15
|
import ResponseHeaders from "@theme/ResponseHeaders";
|
|
14
16
|
import ResponseSchema from "@theme/ResponseSchema";
|
|
15
17
|
import TabItem from "@theme/TabItem";
|
|
18
|
+
import { OPENAPI_STATUS_CODES } from "@theme/translationIds";
|
|
16
19
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/lib/types";
|
|
17
20
|
|
|
18
21
|
interface Props {
|
|
@@ -51,7 +54,12 @@ const StatusCodes: React.FC<Props> = ({ label, id, responses }: any) => {
|
|
|
51
54
|
style={{ textAlign: "left", marginBottom: "1rem" }}
|
|
52
55
|
summary={
|
|
53
56
|
<summary>
|
|
54
|
-
<strong>
|
|
57
|
+
<strong>
|
|
58
|
+
{translate({
|
|
59
|
+
id: OPENAPI_STATUS_CODES.RESPONSE_HEADERS,
|
|
60
|
+
message: "Response Headers",
|
|
61
|
+
})}
|
|
62
|
+
</strong>
|
|
55
63
|
</summary>
|
|
56
64
|
}
|
|
57
65
|
>
|
|
@@ -59,7 +67,10 @@ const StatusCodes: React.FC<Props> = ({ label, id, responses }: any) => {
|
|
|
59
67
|
</Details>
|
|
60
68
|
)}
|
|
61
69
|
<ResponseSchema
|
|
62
|
-
title=
|
|
70
|
+
title={translate({
|
|
71
|
+
id: OPENAPI_STATUS_CODES.SCHEMA_TITLE,
|
|
72
|
+
message: "Schema",
|
|
73
|
+
})}
|
|
63
74
|
body={{ content: response.content }}
|
|
64
75
|
/>
|
|
65
76
|
</TabItem>
|
package/src/theme/styles.scss
CHANGED
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
@use "./CodeSamples/CodeSamples";
|
|
42
42
|
/* Markdown Styling */
|
|
43
43
|
@use "./Markdown/Details/Details";
|
|
44
|
+
/* Example Styling */
|
|
45
|
+
@use "./Example/Example";
|
|
44
46
|
|
|
45
47
|
:root {
|
|
46
48
|
--openapi-required: var(--ifm-color-danger);
|
|
@@ -67,6 +69,9 @@
|
|
|
67
69
|
--openapi-code-tab-border-color-java: #0374bd;
|
|
68
70
|
--openapi-code-tab-border-color-powershell: #00adef;
|
|
69
71
|
--openapi-code-tab-shadow-color-python: rgba(255, 219, 80, 0.25);
|
|
72
|
+
--openapi-code-tab-shadow-color-curl: var(
|
|
73
|
+
--openapi-code-tab-shadow-color-bash
|
|
74
|
+
);
|
|
70
75
|
--openapi-code-tab-shadow-color-bash: rgba(250, 56, 62, 0.25);
|
|
71
76
|
--openapi-code-tab-shadow-color-go: rgba(84, 199, 236, 0.25);
|
|
72
77
|
--openapi-code-tab-shadow-color-js: rgba(255, 186, 0, 0.25);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
export const OPENAPI_RESPONSE = {
|
|
9
|
+
TITLE: "theme.openapi.response.title",
|
|
10
|
+
CLEAR: "theme.openapi.response.clear",
|
|
11
|
+
PLACEHOLDER: "theme.openapi.response.placeholder",
|
|
12
|
+
HEADERS_TAB: "theme.openapi.response.headersTab",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const OPENAPI_TABS = {
|
|
16
|
+
RESPONSES_LABEL: "theme.openapi.tabs.responses.label",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const OPENAPI_REQUEST = {
|
|
20
|
+
BODY_TITLE: "theme.openapi.request.body.title",
|
|
21
|
+
ACCEPT_TITLE: "theme.openapi.request.accept.title",
|
|
22
|
+
SEND_BUTTON: "theme.openapi.request.sendButton",
|
|
23
|
+
REQUIRED_LABEL: "theme.openapi.request.requiredLabel",
|
|
24
|
+
REQUEST_TITLE: "theme.openapi.request.title",
|
|
25
|
+
COLLAPSE_ALL: "theme.openapi.request.collapseAll",
|
|
26
|
+
EXPAND_ALL: "theme.openapi.request.expandAll",
|
|
27
|
+
BASE_URL_TITLE: "theme.openapi.request.baseUrl.title",
|
|
28
|
+
AUTH_TITLE: "theme.openapi.request.auth.title",
|
|
29
|
+
PARAMETERS_TITLE: "theme.openapi.request.parameters.title",
|
|
30
|
+
FETCHING_MESSAGE: "theme.openapi.request.fetchingMessage",
|
|
31
|
+
CONNECTION_FAILED: "theme.openapi.request.connectionFailed",
|
|
32
|
+
ERROR_TIMEOUT: "theme.openapi.request.error.timeout",
|
|
33
|
+
ERROR_NETWORK: "theme.openapi.request.error.network",
|
|
34
|
+
ERROR_CORS: "theme.openapi.request.error.cors",
|
|
35
|
+
ERROR_UNKNOWN: "theme.openapi.request.error.unknown",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const OPENAPI_SERVER = {
|
|
39
|
+
EDIT_BUTTON: "theme.openapi.server.editButton",
|
|
40
|
+
HIDE_BUTTON: "theme.openapi.server.hideButton",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const OPENAPI_PARAM_OPTIONS = {
|
|
44
|
+
SHOW_OPTIONAL: "theme.openapi.paramOptions.showOptional",
|
|
45
|
+
HIDE_OPTIONAL: "theme.openapi.paramOptions.hideOptional",
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const OPENAPI_FORM_FILE_UPLOAD = {
|
|
49
|
+
CLEAR_BUTTON: "theme.openapi.formFileUpload.clearButton",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const OPENAPI_FORM = {
|
|
53
|
+
FIELD_REQUIRED: "theme.openapi.form.fieldRequired",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const OPENAPI_AUTH = {
|
|
57
|
+
BEARER_TOKEN: "theme.openapi.auth.bearerToken",
|
|
58
|
+
USERNAME: "theme.openapi.auth.username",
|
|
59
|
+
PASSWORD: "theme.openapi.auth.password",
|
|
60
|
+
SECURITY_SCHEME: "theme.openapi.auth.securityScheme",
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const OPENAPI_RESPONSE_EXAMPLES = {
|
|
64
|
+
EXAMPLE: "theme.openapi.responseExamples.example",
|
|
65
|
+
AUTO_EXAMPLE: "theme.openapi.responseExamples.autoExample",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const OPENAPI_BODY = {
|
|
69
|
+
EXAMPLE_FROM_SCHEMA: "theme.openapi.body.exampleFromSchema",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const OPENAPI_STATUS_CODES = {
|
|
73
|
+
RESPONSE_HEADERS: "theme.openapi.statusCodes.responseHeaders",
|
|
74
|
+
SCHEMA_TITLE: "theme.openapi.statusCodes.schemaTitle",
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const OPENAPI_SCHEMA = {
|
|
78
|
+
NO_SCHEMA: "theme.openapi.schema.noSchema",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const OPENAPI_SCHEMA_ITEM = {
|
|
82
|
+
REQUIRED: "theme.openapi.schemaItem.required",
|
|
83
|
+
DEPRECATED: "theme.openapi.schemaItem.deprecated",
|
|
84
|
+
NULLABLE: "theme.openapi.schemaItem.nullable",
|
|
85
|
+
DEFAULT_VALUE: "theme.openapi.schemaItem.defaultValue",
|
|
86
|
+
EXAMPLE: "theme.openapi.schemaItem.example",
|
|
87
|
+
EXAMPLES: "theme.openapi.schemaItem.examples",
|
|
88
|
+
DESCRIPTION: "theme.openapi.schemaItem.description",
|
|
89
|
+
CONSTANT_VALUE: "theme.openapi.schemaItem.constantValue",
|
|
90
|
+
ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
|
|
91
|
+
ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
|
|
92
|
+
POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
|
|
93
|
+
ONE_OF: "theme.openapi.schemaItem.oneOf",
|
|
94
|
+
ANY_OF: "theme.openapi.schemaItem.anyOf",
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const OPENAPI_PARAMS_DETAILS = {
|
|
98
|
+
PARAMETERS_TITLE: "theme.openapi.paramsDetails.parametersTitle",
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const OPENAPI_SECURITY_SCHEMES = {
|
|
102
|
+
NAME: "theme.openapi.securitySchemes.name",
|
|
103
|
+
TYPE: "theme.openapi.securitySchemes.type",
|
|
104
|
+
SCOPES: "theme.openapi.securitySchemes.scopes",
|
|
105
|
+
IN: "theme.openapi.securitySchemes.in",
|
|
106
|
+
FLOWS: "theme.openapi.securitySchemes.flows",
|
|
107
|
+
DESCRIPTION: "theme.openapi.securitySchemes.description",
|
|
108
|
+
SCHEME: "theme.openapi.securitySchemes.scheme",
|
|
109
|
+
BEARER_FORMAT: "theme.openapi.securitySchemes.bearerFormat",
|
|
110
|
+
OPEN_ID_CONNECT_URL: "theme.openapi.securitySchemes.openIdConnectUrl",
|
|
111
|
+
};
|