docusaurus-theme-openapi-docs 4.3.6 → 4.4.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/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +4 -2
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +4 -4
- package/lib/theme/ApiExplorer/Request/index.js +25 -4
- package/lib/theme/DiscriminatorTabs/index.js +4 -1
- package/lib/theme/ParamsItem/index.js +4 -1
- package/lib/theme/Schema/index.js +34 -36
- package/package.json +3 -3
- package/src/theme/ApiExplorer/Body/index.tsx +1 -2
- package/src/theme/ApiExplorer/FormFileUpload/_FormFileUpload.scss +4 -2
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +4 -4
- package/src/theme/ApiExplorer/Request/index.tsx +26 -3
- package/src/theme/DiscriminatorTabs/index.tsx +5 -1
- package/src/theme/ParamsItem/index.tsx +6 -1
- package/src/theme/Schema/index.tsx +22 -18
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
&:hover {
|
|
15
15
|
border: 2px dashed var(--ifm-color-primary);
|
|
16
|
-
background:
|
|
16
|
+
background:
|
|
17
|
+
linear-gradient(
|
|
17
18
|
var(--openapi-dropzone-hover-shim),
|
|
18
19
|
var(--openapi-dropzone-hover-shim)
|
|
19
20
|
),
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
font-size: var(--ifm-code-font-size);
|
|
39
40
|
border: 2px dashed var(--ifm-color-primary);
|
|
40
41
|
|
|
41
|
-
background:
|
|
42
|
+
background:
|
|
43
|
+
linear-gradient(
|
|
42
44
|
var(--openapi-dropzone-hover-shim),
|
|
43
45
|
var(--openapi-dropzone-hover-shim)
|
|
44
46
|
),
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
line-height: 1.5;
|
|
46
46
|
|
|
47
47
|
transition-property: color, background, border-color, box-shadow;
|
|
48
|
-
transition-duration:
|
|
49
|
-
var(--ifm-button-transition-duration);
|
|
48
|
+
transition-duration:
|
|
49
|
+
100ms, 100ms, 100ms, var(--ifm-button-transition-duration);
|
|
50
50
|
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
51
51
|
|
|
52
52
|
-webkit-user-select: none;
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
padding: 0.5rem 1rem;
|
|
86
86
|
font-size: 12px;
|
|
87
87
|
transition-property: color, background, border-color, box-shadow;
|
|
88
|
-
transition-duration:
|
|
89
|
-
var(--ifm-button-transition-duration);
|
|
88
|
+
transition-duration:
|
|
89
|
+
100ms, 100ms, 100ms, var(--ifm-button-transition-duration);
|
|
90
90
|
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
91
91
|
user-select: none;
|
|
92
92
|
white-space: nowrap;
|
|
@@ -158,15 +158,36 @@ function Request({ item }) {
|
|
|
158
158
|
paramsArray.push(param);
|
|
159
159
|
});
|
|
160
160
|
const methods = (0, react_hook_form_1.useForm)({ shouldFocusError: false });
|
|
161
|
+
const handleEventStream = async (res) => {
|
|
162
|
+
res.headers &&
|
|
163
|
+
dispatch((0, slice_1.setHeaders)(Object.fromEntries(res.headers)));
|
|
164
|
+
dispatch((0, slice_1.setCode)(res.status));
|
|
165
|
+
const reader = res.body.getReader();
|
|
166
|
+
const decoder = new TextDecoder();
|
|
167
|
+
let result = "";
|
|
168
|
+
while (true) {
|
|
169
|
+
const { done, value } = await reader.read();
|
|
170
|
+
if (done) break;
|
|
171
|
+
result += decoder.decode(value, { stream: true });
|
|
172
|
+
dispatch((0, slice_1.setResponse)(result));
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const handleResponse = async (res) => {
|
|
176
|
+
dispatch((0, slice_1.setResponse)(await res.text()));
|
|
177
|
+
dispatch((0, slice_1.setCode)(res.status));
|
|
178
|
+
res.headers &&
|
|
179
|
+
dispatch((0, slice_1.setHeaders)(Object.fromEntries(res.headers)));
|
|
180
|
+
};
|
|
161
181
|
const onSubmit = async (data) => {
|
|
162
182
|
dispatch((0, slice_1.setResponse)("Fetching..."));
|
|
163
183
|
try {
|
|
164
184
|
await delay(1200);
|
|
165
185
|
const res = await (0, makeRequest_1.default)(postmanRequest, proxy, body);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
if (res.headers.get("content-type")?.includes("text/event-stream")) {
|
|
187
|
+
await handleEventStream(res);
|
|
188
|
+
} else {
|
|
189
|
+
await handleResponse(res);
|
|
190
|
+
}
|
|
170
191
|
} catch (e) {
|
|
171
192
|
console.log(e);
|
|
172
193
|
dispatch((0, slice_1.setResponse)("Connection failed"));
|
|
@@ -238,7 +238,10 @@ function TabsComponent(props) {
|
|
|
238
238
|
}
|
|
239
239
|
function DiscriminatorTabs(props) {
|
|
240
240
|
const isBrowser = (0, useIsBrowser_1.default)();
|
|
241
|
-
if (
|
|
241
|
+
if (
|
|
242
|
+
!props.children ||
|
|
243
|
+
(Array.isArray(props.children) && props.children.length === 0)
|
|
244
|
+
)
|
|
242
245
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
243
246
|
return react_1.default.createElement(
|
|
244
247
|
TabsComponent,
|
|
@@ -44,9 +44,12 @@ function ParamsItem({ param, ...rest }) {
|
|
|
44
44
|
} = param;
|
|
45
45
|
let schema = param.schema;
|
|
46
46
|
let defaultValue;
|
|
47
|
-
if (!schema
|
|
47
|
+
if (!schema) {
|
|
48
48
|
schema = { type: "any" };
|
|
49
49
|
}
|
|
50
|
+
if (!schema.type) {
|
|
51
|
+
schema.type = "any";
|
|
52
|
+
}
|
|
50
53
|
if (schema) {
|
|
51
54
|
if (schema.items) {
|
|
52
55
|
defaultValue = schema.items.default;
|
|
@@ -344,7 +344,8 @@ const DiscriminatorNode = ({ discriminator, schema, schemaType }) => {
|
|
|
344
344
|
mergedSubSchema = mergeAllOf(subSchema);
|
|
345
345
|
}
|
|
346
346
|
const subProperties = subSchema.properties || mergedSubSchema.properties;
|
|
347
|
-
|
|
347
|
+
// Add a safeguard check to avoid referencing subProperties if it's undefined
|
|
348
|
+
if (subProperties && subProperties[discriminator.propertyName]) {
|
|
348
349
|
if (schema.properties) {
|
|
349
350
|
schema.properties[discriminator.propertyName] = {
|
|
350
351
|
...schema.properties[discriminator.propertyName],
|
|
@@ -777,6 +778,37 @@ const SchemaEdge = ({ name, schema, required, discriminator, schemaType }) => {
|
|
|
777
778
|
children: null,
|
|
778
779
|
});
|
|
779
780
|
};
|
|
781
|
+
function renderChildren(schema, schemaType) {
|
|
782
|
+
return react_1.default.createElement(
|
|
783
|
+
react_1.default.Fragment,
|
|
784
|
+
null,
|
|
785
|
+
schema.oneOf &&
|
|
786
|
+
react_1.default.createElement(AnyOneOf, {
|
|
787
|
+
schema: schema,
|
|
788
|
+
schemaType: schemaType,
|
|
789
|
+
}),
|
|
790
|
+
schema.anyOf &&
|
|
791
|
+
react_1.default.createElement(AnyOneOf, {
|
|
792
|
+
schema: schema,
|
|
793
|
+
schemaType: schemaType,
|
|
794
|
+
}),
|
|
795
|
+
schema.properties &&
|
|
796
|
+
react_1.default.createElement(Properties, {
|
|
797
|
+
schema: schema,
|
|
798
|
+
schemaType: schemaType,
|
|
799
|
+
}),
|
|
800
|
+
schema.additionalProperties &&
|
|
801
|
+
react_1.default.createElement(AdditionalProperties, {
|
|
802
|
+
schema: schema,
|
|
803
|
+
schemaType: schemaType,
|
|
804
|
+
}),
|
|
805
|
+
schema.items &&
|
|
806
|
+
react_1.default.createElement(Items, {
|
|
807
|
+
schema: schema,
|
|
808
|
+
schemaType: schemaType,
|
|
809
|
+
})
|
|
810
|
+
);
|
|
811
|
+
}
|
|
780
812
|
const SchemaNode = ({ schema, schemaType }) => {
|
|
781
813
|
if (
|
|
782
814
|
(schemaType === "request" && schema.readOnly) ||
|
|
@@ -826,12 +858,6 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
826
858
|
})
|
|
827
859
|
);
|
|
828
860
|
}
|
|
829
|
-
if (schema.oneOf || schema.anyOf) {
|
|
830
|
-
return react_1.default.createElement(AnyOneOf, {
|
|
831
|
-
schema: schema,
|
|
832
|
-
schemaType: schemaType,
|
|
833
|
-
});
|
|
834
|
-
}
|
|
835
861
|
// Handle primitives
|
|
836
862
|
if (
|
|
837
863
|
schema.type &&
|
|
@@ -854,34 +880,6 @@ const SchemaNode = ({ schema, schemaType }) => {
|
|
|
854
880
|
children: null,
|
|
855
881
|
});
|
|
856
882
|
}
|
|
857
|
-
return
|
|
858
|
-
"div",
|
|
859
|
-
null,
|
|
860
|
-
schema.oneOf &&
|
|
861
|
-
react_1.default.createElement(AnyOneOf, {
|
|
862
|
-
schema: schema,
|
|
863
|
-
schemaType: schemaType,
|
|
864
|
-
}),
|
|
865
|
-
schema.anyOf &&
|
|
866
|
-
react_1.default.createElement(AnyOneOf, {
|
|
867
|
-
schema: schema,
|
|
868
|
-
schemaType: schemaType,
|
|
869
|
-
}),
|
|
870
|
-
schema.properties &&
|
|
871
|
-
react_1.default.createElement(Properties, {
|
|
872
|
-
schema: schema,
|
|
873
|
-
schemaType: schemaType,
|
|
874
|
-
}),
|
|
875
|
-
schema.additionalProperties &&
|
|
876
|
-
react_1.default.createElement(AdditionalProperties, {
|
|
877
|
-
schema: schema,
|
|
878
|
-
schemaType: schemaType,
|
|
879
|
-
}),
|
|
880
|
-
schema.items &&
|
|
881
|
-
react_1.default.createElement(Items, {
|
|
882
|
-
schema: schema,
|
|
883
|
-
schemaType: schemaType,
|
|
884
|
-
})
|
|
885
|
-
);
|
|
883
|
+
return renderChildren(schema, schemaType);
|
|
886
884
|
};
|
|
887
885
|
exports.default = SchemaNode;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/lodash": "^4.14.176",
|
|
37
37
|
"@types/pako": "^2.0.3",
|
|
38
38
|
"concurrently": "^5.2.0",
|
|
39
|
-
"docusaurus-plugin-openapi-docs": "^4.
|
|
39
|
+
"docusaurus-plugin-openapi-docs": "^4.4.0",
|
|
40
40
|
"docusaurus-plugin-sass": "^0.2.3",
|
|
41
41
|
"eslint-plugin-prettier": "^5.0.1"
|
|
42
42
|
},
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=14"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "808e4a252af8e24201e38a6ecbddb05b844891a2"
|
|
83
83
|
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
&:hover {
|
|
15
15
|
border: 2px dashed var(--ifm-color-primary);
|
|
16
|
-
background:
|
|
16
|
+
background:
|
|
17
|
+
linear-gradient(
|
|
17
18
|
var(--openapi-dropzone-hover-shim),
|
|
18
19
|
var(--openapi-dropzone-hover-shim)
|
|
19
20
|
),
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
font-size: var(--ifm-code-font-size);
|
|
39
40
|
border: 2px dashed var(--ifm-color-primary);
|
|
40
41
|
|
|
41
|
-
background:
|
|
42
|
+
background:
|
|
43
|
+
linear-gradient(
|
|
42
44
|
var(--openapi-dropzone-hover-shim),
|
|
43
45
|
var(--openapi-dropzone-hover-shim)
|
|
44
46
|
),
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
line-height: 1.5;
|
|
46
46
|
|
|
47
47
|
transition-property: color, background, border-color, box-shadow;
|
|
48
|
-
transition-duration:
|
|
49
|
-
var(--ifm-button-transition-duration);
|
|
48
|
+
transition-duration:
|
|
49
|
+
100ms, 100ms, 100ms, var(--ifm-button-transition-duration);
|
|
50
50
|
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
51
51
|
|
|
52
52
|
-webkit-user-select: none;
|
|
@@ -85,8 +85,8 @@
|
|
|
85
85
|
padding: 0.5rem 1rem;
|
|
86
86
|
font-size: 12px;
|
|
87
87
|
transition-property: color, background, border-color, box-shadow;
|
|
88
|
-
transition-duration:
|
|
89
|
-
var(--ifm-button-transition-duration);
|
|
88
|
+
transition-duration:
|
|
89
|
+
100ms, 100ms, 100ms, var(--ifm-button-transition-duration);
|
|
90
90
|
transition-timing-function: cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
91
91
|
user-select: none;
|
|
92
92
|
white-space: nowrap;
|
|
@@ -95,14 +95,37 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
95
95
|
|
|
96
96
|
const methods = useForm({ shouldFocusError: false });
|
|
97
97
|
|
|
98
|
+
const handleEventStream = async (res) => {
|
|
99
|
+
res.headers && dispatch(setHeaders(Object.fromEntries(res.headers)));
|
|
100
|
+
dispatch(setCode(res.status));
|
|
101
|
+
|
|
102
|
+
const reader = res.body.getReader();
|
|
103
|
+
const decoder = new TextDecoder();
|
|
104
|
+
let result = "";
|
|
105
|
+
while (true) {
|
|
106
|
+
const { done, value } = await reader.read();
|
|
107
|
+
if (done) break;
|
|
108
|
+
result += decoder.decode(value, { stream: true });
|
|
109
|
+
dispatch(setResponse(result));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const handleResponse = async (res) => {
|
|
114
|
+
dispatch(setResponse(await res.text()));
|
|
115
|
+
dispatch(setCode(res.status));
|
|
116
|
+
res.headers && dispatch(setHeaders(Object.fromEntries(res.headers)));
|
|
117
|
+
};
|
|
118
|
+
|
|
98
119
|
const onSubmit = async (data) => {
|
|
99
120
|
dispatch(setResponse("Fetching..."));
|
|
100
121
|
try {
|
|
101
122
|
await delay(1200);
|
|
102
123
|
const res = await makeRequest(postmanRequest, proxy, body);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
if (res.headers.get("content-type")?.includes("text/event-stream")) {
|
|
125
|
+
await handleEventStream(res);
|
|
126
|
+
} else {
|
|
127
|
+
await handleResponse(res);
|
|
128
|
+
}
|
|
106
129
|
} catch (e: any) {
|
|
107
130
|
console.log(e);
|
|
108
131
|
dispatch(setResponse("Connection failed"));
|
|
@@ -210,7 +210,11 @@ function TabsComponent(props: TabProps): React.JSX.Element {
|
|
|
210
210
|
export default function DiscriminatorTabs(props: TabProps): React.JSX.Element {
|
|
211
211
|
const isBrowser = useIsBrowser();
|
|
212
212
|
|
|
213
|
-
if (
|
|
213
|
+
if (
|
|
214
|
+
!props.children ||
|
|
215
|
+
(Array.isArray(props.children) && props.children.length === 0)
|
|
216
|
+
)
|
|
217
|
+
return <React.Fragment />;
|
|
214
218
|
|
|
215
219
|
return (
|
|
216
220
|
<TabsComponent
|
|
@@ -70,9 +70,14 @@ function ParamsItem({ param, ...rest }: Props) {
|
|
|
70
70
|
let schema = param.schema;
|
|
71
71
|
let defaultValue: string | undefined;
|
|
72
72
|
|
|
73
|
-
if (!schema
|
|
73
|
+
if (!schema) {
|
|
74
74
|
schema = { type: "any" };
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
if (!schema.type) {
|
|
78
|
+
schema.type = "any";
|
|
79
|
+
}
|
|
80
|
+
|
|
76
81
|
if (schema) {
|
|
77
82
|
if (schema.items) {
|
|
78
83
|
defaultValue = schema.items.default;
|
|
@@ -352,7 +352,8 @@ const DiscriminatorNode: React.FC<DiscriminatorNodeProps> = ({
|
|
|
352
352
|
}
|
|
353
353
|
|
|
354
354
|
const subProperties = subSchema.properties || mergedSubSchema.properties;
|
|
355
|
-
|
|
355
|
+
// Add a safeguard check to avoid referencing subProperties if it's undefined
|
|
356
|
+
if (subProperties && subProperties[discriminator.propertyName]) {
|
|
356
357
|
if (schema.properties) {
|
|
357
358
|
schema.properties![discriminator.propertyName] = {
|
|
358
359
|
...schema.properties![discriminator.propertyName],
|
|
@@ -840,6 +841,25 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
|
|
|
840
841
|
);
|
|
841
842
|
};
|
|
842
843
|
|
|
844
|
+
function renderChildren(
|
|
845
|
+
schema: SchemaObject,
|
|
846
|
+
schemaType: "request" | "response"
|
|
847
|
+
) {
|
|
848
|
+
return (
|
|
849
|
+
<>
|
|
850
|
+
{schema.oneOf && <AnyOneOf schema={schema} schemaType={schemaType} />}
|
|
851
|
+
{schema.anyOf && <AnyOneOf schema={schema} schemaType={schemaType} />}
|
|
852
|
+
{schema.properties && (
|
|
853
|
+
<Properties schema={schema} schemaType={schemaType} />
|
|
854
|
+
)}
|
|
855
|
+
{schema.additionalProperties && (
|
|
856
|
+
<AdditionalProperties schema={schema} schemaType={schemaType} />
|
|
857
|
+
)}
|
|
858
|
+
{schema.items && <Items schema={schema} schemaType={schemaType} />}
|
|
859
|
+
</>
|
|
860
|
+
);
|
|
861
|
+
}
|
|
862
|
+
|
|
843
863
|
const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
844
864
|
if (
|
|
845
865
|
(schemaType === "request" && schema.readOnly) ||
|
|
@@ -888,10 +908,6 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
888
908
|
);
|
|
889
909
|
}
|
|
890
910
|
|
|
891
|
-
if (schema.oneOf || schema.anyOf) {
|
|
892
|
-
return <AnyOneOf schema={schema} schemaType={schemaType} />;
|
|
893
|
-
}
|
|
894
|
-
|
|
895
911
|
// Handle primitives
|
|
896
912
|
if (
|
|
897
913
|
schema.type &&
|
|
@@ -917,19 +933,7 @@ const SchemaNode: React.FC<SchemaProps> = ({ schema, schemaType }) => {
|
|
|
917
933
|
);
|
|
918
934
|
}
|
|
919
935
|
|
|
920
|
-
return (
|
|
921
|
-
<div>
|
|
922
|
-
{schema.oneOf && <AnyOneOf schema={schema} schemaType={schemaType} />}
|
|
923
|
-
{schema.anyOf && <AnyOneOf schema={schema} schemaType={schemaType} />}
|
|
924
|
-
{schema.properties && (
|
|
925
|
-
<Properties schema={schema} schemaType={schemaType} />
|
|
926
|
-
)}
|
|
927
|
-
{schema.additionalProperties && (
|
|
928
|
-
<AdditionalProperties schema={schema} schemaType={schemaType} />
|
|
929
|
-
)}
|
|
930
|
-
{schema.items && <Items schema={schema} schemaType={schemaType} />}
|
|
931
|
-
</div>
|
|
932
|
-
);
|
|
936
|
+
return renderChildren(schema, schemaType);
|
|
933
937
|
};
|
|
934
938
|
|
|
935
939
|
export default SchemaNode;
|