docusaurus-theme-openapi-docs 0.0.0-1050 → 0.0.0-1055
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/Authorization/index.js +44 -8
- package/lib/theme/ApiExplorer/Body/index.js +16 -3
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +35 -24
- package/lib/theme/ApiExplorer/FormFileUpload/index.js +6 -1
- package/lib/theme/ApiExplorer/FormItem/index.js +6 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.js +8 -1
- package/lib/theme/ApiExplorer/LiveEditor/index.js +9 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +10 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +10 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +10 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +10 -1
- package/lib/theme/ApiExplorer/ParamOptions/index.js +11 -1
- package/lib/theme/ApiExplorer/Request/index.js +59 -12
- package/lib/theme/ApiExplorer/Response/index.js +27 -13
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +167 -19
- package/lib/theme/ApiExplorer/Server/index.js +16 -2
- package/lib/theme/ApiExplorer/index.js +4 -0
- package/lib/theme/ApiTabs/index.js +6 -1
- package/lib/theme/ParamsDetails/index.js +9 -1
- package/lib/theme/ParamsItem/index.js +63 -8
- package/lib/theme/RequestSchema/index.js +10 -2
- package/lib/theme/ResponseExamples/index.js +23 -3
- package/lib/theme/ResponseSchema/index.js +7 -1
- package/lib/theme/SchemaItem/index.js +68 -9
- package/lib/theme/StatusCodes/index.js +11 -2
- package/lib/theme/translationIds.d.ts +73 -0
- package/lib/theme/translationIds.js +96 -0
- package/package.json +3 -3
- package/src/theme/ApiExplorer/Authorization/index.tsx +44 -8
- package/src/theme/ApiExplorer/Body/index.tsx +15 -3
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +38 -24
- 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 +8 -1
- package/src/theme/ApiExplorer/LiveEditor/index.tsx +9 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +10 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +10 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +10 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +10 -1
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +10 -2
- package/src/theme/ApiExplorer/Request/index.tsx +55 -12
- package/src/theme/ApiExplorer/Response/index.tsx +23 -7
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +117 -19
- package/src/theme/ApiExplorer/Server/index.tsx +10 -2
- package/src/theme/ApiExplorer/index.tsx +5 -0
- package/src/theme/ApiTabs/index.tsx +6 -1
- package/src/theme/ParamsDetails/index.tsx +10 -1
- package/src/theme/ParamsItem/index.tsx +45 -8
- package/src/theme/RequestSchema/index.tsx +11 -2
- package/src/theme/ResponseExamples/index.tsx +23 -3
- package/src/theme/ResponseSchema/index.tsx +7 -1
- package/src/theme/SchemaItem/index.tsx +49 -9
- package/src/theme/StatusCodes/index.tsx +13 -2
- package/src/theme/translationIds.ts +93 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -29,6 +29,7 @@ export const languageSet: Language[] = generateLanguageSet();
|
|
|
29
29
|
export interface Props {
|
|
30
30
|
postman: sdk.Request;
|
|
31
31
|
codeSamples: CodeSample[];
|
|
32
|
+
maskCredentials?: boolean;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
function CodeTab({ children, hidden, className }: any): React.JSX.Element {
|
|
@@ -39,7 +40,11 @@ function CodeTab({ children, hidden, className }: any): React.JSX.Element {
|
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
function CodeSnippets({
|
|
43
|
+
function CodeSnippets({
|
|
44
|
+
postman,
|
|
45
|
+
codeSamples,
|
|
46
|
+
maskCredentials: propMaskCredentials,
|
|
47
|
+
}: Props) {
|
|
43
48
|
const { siteConfig } = useDocusaurusContext();
|
|
44
49
|
|
|
45
50
|
const contentType = useTypedSelector((state: any) => state.contentType.value);
|
|
@@ -53,33 +58,42 @@ function CodeSnippets({ postman, codeSamples }: Props) {
|
|
|
53
58
|
const headerParams = useTypedSelector((state: any) => state.params.header);
|
|
54
59
|
|
|
55
60
|
const auth = useTypedSelector((state: any) => state.auth);
|
|
56
|
-
const clonedAuth = cloneDeep(auth);
|
|
57
|
-
let placeholder: string;
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
62
|
-
// use name as placeholder if exists
|
|
63
|
-
const comboAuthId = Object.keys(obj).join(" and ");
|
|
64
|
-
const authOptions =
|
|
65
|
-
clonedAuth?.options?.[key] ?? clonedAuth?.options?.[comboAuthId];
|
|
66
|
-
placeholder = authOptions?.[0]?.name;
|
|
67
|
-
obj[key] = cleanCredentials(obj[key]);
|
|
68
|
-
} else {
|
|
69
|
-
obj[key] = `<${placeholder ?? key}>`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
62
|
+
// Check if credential masking is enabled (default: true)
|
|
63
|
+
const maskCredentials = propMaskCredentials ?? true;
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
// Clone Auth if maskCredentials is not false
|
|
66
|
+
const cleanedAuth = maskCredentials
|
|
67
|
+
? (() => {
|
|
68
|
+
const clonedAuth = cloneDeep(auth);
|
|
69
|
+
let placeholder: string;
|
|
70
|
+
|
|
71
|
+
function cleanCredentials(obj: any) {
|
|
72
|
+
for (const key in obj) {
|
|
73
|
+
if (typeof obj[key] === "object" && obj[key] !== null) {
|
|
74
|
+
// use name as placeholder if exists
|
|
75
|
+
const comboAuthId = Object.keys(obj).join(" and ");
|
|
76
|
+
const authOptions =
|
|
77
|
+
clonedAuth?.options?.[key] ??
|
|
78
|
+
clonedAuth?.options?.[comboAuthId];
|
|
79
|
+
placeholder = authOptions?.[0]?.name;
|
|
80
|
+
obj[key] = cleanCredentials(obj[key]);
|
|
81
|
+
} else {
|
|
82
|
+
obj[key] = `<${placeholder ?? key}>`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return obj;
|
|
87
|
+
}
|
|
75
88
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
return {
|
|
90
|
+
...clonedAuth,
|
|
91
|
+
data: cleanCredentials(clonedAuth.data),
|
|
92
|
+
};
|
|
93
|
+
})()
|
|
94
|
+
: auth;
|
|
81
95
|
|
|
82
|
-
// Create a Postman request object using cleanedAuth
|
|
96
|
+
// Create a Postman request object using cleanedAuth or original auth
|
|
83
97
|
const cleanedPostmanRequest = buildPostmanRequest(postman, {
|
|
84
98
|
queryParams,
|
|
85
99
|
pathParams,
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import React, { useState } from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import FloatingButton from "@theme/ApiExplorer/FloatingButton";
|
|
12
|
+
import { OPENAPI_FORM_FILE_UPLOAD } from "@theme/translationIds";
|
|
11
13
|
import MagicDropzone from "react-magic-dropzone";
|
|
12
14
|
|
|
13
15
|
type PreviewFile = { preview: string } & File;
|
|
@@ -102,7 +104,10 @@ function FormFileUpload({ placeholder, onChange }: Props) {
|
|
|
102
104
|
setAndNotifyFile(undefined);
|
|
103
105
|
}}
|
|
104
106
|
>
|
|
105
|
-
|
|
107
|
+
{translate({
|
|
108
|
+
id: OPENAPI_FORM_FILE_UPLOAD.CLEAR_BUTTON,
|
|
109
|
+
message: "Clear",
|
|
110
|
+
})}
|
|
106
111
|
</button>
|
|
107
112
|
<RenderPreview file={file} />
|
|
108
113
|
</>
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
|
+
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
|
|
12
|
+
|
|
10
13
|
import clsx from "clsx";
|
|
11
14
|
|
|
12
15
|
export interface Props {
|
|
@@ -24,7 +27,11 @@ function FormItem({ label, type, required, children, className }: Props) {
|
|
|
24
27
|
<label className="openapi-explorer__form-item-label">{label}</label>
|
|
25
28
|
)}
|
|
26
29
|
{type && <span style={{ opacity: 0.6 }}> — {type}</span>}
|
|
27
|
-
{required &&
|
|
30
|
+
{required && (
|
|
31
|
+
<span className="openapi-schema__required">
|
|
32
|
+
{translate({ id: OPENAPI_SCHEMA_ITEM.REQUIRED, message: "required" })}
|
|
33
|
+
</span>
|
|
34
|
+
)}
|
|
28
35
|
<div>{children}</div>
|
|
29
36
|
</div>
|
|
30
37
|
);
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
// @ts-nocheck
|
|
9
9
|
import React from "react";
|
|
10
10
|
|
|
11
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
12
|
import { ErrorMessage } from "@hookform/error-message";
|
|
13
|
+
import { OPENAPI_FORM } from "@theme/translationIds";
|
|
12
14
|
import clsx from "clsx";
|
|
13
15
|
import { useFormContext } from "react-hook-form";
|
|
14
16
|
|
|
@@ -41,7 +43,12 @@ function FormTextInput({
|
|
|
41
43
|
{paramName ? (
|
|
42
44
|
<input
|
|
43
45
|
{...register(paramName, {
|
|
44
|
-
required: isRequired
|
|
46
|
+
required: isRequired
|
|
47
|
+
? translate({
|
|
48
|
+
id: OPENAPI_FORM.FIELD_REQUIRED,
|
|
49
|
+
message: "This field is required",
|
|
50
|
+
})
|
|
51
|
+
: false,
|
|
45
52
|
})}
|
|
46
53
|
className={clsx("openapi-explorer__form-item-input", {
|
|
47
54
|
error: showErrorMessage,
|
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
import React, { type JSX, useEffect, useState } from "react";
|
|
9
9
|
|
|
10
10
|
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
11
|
+
import { translate } from "@docusaurus/Translate";
|
|
11
12
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
12
13
|
import { ErrorMessage } from "@hookform/error-message";
|
|
13
14
|
import { setStringRawBody } from "@theme/ApiExplorer/Body/slice";
|
|
15
|
+
import { OPENAPI_FORM } from "@theme/translationIds";
|
|
14
16
|
import clsx from "clsx";
|
|
15
17
|
import { Controller, useFormContext } from "react-hook-form";
|
|
16
18
|
import { LiveProvider, LiveEditor, withLive } from "react-live";
|
|
@@ -85,7 +87,13 @@ function App({
|
|
|
85
87
|
<Controller
|
|
86
88
|
control={control}
|
|
87
89
|
rules={{
|
|
88
|
-
required:
|
|
90
|
+
required:
|
|
91
|
+
isRequired && !code
|
|
92
|
+
? translate({
|
|
93
|
+
id: OPENAPI_FORM.FIELD_REQUIRED,
|
|
94
|
+
message: "This field is required",
|
|
95
|
+
})
|
|
96
|
+
: false,
|
|
89
97
|
}}
|
|
90
98
|
name="requestBody"
|
|
91
99
|
render={({ field: { onChange, name } }) => (
|
|
@@ -7,12 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
import React, { useEffect, useState } from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import { ErrorMessage } from "@hookform/error-message";
|
|
11
12
|
import { nanoid } from "@reduxjs/toolkit";
|
|
12
13
|
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
13
14
|
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
|
|
14
15
|
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
|
|
15
16
|
import { useTypedDispatch } from "@theme/ApiItem/hooks";
|
|
17
|
+
import { OPENAPI_FORM } from "@theme/translationIds";
|
|
16
18
|
import { Controller, useFormContext } from "react-hook-form";
|
|
17
19
|
|
|
18
20
|
export interface ParamProps {
|
|
@@ -121,7 +123,14 @@ export default function ParamArrayFormItem({ param }: ParamProps) {
|
|
|
121
123
|
<>
|
|
122
124
|
<Controller
|
|
123
125
|
control={control}
|
|
124
|
-
rules={{
|
|
126
|
+
rules={{
|
|
127
|
+
required: param.required
|
|
128
|
+
? translate({
|
|
129
|
+
id: OPENAPI_FORM.FIELD_REQUIRED,
|
|
130
|
+
message: "This field is required",
|
|
131
|
+
})
|
|
132
|
+
: false,
|
|
133
|
+
}}
|
|
125
134
|
name="paramArray"
|
|
126
135
|
render={({ field: { onChange, name } }) => (
|
|
127
136
|
<>
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import { ErrorMessage } from "@hookform/error-message";
|
|
11
12
|
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
12
13
|
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
|
|
13
14
|
import { useTypedDispatch } from "@theme/ApiItem/hooks";
|
|
15
|
+
import { OPENAPI_FORM } from "@theme/translationIds";
|
|
14
16
|
import { Controller, useFormContext } from "react-hook-form";
|
|
15
17
|
|
|
16
18
|
export interface ParamProps {
|
|
@@ -31,7 +33,14 @@ export default function ParamBooleanFormItem({ param }: ParamProps) {
|
|
|
31
33
|
<>
|
|
32
34
|
<Controller
|
|
33
35
|
control={control}
|
|
34
|
-
rules={{
|
|
36
|
+
rules={{
|
|
37
|
+
required: param.required
|
|
38
|
+
? translate({
|
|
39
|
+
id: OPENAPI_FORM.FIELD_REQUIRED,
|
|
40
|
+
message: "This field is required",
|
|
41
|
+
})
|
|
42
|
+
: false,
|
|
43
|
+
}}
|
|
35
44
|
name="paramBoolean"
|
|
36
45
|
render={({ field: { onChange, name } }) => (
|
|
37
46
|
<FormSelect
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import { ErrorMessage } from "@hookform/error-message";
|
|
11
12
|
import FormMultiSelect from "@theme/ApiExplorer/FormMultiSelect";
|
|
12
13
|
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
|
|
13
14
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
15
|
+
import { OPENAPI_FORM } from "@theme/translationIds";
|
|
14
16
|
import { Controller, useFormContext } from "react-hook-form";
|
|
15
17
|
|
|
16
18
|
export interface ParamProps {
|
|
@@ -61,7 +63,14 @@ export default function ParamMultiSelectFormItem({ param }: ParamProps) {
|
|
|
61
63
|
<>
|
|
62
64
|
<Controller
|
|
63
65
|
control={control}
|
|
64
|
-
rules={{
|
|
66
|
+
rules={{
|
|
67
|
+
required: param.required
|
|
68
|
+
? translate({
|
|
69
|
+
id: OPENAPI_FORM.FIELD_REQUIRED,
|
|
70
|
+
message: "This field is required",
|
|
71
|
+
})
|
|
72
|
+
: false,
|
|
73
|
+
}}
|
|
65
74
|
name="paramMultiSelect"
|
|
66
75
|
render={({ field: { onChange, name } }) => (
|
|
67
76
|
<FormMultiSelect
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import React from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import { ErrorMessage } from "@hookform/error-message";
|
|
11
12
|
import FormSelect from "@theme/ApiExplorer/FormSelect";
|
|
12
13
|
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
|
|
13
14
|
import { useTypedDispatch } from "@theme/ApiItem/hooks";
|
|
15
|
+
import { OPENAPI_FORM } from "@theme/translationIds";
|
|
14
16
|
import { Controller, useFormContext } from "react-hook-form";
|
|
15
17
|
|
|
16
18
|
export interface ParamProps {
|
|
@@ -33,7 +35,14 @@ export default function ParamSelectFormItem({ param }: ParamProps) {
|
|
|
33
35
|
<>
|
|
34
36
|
<Controller
|
|
35
37
|
control={control}
|
|
36
|
-
rules={{
|
|
38
|
+
rules={{
|
|
39
|
+
required: param.required
|
|
40
|
+
? translate({
|
|
41
|
+
id: OPENAPI_FORM.FIELD_REQUIRED,
|
|
42
|
+
message: "This field is required",
|
|
43
|
+
})
|
|
44
|
+
: false,
|
|
45
|
+
}}
|
|
37
46
|
name="paramSelect"
|
|
38
47
|
render={({ field: { onChange, name } }) => (
|
|
39
48
|
<FormSelect
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React, { useState } from "react";
|
|
9
9
|
|
|
10
|
+
import { translate } from "@docusaurus/Translate";
|
|
10
11
|
import FormItem from "@theme/ApiExplorer/FormItem";
|
|
11
12
|
import ParamArrayFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem";
|
|
12
13
|
import ParamBooleanFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem";
|
|
@@ -14,6 +15,7 @@ import ParamMultiSelectFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormI
|
|
|
14
15
|
import ParamSelectFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem";
|
|
15
16
|
import ParamTextFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem";
|
|
16
17
|
import { useTypedSelector } from "@theme/ApiItem/hooks";
|
|
18
|
+
import { OPENAPI_PARAM_OPTIONS } from "@theme/translationIds";
|
|
17
19
|
|
|
18
20
|
import { Param } from "./slice";
|
|
19
21
|
|
|
@@ -119,8 +121,14 @@ function ParamOptions() {
|
|
|
119
121
|
</span>
|
|
120
122
|
</span>
|
|
121
123
|
{showOptional
|
|
122
|
-
?
|
|
123
|
-
|
|
124
|
+
? translate({
|
|
125
|
+
id: OPENAPI_PARAM_OPTIONS.HIDE_OPTIONAL,
|
|
126
|
+
message: "Hide optional parameters",
|
|
127
|
+
})
|
|
128
|
+
: translate({
|
|
129
|
+
id: OPENAPI_PARAM_OPTIONS.SHOW_OPTIONAL,
|
|
130
|
+
message: "Show optional parameters",
|
|
131
|
+
})}
|
|
124
132
|
</button>
|
|
125
133
|
|
|
126
134
|
<div
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import React, { useState } from "react";
|
|
10
10
|
|
|
11
11
|
import { useDoc } from "@docusaurus/plugin-content-docs/client";
|
|
12
|
+
import { translate } from "@docusaurus/Translate";
|
|
12
13
|
import Accept from "@theme/ApiExplorer/Accept";
|
|
13
14
|
import Authorization from "@theme/ApiExplorer/Authorization";
|
|
14
15
|
import Body from "@theme/ApiExplorer/Body";
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
} from "@theme/ApiExplorer/Response/slice";
|
|
25
26
|
import Server from "@theme/ApiExplorer/Server";
|
|
26
27
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
28
|
+
import { OPENAPI_REQUEST } from "@theme/translationIds";
|
|
27
29
|
import { ParameterObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
28
30
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
29
31
|
import * as sdk from "postman-collection";
|
|
@@ -117,7 +119,14 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
const onSubmit = async (data) => {
|
|
120
|
-
dispatch(
|
|
122
|
+
dispatch(
|
|
123
|
+
setResponse(
|
|
124
|
+
translate({
|
|
125
|
+
id: OPENAPI_REQUEST.FETCHING_MESSAGE,
|
|
126
|
+
message: "Fetching...",
|
|
127
|
+
})
|
|
128
|
+
)
|
|
129
|
+
);
|
|
121
130
|
try {
|
|
122
131
|
await delay(1200);
|
|
123
132
|
const res = await makeRequest(postmanRequest, proxy, body);
|
|
@@ -128,7 +137,14 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
128
137
|
}
|
|
129
138
|
} catch (e) {
|
|
130
139
|
console.log(e);
|
|
131
|
-
dispatch(
|
|
140
|
+
dispatch(
|
|
141
|
+
setResponse(
|
|
142
|
+
translate({
|
|
143
|
+
id: OPENAPI_REQUEST.CONNECTION_FAILED,
|
|
144
|
+
message: "Connection failed",
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
);
|
|
132
148
|
dispatch(clearCode());
|
|
133
149
|
dispatch(clearHeaders());
|
|
134
150
|
}
|
|
@@ -178,20 +194,31 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
178
194
|
onSubmit={methods.handleSubmit(onSubmit)}
|
|
179
195
|
>
|
|
180
196
|
<div className="openapi-explorer__request-header-container">
|
|
181
|
-
<span className="openapi-explorer__request-title">
|
|
197
|
+
<span className="openapi-explorer__request-title">
|
|
198
|
+
{translate({
|
|
199
|
+
id: OPENAPI_REQUEST.REQUEST_TITLE,
|
|
200
|
+
message: "Request",
|
|
201
|
+
})}
|
|
202
|
+
</span>
|
|
182
203
|
{allDetailsExpanded ? (
|
|
183
204
|
<span
|
|
184
205
|
className="openapi-explorer__expand-details-btn"
|
|
185
206
|
onClick={collapseAllDetails}
|
|
186
207
|
>
|
|
187
|
-
|
|
208
|
+
{translate({
|
|
209
|
+
id: OPENAPI_REQUEST.COLLAPSE_ALL,
|
|
210
|
+
message: "Collapse all",
|
|
211
|
+
})}
|
|
188
212
|
</span>
|
|
189
213
|
) : (
|
|
190
214
|
<span
|
|
191
215
|
className="openapi-explorer__expand-details-btn"
|
|
192
216
|
onClick={expandAllDetails}
|
|
193
217
|
>
|
|
194
|
-
|
|
218
|
+
{translate({
|
|
219
|
+
id: OPENAPI_REQUEST.EXPAND_ALL,
|
|
220
|
+
message: "Expand all",
|
|
221
|
+
})}
|
|
195
222
|
</span>
|
|
196
223
|
)}
|
|
197
224
|
</div>
|
|
@@ -208,7 +235,10 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
208
235
|
setExpandServer(!expandServer);
|
|
209
236
|
}}
|
|
210
237
|
>
|
|
211
|
-
|
|
238
|
+
{translate({
|
|
239
|
+
id: OPENAPI_REQUEST.BASE_URL_TITLE,
|
|
240
|
+
message: "Base URL",
|
|
241
|
+
})}
|
|
212
242
|
</summary>
|
|
213
243
|
<Server />
|
|
214
244
|
</details>
|
|
@@ -225,7 +255,7 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
225
255
|
setExpandAuth(!expandAuth);
|
|
226
256
|
}}
|
|
227
257
|
>
|
|
228
|
-
Auth
|
|
258
|
+
{translate({ id: OPENAPI_REQUEST.AUTH_TITLE, message: "Auth" })}
|
|
229
259
|
</summary>
|
|
230
260
|
<Authorization />
|
|
231
261
|
</details>
|
|
@@ -244,7 +274,10 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
244
274
|
setExpandParams(!expandParams);
|
|
245
275
|
}}
|
|
246
276
|
>
|
|
247
|
-
|
|
277
|
+
{translate({
|
|
278
|
+
id: OPENAPI_REQUEST.PARAMETERS_TITLE,
|
|
279
|
+
message: "Parameters",
|
|
280
|
+
})}
|
|
248
281
|
</summary>
|
|
249
282
|
<ParamOptions />
|
|
250
283
|
</details>
|
|
@@ -261,10 +294,14 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
261
294
|
setExpandBody(!expandBody);
|
|
262
295
|
}}
|
|
263
296
|
>
|
|
264
|
-
Body
|
|
297
|
+
{translate({ id: OPENAPI_REQUEST.BODY_TITLE, message: "Body" })}
|
|
265
298
|
{requestBodyRequired && (
|
|
266
299
|
<span className="openapi-schema__required">
|
|
267
|
-
|
|
300
|
+
|
|
301
|
+
{translate({
|
|
302
|
+
id: OPENAPI_REQUEST.REQUIRED_LABEL,
|
|
303
|
+
message: "required",
|
|
304
|
+
})}
|
|
268
305
|
</span>
|
|
269
306
|
)}
|
|
270
307
|
</summary>
|
|
@@ -290,14 +327,20 @@ function Request({ item }: { item: ApiItem }) {
|
|
|
290
327
|
setExpandAccept(!expandAccept);
|
|
291
328
|
}}
|
|
292
329
|
>
|
|
293
|
-
|
|
330
|
+
{translate({
|
|
331
|
+
id: OPENAPI_REQUEST.ACCEPT_TITLE,
|
|
332
|
+
message: "Accept",
|
|
333
|
+
})}
|
|
294
334
|
</summary>
|
|
295
335
|
<Accept />
|
|
296
336
|
</details>
|
|
297
337
|
)}
|
|
298
338
|
{showRequestButton && item.method !== "event" && (
|
|
299
339
|
<button className="openapi-explorer__request-btn" type="submit">
|
|
300
|
-
|
|
340
|
+
{translate({
|
|
341
|
+
id: OPENAPI_REQUEST.SEND_BUTTON,
|
|
342
|
+
message: "Send API Request",
|
|
343
|
+
})}
|
|
301
344
|
</button>
|
|
302
345
|
)}
|
|
303
346
|
</div>
|
|
@@ -9,10 +9,12 @@ import React from "react";
|
|
|
9
9
|
|
|
10
10
|
import { useDoc } from "@docusaurus/plugin-content-docs/client";
|
|
11
11
|
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
12
|
+
import { translate } from "@docusaurus/Translate";
|
|
12
13
|
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
|
|
13
14
|
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
|
|
14
15
|
import SchemaTabs from "@theme/SchemaTabs";
|
|
15
16
|
import TabItem from "@theme/TabItem";
|
|
17
|
+
import { OPENAPI_RESPONSE } from "@theme/translationIds";
|
|
16
18
|
import clsx from "clsx";
|
|
17
19
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
18
20
|
|
|
@@ -74,7 +76,9 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
74
76
|
return (
|
|
75
77
|
<div className="openapi-explorer__response-container">
|
|
76
78
|
<div className="openapi-explorer__response-title-container">
|
|
77
|
-
<span className="openapi-explorer__response-title">
|
|
79
|
+
<span className="openapi-explorer__response-title">
|
|
80
|
+
{translate({ id: OPENAPI_RESPONSE.TITLE, message: "Response" })}
|
|
81
|
+
</span>
|
|
78
82
|
<span
|
|
79
83
|
className="openapi-explorer__response-clear-btn"
|
|
80
84
|
onClick={() => {
|
|
@@ -83,7 +87,7 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
83
87
|
dispatch(clearHeaders());
|
|
84
88
|
}}
|
|
85
89
|
>
|
|
86
|
-
Clear
|
|
90
|
+
{translate({ id: OPENAPI_RESPONSE.CLEAR, message: "Clear" })}
|
|
87
91
|
</span>
|
|
88
92
|
</div>
|
|
89
93
|
<div
|
|
@@ -117,14 +121,23 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
117
121
|
>
|
|
118
122
|
{prettyResponse || (
|
|
119
123
|
<p className="openapi-explorer__response-placeholder-message">
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
{translate({
|
|
125
|
+
id: OPENAPI_RESPONSE.PLACEHOLDER,
|
|
126
|
+
message:
|
|
127
|
+
"Click the <code>Send API Request</code> button above and see the response here!",
|
|
128
|
+
})}
|
|
122
129
|
</p>
|
|
123
130
|
)}
|
|
124
131
|
</ApiCodeBlock>
|
|
125
132
|
</TabItem>
|
|
126
133
|
{/* @ts-ignore */}
|
|
127
|
-
<TabItem
|
|
134
|
+
<TabItem
|
|
135
|
+
label={translate({
|
|
136
|
+
id: OPENAPI_RESPONSE.HEADERS_TAB,
|
|
137
|
+
message: "Headers",
|
|
138
|
+
})}
|
|
139
|
+
value="headers"
|
|
140
|
+
>
|
|
128
141
|
{/* @ts-ignore */}
|
|
129
142
|
<ApiCodeBlock
|
|
130
143
|
className="openapi-explorer__code-block openapi-response__status-headers"
|
|
@@ -145,8 +158,11 @@ function Response({ item }: { item: ApiItem }) {
|
|
|
145
158
|
</div>
|
|
146
159
|
) : (
|
|
147
160
|
<p className="openapi-explorer__response-placeholder-message">
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
{translate({
|
|
162
|
+
id: OPENAPI_RESPONSE.PLACEHOLDER,
|
|
163
|
+
message:
|
|
164
|
+
"Click the <code>Send API Request</code> button above and see the response here!",
|
|
165
|
+
})}
|
|
150
166
|
</p>
|
|
151
167
|
)}
|
|
152
168
|
</div>
|