@digi-frontend/dgate-api-documentation 1.0.4 → 1.0.5
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/dist/_virtual/index3.js +1 -1
- package/dist/_virtual/index4.js +1 -1
- package/dist/_virtual/index5.js +1 -1
- package/dist/_virtual/index6.js +1 -1
- package/dist/node_modules/digitinary-ui/dist/index.js +1 -1
- package/dist/node_modules/digitinary-ui/dist/index.js.map +1 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs.js +3 -0
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs.js.map +1 -0
- package/dist/node_modules/toposort/index.js +1 -1
- package/dist/node_modules/yup/index.esm.js +1 -1
- package/dist/src/components/InfoForm/InfoForm.js +1 -1
- package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
- package/dist/src/components/JsonInput/JsonInput.js +2 -0
- package/dist/src/components/JsonInput/JsonInput.js.map +1 -0
- package/dist/src/components/JsonInput/style.module.scss.js +2 -0
- package/dist/src/components/JsonInput/style.module.scss.js.map +1 -0
- package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
- package/dist/src/constants/index.js +1 -1
- package/dist/src/constants/index.js.map +1 -1
- package/dist/src/helpers/layout.helper.js +1 -1
- package/dist/src/helpers/layout.helper.js.map +1 -1
- package/dist/src/layout/layout.js +1 -1
- package/dist/src/layout/layout.js.map +1 -1
- package/dist/src/layout/layout.module.css.js +1 -1
- package/dist/styles.css +315 -212
- package/dist/types/components/JsonInput/JsonInput.d.ts +13 -0
- package/dist/types/components/MethodAccordion/MethodAccordion.d.ts +1 -2
- package/dist/types/constants/index.d.ts +12 -4
- package/dist/types/types/layout.type.d.ts +9 -1
- package/dist/types/types/openApi.d.ts +1 -1
- package/package.json +2 -1
- package/src/components/InfoForm/InfoForm.module.scss +0 -5
- package/src/components/InfoForm/InfoForm.tsx +3 -17
- package/src/components/JsonInput/JsonInput.tsx +124 -0
- package/src/components/JsonInput/style.module.scss +123 -0
- package/src/components/MethodAccordion/MethodAccordion.module.scss +10 -5
- package/src/components/MethodAccordion/MethodAccordion.tsx +17 -47
- package/src/constants/index.ts +16 -8
- package/src/helpers/layout.helper.ts +53 -24
- package/src/layout/layout.module.css +18 -0
- package/src/layout/layout.tsx +40 -16
- package/src/types/layout.type.ts +9 -1
- package/src/types/openApi.ts +1 -1
- package/dist/types/types/index.d.ts +0 -18
|
@@ -2,34 +2,42 @@ export declare const methodColorMapping: {
|
|
|
2
2
|
get: {
|
|
3
3
|
label: string;
|
|
4
4
|
color: string;
|
|
5
|
+
order: number;
|
|
5
6
|
};
|
|
6
7
|
post: {
|
|
7
8
|
label: string;
|
|
8
9
|
color: string;
|
|
10
|
+
order: number;
|
|
9
11
|
};
|
|
10
12
|
put: {
|
|
11
13
|
label: string;
|
|
12
14
|
color: string;
|
|
15
|
+
order: number;
|
|
13
16
|
};
|
|
14
17
|
delete: {
|
|
15
18
|
label: string;
|
|
16
19
|
color: string;
|
|
20
|
+
order: number;
|
|
17
21
|
};
|
|
18
|
-
|
|
22
|
+
patch: {
|
|
19
23
|
label: string;
|
|
20
24
|
color: string;
|
|
25
|
+
order: number;
|
|
21
26
|
};
|
|
22
|
-
|
|
27
|
+
options: {
|
|
23
28
|
label: string;
|
|
24
29
|
color: string;
|
|
30
|
+
order: number;
|
|
25
31
|
};
|
|
26
|
-
|
|
32
|
+
trace: {
|
|
27
33
|
label: string;
|
|
28
34
|
color: string;
|
|
35
|
+
order: number;
|
|
29
36
|
};
|
|
30
|
-
|
|
37
|
+
head: {
|
|
31
38
|
label: string;
|
|
32
39
|
color: string;
|
|
40
|
+
order: number;
|
|
33
41
|
};
|
|
34
42
|
};
|
|
35
43
|
export declare const paramsTableHeaders: ({
|
|
@@ -3,7 +3,15 @@ export type TransformedMethod = {
|
|
|
3
3
|
type: HTTPMethod;
|
|
4
4
|
tags: string[];
|
|
5
5
|
parameters: any;
|
|
6
|
-
requestBody:
|
|
6
|
+
requestBody: {
|
|
7
|
+
content: {
|
|
8
|
+
contentType: string;
|
|
9
|
+
schema: {
|
|
10
|
+
properties: string;
|
|
11
|
+
type: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}[];
|
|
7
15
|
responses: {
|
|
8
16
|
code: string;
|
|
9
17
|
content: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digi-frontend/dgate-api-documentation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"main": "dist/src/index.js",
|
|
5
5
|
"module": "dist/src/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"digitinary-ui": "^1.0.156",
|
|
20
20
|
"formik": "^2.4.6",
|
|
21
21
|
"html-react-parser": "^5.2.2",
|
|
22
|
+
"js-yaml": "^4.1.0",
|
|
22
23
|
"react": "^18.0.0",
|
|
23
24
|
"react-dom": "^18.0.0",
|
|
24
25
|
"tslib": "^2.8.1",
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import { useFormikContext } from 'formik'
|
|
4
|
-
import
|
|
5
|
-
import { Button, Input, SelectGroup, TextArea } from 'digitinary-ui'
|
|
4
|
+
import { Input, SelectGroup, TextArea } from 'digitinary-ui'
|
|
6
5
|
import styles from './InfoForm.module.scss'
|
|
7
6
|
import Chips from '../../components/Chips/Chips'
|
|
8
|
-
import { CheckMarkSquare } from '../../assets/icons'
|
|
9
|
-
import SVGLoader from '../../components/SVGLoader/SVGLoader'
|
|
10
7
|
import regex from '../../constants/regex'
|
|
11
8
|
import { TransformedOpenApi } from '../../types/transformedOpenApi'
|
|
12
9
|
|
|
13
10
|
const InfoForm = () => {
|
|
14
11
|
const [tagsList, setTagsList] = useState([])
|
|
15
12
|
const [authType, setAuthType] = useState('')
|
|
16
|
-
const { values, setFieldValue, errors
|
|
13
|
+
const { values, setFieldValue, errors } = useFormikContext<TransformedOpenApi>()
|
|
14
|
+
|
|
17
15
|
useEffect(() => {
|
|
18
16
|
if (values && values.tags) {
|
|
19
17
|
setTagsList(values.tags)
|
|
@@ -119,18 +117,6 @@ const InfoForm = () => {
|
|
|
119
117
|
}
|
|
120
118
|
/>
|
|
121
119
|
)}
|
|
122
|
-
<Button
|
|
123
|
-
className={styles.apiInfoForm_submitBtn}
|
|
124
|
-
size="small"
|
|
125
|
-
fullWidth={false}
|
|
126
|
-
onClick={submitForm}
|
|
127
|
-
type="submit"
|
|
128
|
-
variant="link"
|
|
129
|
-
color="success"
|
|
130
|
-
startIcon={<SVGLoader src={CheckMarkSquare} width="1.5rem" height="1.5rem" />}
|
|
131
|
-
>
|
|
132
|
-
Save
|
|
133
|
-
</Button>
|
|
134
120
|
</form>
|
|
135
121
|
)
|
|
136
122
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import yaml from 'js-yaml'
|
|
3
|
+
import styles from './style.module.scss'
|
|
4
|
+
|
|
5
|
+
const JsonInput = ({
|
|
6
|
+
placeholder,
|
|
7
|
+
label,
|
|
8
|
+
value,
|
|
9
|
+
onValidation,
|
|
10
|
+
onChange,
|
|
11
|
+
dataId,
|
|
12
|
+
className = '',
|
|
13
|
+
errorMessage,
|
|
14
|
+
acceptType = 'BOTH',
|
|
15
|
+
fieldIsDisabled,
|
|
16
|
+
}) => {
|
|
17
|
+
const [isValid, setIsValid] = useState()
|
|
18
|
+
const [disabledBeautify, setDisabledBeautify] = useState(true)
|
|
19
|
+
|
|
20
|
+
const handlePrettify = (e) => {
|
|
21
|
+
if (value === '') return
|
|
22
|
+
e.preventDefault()
|
|
23
|
+
try {
|
|
24
|
+
let prettifiedData
|
|
25
|
+
if ((acceptType === 'BOTH' || acceptType === 'JSON') && isValidJson(value)) {
|
|
26
|
+
// If it's valid JSON, prettify JSON
|
|
27
|
+
prettifiedData = JSON.stringify(JSON.parse(value), null, 2)
|
|
28
|
+
} else if (acceptType === 'BOTH' || acceptType === 'YML') {
|
|
29
|
+
// If it's not valid JSON, prettify YAML
|
|
30
|
+
prettifiedData = yaml.dump(yaml.load(value), { indent: 0 })
|
|
31
|
+
}
|
|
32
|
+
onChange(prettifiedData)
|
|
33
|
+
setIsValid(true) // Reset validity status
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(error)
|
|
36
|
+
setIsValid(false)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Function to check if input is valid JSON
|
|
41
|
+
const isValidJson = (str) => {
|
|
42
|
+
try {
|
|
43
|
+
JSON.parse(str)
|
|
44
|
+
return true
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const checkIsValid = () => {
|
|
51
|
+
if (acceptType === 'BOTH' || acceptType === 'JSON') {
|
|
52
|
+
return isValidJson(value)
|
|
53
|
+
} else if (acceptType === 'BOTH' || acceptType === 'YML') {
|
|
54
|
+
try {
|
|
55
|
+
// Try parsing as YAML
|
|
56
|
+
yaml.load(value)
|
|
57
|
+
return true
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error(error)
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
try {
|
|
67
|
+
handlePrettify(value)
|
|
68
|
+
} catch {}
|
|
69
|
+
}, [])
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div className={`${styles['json-editor-container']} ${className}`}>
|
|
73
|
+
{label && <p className={`${styles['json-editor-label']}`}>{label}</p>}
|
|
74
|
+
<div
|
|
75
|
+
className={`${styles['json-editor']} ${
|
|
76
|
+
value !== '' && isValid === false ? styles.invalid : ''
|
|
77
|
+
}`}
|
|
78
|
+
>
|
|
79
|
+
<textarea
|
|
80
|
+
data-id={dataId}
|
|
81
|
+
value={value}
|
|
82
|
+
onChange={(e) => {
|
|
83
|
+
if (fieldIsDisabled) return
|
|
84
|
+
setIsValid(undefined)
|
|
85
|
+
setDisabledBeautify(true)
|
|
86
|
+
onChange(e.target.value)
|
|
87
|
+
}}
|
|
88
|
+
min="1"
|
|
89
|
+
placeholder={placeholder}
|
|
90
|
+
/>
|
|
91
|
+
<div className={`${styles['actions-container']}`}>
|
|
92
|
+
<button
|
|
93
|
+
type="button"
|
|
94
|
+
className={styles.validate}
|
|
95
|
+
onClick={() => {
|
|
96
|
+
const valid = checkIsValid()
|
|
97
|
+
setIsValid(valid)
|
|
98
|
+
onValidation(valid)
|
|
99
|
+
setDisabledBeautify(!checkIsValid())
|
|
100
|
+
}}
|
|
101
|
+
data-id={`${dataId}-VALIDATE-BUTTON`}
|
|
102
|
+
disabled={value === ''}
|
|
103
|
+
>
|
|
104
|
+
Validate
|
|
105
|
+
</button>
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
disabled={value === '' || disabledBeautify}
|
|
109
|
+
data-id={`${dataId}-BEAUTIFY-BUTTON`}
|
|
110
|
+
className={styles.beautify}
|
|
111
|
+
onClick={handlePrettify}
|
|
112
|
+
>
|
|
113
|
+
Beautify
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
{(errorMessage || (value !== '' && isValid === false)) && (
|
|
118
|
+
<p className={styles['error-message']}>{errorMessage || 'Invalid JSON or YAML format'}</p>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default JsonInput
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
.json-editor-container {
|
|
2
|
+
.json-editor-label {
|
|
3
|
+
font-size: 0.875rem;
|
|
4
|
+
font-weight: 600;
|
|
5
|
+
line-height: 1.25rem;
|
|
6
|
+
margin-bottom: 0.3125rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.json-editor {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
background-color: #142452;
|
|
13
|
+
width: 100%;
|
|
14
|
+
border-radius: 0.3125rem;
|
|
15
|
+
margin-bottom: -0.5rem;
|
|
16
|
+
outline: 1px solid transparent;
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
.actions-container {
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 5rem;
|
|
22
|
+
padding: 1.25rem;
|
|
23
|
+
border-radius: 0 0 0.3125rem 0.3125rem;
|
|
24
|
+
background: #101e47;
|
|
25
|
+
display: flex;
|
|
26
|
+
flex-direction: row;
|
|
27
|
+
gap: 1.25rem;
|
|
28
|
+
align-items: center;
|
|
29
|
+
|
|
30
|
+
.validate {
|
|
31
|
+
color: #fff;
|
|
32
|
+
text-align: center;
|
|
33
|
+
font-size: 1rem;
|
|
34
|
+
font-style: normal;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
line-height: 1.25rem;
|
|
37
|
+
width: 8.75rem;
|
|
38
|
+
padding: 0.625rem 2.25rem;
|
|
39
|
+
background-color: rgba(240, 248, 255, 0);
|
|
40
|
+
border-radius: 0.3125rem;
|
|
41
|
+
border: 0.0625rem solid #4d75d8;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
|
|
44
|
+
&:disabled {
|
|
45
|
+
color: #babdcc;
|
|
46
|
+
border-color: #a2a5b6;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.beautify {
|
|
51
|
+
color: #fff;
|
|
52
|
+
text-align: center;
|
|
53
|
+
font-size: 1rem;
|
|
54
|
+
font-style: normal;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
line-height: 1.25rem;
|
|
57
|
+
width: 8.75rem;
|
|
58
|
+
padding: 0.625rem 2.25rem;
|
|
59
|
+
background-color: rgba(240, 248, 255, 0);
|
|
60
|
+
border-radius: 0.3125rem;
|
|
61
|
+
border: 1px solid #babdcc;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
|
|
64
|
+
&:disabled {
|
|
65
|
+
color: #a2a5b6;
|
|
66
|
+
border-color: #a2a5b6;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
textarea {
|
|
72
|
+
width: 100%;
|
|
73
|
+
padding: 1.25rem;
|
|
74
|
+
font-size: 0.875rem;
|
|
75
|
+
font-style: normal;
|
|
76
|
+
font-weight: 400;
|
|
77
|
+
line-height: 1.25rem;
|
|
78
|
+
color: white;
|
|
79
|
+
height: 25rem;
|
|
80
|
+
background-color: #142452;
|
|
81
|
+
border: none;
|
|
82
|
+
resize: none;
|
|
83
|
+
border-radius: 0.3125rem;
|
|
84
|
+
|
|
85
|
+
&:focus,
|
|
86
|
+
&:focus-within,
|
|
87
|
+
&:focus-visible &:active {
|
|
88
|
+
outline: none;
|
|
89
|
+
border: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&::-webkit-scrollbar {
|
|
93
|
+
width: 0.5rem;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&::-webkit-scrollbar-track {
|
|
97
|
+
background-color: #828699;
|
|
98
|
+
border: none;
|
|
99
|
+
border-color: transparent;
|
|
100
|
+
border-top-right-radius: 0.25rem;
|
|
101
|
+
border-top-left-radius: 0;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&::-webkit-scrollbar-thumb {
|
|
105
|
+
background-color: #d8dae5;
|
|
106
|
+
border: none;
|
|
107
|
+
border-color: transparent;
|
|
108
|
+
border-radius: 0;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
&.invalid {
|
|
113
|
+
outline: 1px solid #ce2828 !important;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.error-message {
|
|
118
|
+
color: #ce2828;
|
|
119
|
+
font-size: 0.75rem;
|
|
120
|
+
line-height: 1.25rem;
|
|
121
|
+
margin-top: 0.625rem;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -187,6 +187,16 @@
|
|
|
187
187
|
border-top: 1px solid #babdcc !important;
|
|
188
188
|
padding: 1.25rem !important;
|
|
189
189
|
padding: 0 !important;
|
|
190
|
+
|
|
191
|
+
:global(.jsonField) {
|
|
192
|
+
div {
|
|
193
|
+
textarea {
|
|
194
|
+
border-top-right-radius: 0;
|
|
195
|
+
border-top-left-radius: 0;
|
|
196
|
+
height: 10rem;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
:global(.details.show .textArea .containerTextArea) {
|
|
@@ -280,10 +290,5 @@
|
|
|
280
290
|
}
|
|
281
291
|
}
|
|
282
292
|
}
|
|
283
|
-
|
|
284
|
-
.methodForm_submitBtn {
|
|
285
|
-
height: 1.25rem !important;
|
|
286
|
-
width: 4.25rem;
|
|
287
|
-
}
|
|
288
293
|
}
|
|
289
294
|
}
|
|
@@ -11,11 +11,12 @@ import {
|
|
|
11
11
|
import { httpStatusCodes, methodColorMapping, paramsTableHeaders } from '../../constants/index'
|
|
12
12
|
import Tooltip from '../../components/Tooltip/Tooltip'
|
|
13
13
|
import { TransformedMethod } from '../../types/layout.type'
|
|
14
|
-
import styles from './MethodAccordion.module.scss'
|
|
15
14
|
import SimpleLabelValue from '../../components/SimpleLabelValue'
|
|
16
15
|
import { capitalize, handleStatusColor } from '../../helpers/methodAccordion.helper'
|
|
17
16
|
import ParamterTable from '../table/table'
|
|
18
17
|
import CommonDialog from '../../components/dialog'
|
|
18
|
+
import JsonInput from '../../components/JsonInput/JsonInput'
|
|
19
|
+
import styles from './MethodAccordion.module.scss'
|
|
19
20
|
|
|
20
21
|
const httpStatusCodeOptions = httpStatusCodes.map((code) => ({
|
|
21
22
|
label: (
|
|
@@ -35,13 +36,11 @@ const MethodsAccordion = ({
|
|
|
35
36
|
path,
|
|
36
37
|
setFieldValue,
|
|
37
38
|
readOnly,
|
|
38
|
-
handleSave,
|
|
39
39
|
}: {
|
|
40
40
|
method: TransformedMethod
|
|
41
41
|
path: string
|
|
42
42
|
setFieldValue: (key: string, value: string) => void
|
|
43
43
|
readOnly?: boolean
|
|
44
|
-
handleSave: (data: any) => unknown
|
|
45
44
|
}) => {
|
|
46
45
|
const [isExpanded, setIsExpanded] = useState({
|
|
47
46
|
request: false,
|
|
@@ -157,10 +156,7 @@ const MethodsAccordion = ({
|
|
|
157
156
|
)}
|
|
158
157
|
</Tooltip>
|
|
159
158
|
|
|
160
|
-
{
|
|
161
|
-
!readOnly&&
|
|
162
|
-
<div className={styles.paramDescContainer_separator}></div>
|
|
163
|
-
}
|
|
159
|
+
{!readOnly && <div className={styles.paramDescContainer_separator}></div>}
|
|
164
160
|
|
|
165
161
|
{!readOnly && (
|
|
166
162
|
<Button
|
|
@@ -299,19 +295,15 @@ const MethodsAccordion = ({
|
|
|
299
295
|
</span>
|
|
300
296
|
}
|
|
301
297
|
children={
|
|
302
|
-
<
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return JSON.stringify(requestBody)
|
|
309
|
-
} else return requestBody
|
|
310
|
-
})()}
|
|
311
|
-
onChange={(value) => {
|
|
298
|
+
<JsonInput
|
|
299
|
+
className={'jsonField'}
|
|
300
|
+
placeholder="Enter your request body as a JSON object...."
|
|
301
|
+
fieldIsDisabled={readOnly}
|
|
302
|
+
value={method?.requestBody?.at(0)?.content?.schema?.properties || '{}'}
|
|
303
|
+
onChange={(value: string) => {
|
|
312
304
|
setFieldValue('requestBody[0].content.schema.properties', value)
|
|
313
305
|
}}
|
|
314
|
-
|
|
306
|
+
onValidation={() => null}
|
|
315
307
|
/>
|
|
316
308
|
}
|
|
317
309
|
/>
|
|
@@ -356,40 +348,18 @@ const MethodsAccordion = ({
|
|
|
356
348
|
</span>
|
|
357
349
|
}
|
|
358
350
|
children={
|
|
359
|
-
<
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
: method.responses?.at(0)?.content.schema.properties
|
|
365
|
-
}
|
|
351
|
+
<JsonInput
|
|
352
|
+
className={'jsonField'}
|
|
353
|
+
placeholder="Enter your response as a JSON object..."
|
|
354
|
+
fieldIsDisabled={readOnly}
|
|
355
|
+
value={method.responses?.at(0)?.content?.schema?.properties || '{}'}
|
|
366
356
|
onChange={(value) => {
|
|
367
|
-
|
|
368
|
-
try {
|
|
369
|
-
parsedValue = JSON.parse(value)
|
|
370
|
-
} catch (err) {
|
|
371
|
-
console.log(err)
|
|
372
|
-
}
|
|
373
|
-
setFieldValue('responses[0].content.schema.properties', parsedValue as any)
|
|
357
|
+
setFieldValue('responses[0].content.schema.properties', value)
|
|
374
358
|
}}
|
|
375
|
-
|
|
359
|
+
onValidation={() => null}
|
|
376
360
|
/>
|
|
377
361
|
}
|
|
378
362
|
/>
|
|
379
|
-
{!readOnly && (
|
|
380
|
-
<Button
|
|
381
|
-
className={styles.methodForm_submitBtn}
|
|
382
|
-
size="small"
|
|
383
|
-
fullWidth={false}
|
|
384
|
-
type="submit"
|
|
385
|
-
variant="link"
|
|
386
|
-
color="success"
|
|
387
|
-
onClick={handleSave}
|
|
388
|
-
startIcon={<SVGLoader src={CheckMarkSquare} width="1.5rem" height="1.5rem" />}
|
|
389
|
-
>
|
|
390
|
-
Save
|
|
391
|
-
</Button>
|
|
392
|
-
)}
|
|
393
363
|
</div>
|
|
394
364
|
}
|
|
395
365
|
/>
|
package/src/constants/index.ts
CHANGED
|
@@ -2,34 +2,42 @@ export const methodColorMapping = {
|
|
|
2
2
|
get: {
|
|
3
3
|
label: 'Get',
|
|
4
4
|
color: '#3A6CD1',
|
|
5
|
+
order: 1,
|
|
5
6
|
},
|
|
6
7
|
post: {
|
|
7
8
|
label: 'Post',
|
|
8
9
|
color: '#3AAA35',
|
|
10
|
+
order: 2,
|
|
9
11
|
},
|
|
10
12
|
put: {
|
|
11
13
|
label: 'Put',
|
|
12
14
|
color: '#FAAD14',
|
|
15
|
+
order: 3,
|
|
13
16
|
},
|
|
14
17
|
delete: {
|
|
15
18
|
label: 'Delete',
|
|
16
19
|
color: '#DA3F3F',
|
|
20
|
+
order: 4,
|
|
17
21
|
},
|
|
18
|
-
|
|
22
|
+
patch: {
|
|
19
23
|
label: 'Patch',
|
|
20
|
-
color: '#
|
|
24
|
+
color: '#58E2C2',
|
|
25
|
+
order: 5,
|
|
21
26
|
},
|
|
22
|
-
|
|
27
|
+
options: {
|
|
23
28
|
label: 'Options',
|
|
24
|
-
color: '#
|
|
29
|
+
color: '#495D97',
|
|
30
|
+
order: 6,
|
|
25
31
|
},
|
|
26
|
-
|
|
32
|
+
trace: {
|
|
27
33
|
label: 'Trace',
|
|
28
|
-
color: '#
|
|
34
|
+
color: '#FFA28F',
|
|
35
|
+
order: 7,
|
|
29
36
|
},
|
|
30
|
-
|
|
37
|
+
head: {
|
|
31
38
|
label: 'Head',
|
|
32
|
-
color: '#
|
|
39
|
+
color: '#9461C9',
|
|
40
|
+
order: 8,
|
|
33
41
|
},
|
|
34
42
|
}
|
|
35
43
|
|