@digi-frontend/dgate-api-documentation 1.0.95 → 1.0.97
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/src/helpers/layout.helper.js +1 -1
- package/dist/src/helpers/layout.helper.js.map +1 -1
- package/dist/src/layout/docsComponents/DocsAside/DocsAside.js +1 -1
- package/dist/src/layout/docsComponents/DocsAside/DocsAside.js.map +1 -1
- package/dist/src/layout/docsComponents/DocsContent/EndpointPage/index.js +1 -1
- package/dist/src/layout/docsComponents/DocsContent/EndpointPage/index.js.map +1 -1
- package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js +1 -1
- package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js.map +1 -1
- package/dist/styles.css +490 -483
- package/package.json +1 -1
- package/src/helpers/layout.helper.ts +17 -1
- package/src/layout/docsComponents/DocsAside/DocsAside.tsx +34 -15
- package/src/layout/docsComponents/DocsContent/EndpointPage/index.tsx +71 -54
- package/src/layout/docsComponents/DocsHeader/DocsHeader.module.scss +25 -11
- package/src/layout/docsComponents/DocsHeader/DocsHeader.tsx +2 -1
- package/variables.txt +1 -1
package/package.json
CHANGED
|
@@ -190,11 +190,27 @@ export const transformPathsArrayToOrigin = (paths: TransformedPathsArray): OpenA
|
|
|
190
190
|
return param
|
|
191
191
|
})
|
|
192
192
|
}
|
|
193
|
+
|
|
194
|
+
// Get the original responses from the rest object
|
|
195
|
+
const originalResponses = rest.responses || {}
|
|
196
|
+
|
|
193
197
|
methodAcc[type] = {
|
|
194
198
|
...copiedRest,
|
|
195
199
|
tags,
|
|
196
200
|
summary,
|
|
197
201
|
responses: responses.reduce((respAcc, { code, content, headers }) => {
|
|
202
|
+
// Skip if:
|
|
203
|
+
// 1. This is a new code (not in original) AND
|
|
204
|
+
// 2. Both headers and content are empty
|
|
205
|
+
const isNewCode = !originalResponses[code]
|
|
206
|
+
const hasHeaders = Object.keys(headers || {}).length > 0
|
|
207
|
+
const hasContent =
|
|
208
|
+
Object.keys(validateBodyForResponse(content || {}, type) || {}).length > 0
|
|
209
|
+
|
|
210
|
+
if (isNewCode && !hasHeaders && !hasContent) {
|
|
211
|
+
return respAcc
|
|
212
|
+
}
|
|
213
|
+
|
|
198
214
|
const formattedHeaders: Record<string, any> = {}
|
|
199
215
|
if (headers) {
|
|
200
216
|
for (const [key, value] of Object.entries(headers)) {
|
|
@@ -216,7 +232,7 @@ export const transformPathsArrayToOrigin = (paths: TransformedPathsArray): OpenA
|
|
|
216
232
|
},
|
|
217
233
|
},
|
|
218
234
|
}
|
|
219
|
-
: {},
|
|
235
|
+
: originalResponses[code]?.content || {},
|
|
220
236
|
headers: formattedHeaders,
|
|
221
237
|
}
|
|
222
238
|
return respAcc
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
2
|
import { EndpointData } from 'src/layout/docsLayout'
|
|
3
3
|
import Codebox from '../Codebox/Codebox'
|
|
4
4
|
import { Option, SelectGroup } from 'digitinary-ui'
|
|
@@ -6,24 +6,43 @@ import { httpStatusCodes } from '../../../constants/index'
|
|
|
6
6
|
import { handleStatusColor } from '../../../helpers/methodAccordion.helper'
|
|
7
7
|
import styles from './style.module.scss'
|
|
8
8
|
|
|
9
|
-
const httpStatusCodeOptions: Option[] = httpStatusCodes.map((code) => ({
|
|
10
|
-
label: (
|
|
11
|
-
<div className={styles.statusCodeOptionContainer}>
|
|
12
|
-
<div
|
|
13
|
-
className={styles.statusCodeOptionCircle}
|
|
14
|
-
style={{ backgroundColor: handleStatusColor(code) }}
|
|
15
|
-
></div>
|
|
16
|
-
<span>{code}</span>
|
|
17
|
-
</div>
|
|
18
|
-
),
|
|
19
|
-
value: String(code),
|
|
20
|
-
}))
|
|
21
|
-
|
|
22
9
|
const DocsAside = ({ data }: { data: EndpointData }) => {
|
|
10
|
+
// Filter status codes to only include those with non-empty properties
|
|
11
|
+
const filteredStatusCodes = Object.keys(data?.responses || {}).filter((code) => {
|
|
12
|
+
const response = data.responses[code]
|
|
13
|
+
const contentType = Object.keys(response?.content || {})[0]
|
|
14
|
+
return response?.content?.[contentType]?.schema?.properties
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
// Create options for the select dropdown
|
|
18
|
+
const httpStatusCodeOptions = filteredStatusCodes.map((code) => ({
|
|
19
|
+
label: (
|
|
20
|
+
<div className={styles.statusCodeOptionContainer}>
|
|
21
|
+
<div
|
|
22
|
+
className={styles.statusCodeOptionCircle}
|
|
23
|
+
style={{ backgroundColor: handleStatusColor(code) }}
|
|
24
|
+
></div>
|
|
25
|
+
<span>{code}</span>
|
|
26
|
+
</div>
|
|
27
|
+
),
|
|
28
|
+
value: String(code),
|
|
29
|
+
}))
|
|
30
|
+
|
|
31
|
+
// Function to get default option
|
|
32
|
+
const getDefaultOption = () => {
|
|
33
|
+
const has200 = filteredStatusCodes.includes('200')
|
|
34
|
+
return has200
|
|
35
|
+
? httpStatusCodeOptions.find((opt) => opt.value === '200')
|
|
36
|
+
: httpStatusCodeOptions[0] || null
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
setSelectedResStatusCode(getDefaultOption())
|
|
41
|
+
}, [data])
|
|
23
42
|
const [selectedResStatusCode, setSelectedResStatusCode] = useState(httpStatusCodeOptions[4])
|
|
24
43
|
const currentResponse = Object.entries(data.responses)
|
|
25
44
|
.map(([code, data]) => ({ code, data }))
|
|
26
|
-
.find((res) => res.code === selectedResStatusCode
|
|
45
|
+
.find((res) => res.code === selectedResStatusCode?.value)
|
|
27
46
|
|
|
28
47
|
const stringifyRequestBody = () => {
|
|
29
48
|
if (data?.requestBody?.content) {
|
|
@@ -44,11 +44,20 @@ export const EndpointPage = ({
|
|
|
44
44
|
return `${url}${fullPath}`
|
|
45
45
|
}, [data])
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// Filter status codes to only include those
|
|
48
|
+
const filteredStatusCodes = Object.keys(data?.responses || {}).filter((code) => {
|
|
49
|
+
const response = data.responses[code]
|
|
50
|
+
return (
|
|
51
|
+
response?.content?.['application/json']?.schema?.properties
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Create options for the select dropdown
|
|
56
|
+
const httpStatusCodeOptions = filteredStatusCodes.map((code) => ({
|
|
48
57
|
label: (
|
|
49
|
-
<div className=
|
|
58
|
+
<div className="statusCodeOptionContainer">
|
|
50
59
|
<div
|
|
51
|
-
className=
|
|
60
|
+
className="statusCodeOptionCircle"
|
|
52
61
|
style={{ backgroundColor: handleStatusColor(code) }}
|
|
53
62
|
></div>
|
|
54
63
|
<span>{code}</span>
|
|
@@ -57,13 +66,25 @@ export const EndpointPage = ({
|
|
|
57
66
|
value: code,
|
|
58
67
|
}))
|
|
59
68
|
|
|
69
|
+
// Function to get default option
|
|
70
|
+
const getDefaultOption = () => {
|
|
71
|
+
const has200 = filteredStatusCodes.includes('200')
|
|
72
|
+
return has200
|
|
73
|
+
? httpStatusCodeOptions.find((opt) => opt.value === '200')
|
|
74
|
+
: httpStatusCodeOptions[0] || null
|
|
75
|
+
}
|
|
76
|
+
|
|
60
77
|
const [expanded, setExpanded] = useState(null)
|
|
61
|
-
const [selectedResStatusCode, setSelectedResStatusCode] = useState(
|
|
78
|
+
const [selectedResStatusCode, setSelectedResStatusCode] = useState(getDefaultOption())
|
|
62
79
|
const [headersList, setHeadersList] = useState({})
|
|
63
80
|
const requestTableData = (data?.parameters || []).filter(
|
|
64
81
|
(param) => param.in?.toLowerCase() === activeTab.toLowerCase()
|
|
65
82
|
)
|
|
66
83
|
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
setSelectedResStatusCode(getDefaultOption())
|
|
86
|
+
}, [data])
|
|
87
|
+
|
|
67
88
|
useEffect(() => {
|
|
68
89
|
if (selectedResStatusCode && selectedResStatusCode.value) {
|
|
69
90
|
const headerObj = data?.responses[selectedResStatusCode.value]
|
|
@@ -71,8 +92,6 @@ export const EndpointPage = ({
|
|
|
71
92
|
}
|
|
72
93
|
}, [selectedResStatusCode, data?.responses])
|
|
73
94
|
|
|
74
|
-
// ? TODO: 'body' should be returned after discussing with PO
|
|
75
|
-
|
|
76
95
|
return (
|
|
77
96
|
<div className="api-details-expanded">
|
|
78
97
|
<div className="test-button">
|
|
@@ -166,54 +185,52 @@ export const EndpointPage = ({
|
|
|
166
185
|
))}
|
|
167
186
|
</div>
|
|
168
187
|
|
|
169
|
-
|
|
170
|
-
<
|
|
171
|
-
<
|
|
172
|
-
<
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
<
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
</div>
|
|
216
|
-
}
|
|
188
|
+
<div className="table-wrapper">
|
|
189
|
+
<table className="param-table">
|
|
190
|
+
<thead>
|
|
191
|
+
<tr>
|
|
192
|
+
<th className="head-table-label">Parameter Name</th>
|
|
193
|
+
<th className="head-table-label">Required</th>
|
|
194
|
+
<th className="head-table-label">Type</th>
|
|
195
|
+
<th className="head-table-label">Enum</th>
|
|
196
|
+
<th className="head-table-label">Description</th>
|
|
197
|
+
</tr>
|
|
198
|
+
</thead>
|
|
199
|
+
<tbody>
|
|
200
|
+
{data.parameters
|
|
201
|
+
?.filter((p) => p.in?.toLowerCase() === activeTab.toLowerCase())
|
|
202
|
+
.map((row, index) => (
|
|
203
|
+
<tr key={index}>
|
|
204
|
+
<td>{row.name}</td>
|
|
205
|
+
<td>{row.required ? 'True' : 'False'}</td>
|
|
206
|
+
<td style={{ textTransform: 'capitalize' }}>
|
|
207
|
+
<span>{row?.schema?.type || '-'}</span>
|
|
208
|
+
{row?.schema?.type === 'array' && row?.schema?.items?.type && (
|
|
209
|
+
<span style={{ color: '#616874', fontSize: '0.75rem' }}>
|
|
210
|
+
_{capitalizeFirstLetter(row.schema?.items?.type)}
|
|
211
|
+
</span>
|
|
212
|
+
)}
|
|
213
|
+
</td>
|
|
214
|
+
<td>{Array.isArray(row.schema?.enum) ? row.schema.enum.join(' / ') : '-'}</td>
|
|
215
|
+
<td className="desc-cell">
|
|
216
|
+
<div className={`desc-text ${expanded === index ? 'expanded' : ''}`}>
|
|
217
|
+
{row.description || 'No description'}
|
|
218
|
+
</div>
|
|
219
|
+
<button
|
|
220
|
+
className="desc-toggle"
|
|
221
|
+
onClick={() => setExpanded(expanded === index ? null : index)}
|
|
222
|
+
>
|
|
223
|
+
<SVGLoader
|
|
224
|
+
src={DownArrowIcon}
|
|
225
|
+
className={expanded === index ? 'rotated' : ''}
|
|
226
|
+
/>
|
|
227
|
+
</button>
|
|
228
|
+
</td>
|
|
229
|
+
</tr>
|
|
230
|
+
))}
|
|
231
|
+
</tbody>
|
|
232
|
+
</table>
|
|
233
|
+
</div>
|
|
217
234
|
</div>
|
|
218
235
|
|
|
219
236
|
<div className="response-section">
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
line-height: 1.25rem;
|
|
29
29
|
|
|
30
30
|
.btnContentWrapper {
|
|
31
|
-
.btnContent{
|
|
31
|
+
.btnContent {
|
|
32
32
|
font-size: 0.918rem !important;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
height: 2.25rem;
|
|
82
82
|
|
|
83
83
|
.btnContentWrapper {
|
|
84
|
-
.btnContent{
|
|
84
|
+
.btnContent {
|
|
85
85
|
font-size: 0.918rem !important;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -96,15 +96,6 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
.tippy_box_color {
|
|
100
|
-
margin-left: 2rem;
|
|
101
|
-
background-color: #000 !important;
|
|
102
|
-
border: none;
|
|
103
|
-
height: 1.875rem;
|
|
104
|
-
border-radius: 0.75rem;
|
|
105
|
-
margin-top: -0.5rem;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
99
|
:global(.tippy-arrow) {
|
|
109
100
|
transform: translateX(12px) !important;
|
|
110
101
|
}
|
|
@@ -280,4 +271,27 @@
|
|
|
280
271
|
backdrop-filter: blur(0.5rem);
|
|
281
272
|
background-color: rgba(0, 0, 0, 0.281) !important;
|
|
282
273
|
}
|
|
274
|
+
|
|
275
|
+
// Tooltip overrides
|
|
276
|
+
.guide-tooltip.guide-tooltip.guide-tooltip.guide-tooltip {
|
|
277
|
+
background-color: #000;
|
|
278
|
+
border: none;
|
|
279
|
+
border-radius: 0.75rem;
|
|
280
|
+
|
|
281
|
+
&.tippy-box {
|
|
282
|
+
.tippy-content.tippy-content {
|
|
283
|
+
border-radius: 0.75rem;
|
|
284
|
+
color: #fff;
|
|
285
|
+
background-color: #000;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.tippy-arrow.tippy-arrow.tippy-arrow.tippy-arrow {
|
|
290
|
+
color: #000;
|
|
291
|
+
|
|
292
|
+
&::before {
|
|
293
|
+
color: #000;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
283
297
|
}
|
|
@@ -96,8 +96,9 @@ const DocsHeader = ({
|
|
|
96
96
|
<div className={styles.nav_buttons}>
|
|
97
97
|
<Tooltip
|
|
98
98
|
placement="bottom"
|
|
99
|
+
offset={[10, 5]}
|
|
99
100
|
delay={[0, 0]}
|
|
100
|
-
className=
|
|
101
|
+
className="guide-tooltip"
|
|
101
102
|
content={<div>Coming Soon</div>}
|
|
102
103
|
>
|
|
103
104
|
<Button variant="outlined" size="small" className="guide-btn" disabled={true}>
|
package/variables.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export APP_VERSION=1.0.
|
|
1
|
+
export APP_VERSION=1.0.96
|