@digi-frontend/dgate-api-documentation 1.0.31 → 1.0.32

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.
Files changed (104) hide show
  1. package/.editorconfig +12 -12
  2. package/.prettierignore +7 -7
  3. package/.prettierrc +15 -15
  4. package/dist/{2e10bbdb265df50e.svg → 43595976d1fdccbf.svg} +4 -4
  5. package/dist/{8789eb84283ea95b.svg → 56dc416b683db280.svg} +5 -5
  6. package/dist/{bb8b87cace25e052.svg → 64efc2716808c4a4.svg} +3 -3
  7. package/dist/{d32ce84bbd78babd.svg → 72db3b05a96dd600.svg} +3 -3
  8. package/dist/{d501922060662842.svg → 844eba3f2e42a9eb.svg} +3 -3
  9. package/dist/_virtual/index3.js +1 -1
  10. package/dist/_virtual/index4.js +1 -1
  11. package/dist/_virtual/index5.js +1 -1
  12. package/dist/_virtual/index6.js +1 -1
  13. package/dist/{070dc6ecd197bc80.svg → a7568b270e175038.svg} +8 -8
  14. package/dist/{9bdff13f8d8fa48a.svg → af16a554be8c4d69.svg} +3 -3
  15. package/dist/{7f54eeb0bb2d1150.svg → b82c7612e73342f3.svg} +3 -3
  16. package/dist/node_modules/toposort/index.js +1 -1
  17. package/dist/node_modules/yup/index.esm.js +1 -1
  18. package/dist/src/assets/icons/AddRow.svg.js +1 -1
  19. package/dist/src/assets/icons/AddRow.svg.js.map +1 -1
  20. package/dist/src/assets/icons/CheckMarkSquare.svg.js +1 -1
  21. package/dist/src/assets/icons/CheckMarkSquare.svg.js.map +1 -1
  22. package/dist/src/assets/icons/CloseIcon.svg.js +1 -1
  23. package/dist/src/assets/icons/CloseIcon.svg.js.map +1 -1
  24. package/dist/src/assets/icons/DeleteIcon.svg.js +1 -1
  25. package/dist/src/assets/icons/DeleteIcon.svg.js.map +1 -1
  26. package/dist/src/assets/icons/DownArrow.svg.js +1 -1
  27. package/dist/src/assets/icons/DownArrow.svg.js.map +1 -1
  28. package/dist/src/assets/icons/EditIcon.svg.js +1 -1
  29. package/dist/src/assets/icons/EditIcon.svg.js.map +1 -1
  30. package/dist/src/assets/icons/UpArrow.svg.js +1 -1
  31. package/dist/src/assets/icons/UpArrow.svg.js.map +1 -1
  32. package/dist/src/assets/icons/deleteOutlinedIcon.svg.js +1 -1
  33. package/dist/src/assets/icons/deleteOutlinedIcon.svg.js.map +1 -1
  34. package/dist/src/components/Chips/Chips.js.map +1 -1
  35. package/dist/src/components/InfoForm/InfoForm.js +1 -1
  36. package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
  37. package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
  38. package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
  39. package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
  40. package/dist/src/components/SVGLoader/SVGLoader.js.map +1 -1
  41. package/dist/src/components/SectionHead/SectionHead.js.map +1 -1
  42. package/dist/src/components/SimpleLabelValue/SimpleLabelValue.js.map +1 -1
  43. package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
  44. package/dist/src/components/dialog/index.js.map +1 -1
  45. package/dist/src/components/table/table.js.map +1 -1
  46. package/dist/src/components/table/tags-table.js +1 -1
  47. package/dist/src/components/table/tags-table.js.map +1 -1
  48. package/dist/src/constants/index.js.map +1 -1
  49. package/dist/src/constants/regex.js +1 -1
  50. package/dist/src/constants/regex.js.map +1 -1
  51. package/dist/src/helpers/layout.helper.js.map +1 -1
  52. package/dist/src/helpers/methodAccordion.helper.js.map +1 -1
  53. package/dist/src/layout/layout.js.map +1 -1
  54. package/dist/src/validator/form.scheme.js.map +1 -1
  55. package/dist/styles.css +335 -335
  56. package/package.json +43 -43
  57. package/rollup.config.js +35 -35
  58. package/src/assets/icons/AddRow.svg +3 -3
  59. package/src/assets/icons/CheckMarkSquare.svg +5 -5
  60. package/src/assets/icons/CloseIcon.svg +4 -4
  61. package/src/assets/icons/DeleteIcon.svg +3 -3
  62. package/src/assets/icons/DownArrow.svg +3 -3
  63. package/src/assets/icons/EditIcon.svg +3 -3
  64. package/src/assets/icons/UpArrow.svg +3 -3
  65. package/src/assets/icons/deleteOutlinedIcon.svg +8 -8
  66. package/src/assets/icons/index.ts +8 -8
  67. package/src/components/Chips/Chips.tsx +87 -87
  68. package/src/components/Chips/style.scss +147 -147
  69. package/src/components/InfoForm/InfoForm.module.scss +165 -165
  70. package/src/components/InfoForm/InfoForm.tsx +424 -426
  71. package/src/components/JsonInput/JsonInput.tsx +149 -149
  72. package/src/components/JsonInput/style.module.scss +133 -133
  73. package/src/components/LivePreview/LivePreview.module.scss +24 -24
  74. package/src/components/LivePreview/LivePreview.tsx +184 -184
  75. package/src/components/MethodAccordion/MethodAccordion.module.scss +338 -338
  76. package/src/components/MethodAccordion/MethodAccordion.tsx +515 -515
  77. package/src/components/SVGLoader/SVGLoader.tsx +94 -94
  78. package/src/components/SectionHead/SectionHead.scss +29 -29
  79. package/src/components/SectionHead/SectionHead.tsx +22 -22
  80. package/src/components/SimpleLabelValue/SimpleLabelValue.tsx +31 -31
  81. package/src/components/SimpleLabelValue/index.ts +1 -1
  82. package/src/components/SimpleLabelValue/style.scss +30 -30
  83. package/src/components/Tooltip/Tooltip.scss +133 -133
  84. package/src/components/Tooltip/Tooltip.tsx +85 -85
  85. package/src/components/_global.scss +337 -337
  86. package/src/components/dialog/dialog.ts +54 -54
  87. package/src/components/dialog/index.tsx +85 -85
  88. package/src/components/dialog/style.scss +104 -104
  89. package/src/components/table/style.scss +190 -190
  90. package/src/components/table/table.tsx +327 -327
  91. package/src/components/table/tags-table.tsx +348 -348
  92. package/src/constants/index.ts +93 -93
  93. package/src/constants/regex.ts +7 -7
  94. package/src/global.d.ts +13 -13
  95. package/src/helpers/layout.helper.ts +162 -162
  96. package/src/helpers/methodAccordion.helper.ts +19 -19
  97. package/src/index.ts +1 -1
  98. package/src/layout/layout.module.css +61 -61
  99. package/src/layout/layout.tsx +150 -150
  100. package/src/types/layout.type.ts +30 -30
  101. package/src/types/openApi.ts +108 -108
  102. package/src/types/transformedOpenApi.ts +52 -52
  103. package/src/validator/form.scheme.ts +70 -70
  104. package/tsconfig.json +33 -33
@@ -1,93 +1,93 @@
1
- export const methodColorMapping = {
2
- get: {
3
- label: 'Get',
4
- color: '#3A6CD1',
5
- order: 1,
6
- },
7
- post: {
8
- label: 'Post',
9
- color: '#3AAA35',
10
- order: 2,
11
- },
12
- put: {
13
- label: 'Put',
14
- color: '#FAAD14',
15
- order: 3,
16
- },
17
- delete: {
18
- label: 'Delete',
19
- color: '#DA3F3F',
20
- order: 4,
21
- },
22
- patch: {
23
- label: 'Patch',
24
- color: '#58E2C2',
25
- order: 5,
26
- },
27
- options: {
28
- label: 'Options',
29
- color: '#495D97',
30
- order: 6,
31
- },
32
- trace: {
33
- label: 'Trace',
34
- color: '#FFA28F',
35
- order: 7,
36
- },
37
- head: {
38
- label: 'Head',
39
- color: '#9461C9',
40
- order: 8,
41
- },
42
- }
43
-
44
- export const tagsTableHeaders = [
45
- {
46
- id: 'tagName',
47
- label: 'Tag Name',
48
- sortable: false,
49
- classes: 'requiredParam',
50
- },
51
- {
52
- id: 'description',
53
- label: 'Description',
54
- sortable: false,
55
- },
56
- {
57
- id: 'externalDocs',
58
- label: 'External Docs',
59
- sortable: false,
60
- },
61
- ]
62
-
63
- export const paramsTableHeaders = [
64
- {
65
- id: 'paramName',
66
- label: 'Parameter Name',
67
- sortable: false,
68
- required: true,
69
- classes: 'requiredParam',
70
- },
71
- { id: 'paramType', label: 'In', sortable: false, classes: 'requiredParam' },
72
- { id: 'schemaType', label: 'Schema-Type', sortable: false, classes: 'requiredParam' },
73
- { id: 'required', label: 'Required', sortable: false, classes: 'requiredParam' },
74
- { id: 'description', label: 'Description', sortable: false },
75
- ]
76
-
77
- export const httpStatusCodes = [
78
- // 1xx: Informational responses
79
- 100, 101, 102, 103,
80
-
81
- // 2xx: Success
82
- 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
83
-
84
- // 3xx: Redirection
85
- 300, 301, 302, 303, 304, 305, 306, 307, 308,
86
-
87
- // 4xx: Client errors
88
- 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418,
89
- 421, 422, 423, 424, 425, 426, 428, 429, 431, 451,
90
-
91
- // 5xx: Server errors
92
- 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511,
93
- ]
1
+ export const methodColorMapping = {
2
+ get: {
3
+ label: 'Get',
4
+ color: '#3A6CD1',
5
+ order: 1,
6
+ },
7
+ post: {
8
+ label: 'Post',
9
+ color: '#3AAA35',
10
+ order: 2,
11
+ },
12
+ put: {
13
+ label: 'Put',
14
+ color: '#FAAD14',
15
+ order: 3,
16
+ },
17
+ delete: {
18
+ label: 'Delete',
19
+ color: '#DA3F3F',
20
+ order: 4,
21
+ },
22
+ patch: {
23
+ label: 'Patch',
24
+ color: '#58E2C2',
25
+ order: 5,
26
+ },
27
+ options: {
28
+ label: 'Options',
29
+ color: '#495D97',
30
+ order: 6,
31
+ },
32
+ trace: {
33
+ label: 'Trace',
34
+ color: '#FFA28F',
35
+ order: 7,
36
+ },
37
+ head: {
38
+ label: 'Head',
39
+ color: '#9461C9',
40
+ order: 8,
41
+ },
42
+ }
43
+
44
+ export const tagsTableHeaders = [
45
+ {
46
+ id: 'tagName',
47
+ label: 'Tag Name',
48
+ sortable: false,
49
+ classes: 'requiredParam',
50
+ },
51
+ {
52
+ id: 'description',
53
+ label: 'Description',
54
+ sortable: false,
55
+ },
56
+ {
57
+ id: 'externalDocs',
58
+ label: 'External Docs',
59
+ sortable: false,
60
+ },
61
+ ]
62
+
63
+ export const paramsTableHeaders = [
64
+ {
65
+ id: 'paramName',
66
+ label: 'Parameter Name',
67
+ sortable: false,
68
+ required: true,
69
+ classes: 'requiredParam',
70
+ },
71
+ { id: 'paramType', label: 'In', sortable: false, classes: 'requiredParam' },
72
+ { id: 'schemaType', label: 'Schema-Type', sortable: false, classes: 'requiredParam' },
73
+ { id: 'required', label: 'Required', sortable: false, classes: 'requiredParam' },
74
+ { id: 'description', label: 'Description', sortable: false },
75
+ ]
76
+
77
+ export const httpStatusCodes = [
78
+ // 1xx: Informational responses
79
+ 100, 101, 102, 103,
80
+
81
+ // 2xx: Success
82
+ 200, 201, 202, 203, 204, 205, 206, 207, 208, 226,
83
+
84
+ // 3xx: Redirection
85
+ 300, 301, 302, 303, 304, 305, 306, 307, 308,
86
+
87
+ // 4xx: Client errors
88
+ 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418,
89
+ 421, 422, 423, 424, 425, 426, 428, 429, 431, 451,
90
+
91
+ // 5xx: Server errors
92
+ 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511,
93
+ ]
@@ -1,7 +1,7 @@
1
- const regex = {
2
- basic: /[^a-zA-Z0-9-_ ]/, // not (alphanumeric + underscore + dash + space)
3
- restrictNone: /^$/, // restrict nothing
4
- ASCII: /^[\x00-\x7F]+$/,
5
- urlRegex: /^(https?:\/\/)?(www\.)?([a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+)(\/[^\s]*)?$/,
6
- }
7
- export default regex
1
+ const regex = {
2
+ basic: /[^a-zA-Z0-9-_ ]/, // not (alphanumeric + underscore + dash + space)
3
+ restrictNone: /^$/, // restrict nothing
4
+ ASCII: /^[\x00-\x7F]+$/,
5
+ urlRegex: /^(https?:\/\/|www\.)[a-zA-Z0-9-]+(\.[a-zA-Z]{2,})+(\/[^\s]*)?$/,
6
+ }
7
+ export default regex
package/src/global.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- declare module '*.module.css' {
2
- const classes: { [key: string]: string }
3
- export default classes
4
- }
5
- declare module '*.module.scss' {
6
- const classes: { [key: string]: string }
7
- export default classes
8
- }
9
-
10
- declare module '*.svg' {
11
- const src: string
12
- export default src
13
- }
1
+ declare module '*.module.css' {
2
+ const classes: { [key: string]: string }
3
+ export default classes
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { [key: string]: string }
7
+ export default classes
8
+ }
9
+
10
+ declare module '*.svg' {
11
+ const src: string
12
+ export default src
13
+ }
@@ -1,162 +1,162 @@
1
- import { TransformedPathsArray } from '@entities/layout.type'
2
- import { OpenAPIFile, SecurityScheme } from '@entities/openApi'
3
- import { TransformedOpenApi } from '@entities/transformedOpenApi'
4
-
5
- export const transformOpenApiObject = (openApiJson: OpenAPIFile): TransformedOpenApi => {
6
- if (openApiJson.components && openApiJson.components.securitySchemes) {
7
- const authKey = Object.keys(openApiJson.components.securitySchemes)?.at(0)
8
- if (authKey) {
9
- openApiJson.components.securitySchemes[authKey].type =
10
- openApiJson?.components?.securitySchemes?.[
11
- authKey
12
- ]?.type?.toUpperCase() as SecurityScheme['type']
13
- }
14
- } else {
15
- openApiJson.components = {
16
- securitySchemes: {
17
- Public: {
18
- type: 'http',
19
- scheme: 'public',
20
- },
21
- },
22
- }
23
- }
24
-
25
- if (!openApiJson.tags) {
26
- openApiJson.tags = []
27
- }
28
-
29
- return {
30
- ...openApiJson,
31
- paths: transformPathsToArray(openApiJson.paths),
32
- } as TransformedOpenApi
33
- }
34
-
35
- export const transformOpenApiObjectToOrigin = (values: TransformedOpenApi): OpenAPIFile => {
36
- const object = {
37
- ...values,
38
- paths: transformPathsArrayToOrigin(values.paths),
39
- }
40
- if (object.components && object.components.securitySchemes) {
41
- const authKey = Object.keys(object.components.securitySchemes)?.at(0)
42
- if (authKey) {
43
- if (object.components.securitySchemes[authKey].type.toLowerCase() == 'APIKEY'.toLowerCase()) {
44
- object.components.securitySchemes[authKey].in = object.components.securitySchemes[
45
- authKey
46
- ].in.toUpperCase() as SecurityScheme['in']
47
- }
48
- object.components.securitySchemes[authKey].type = object?.components?.securitySchemes?.[
49
- authKey
50
- ]?.type?.toUpperCase() as SecurityScheme['type']
51
- }
52
- }
53
- return object
54
- }
55
-
56
- export const transformPathsToArray = (paths: OpenAPIFile['paths']): TransformedPathsArray | any => {
57
- const transformedPaths = Object.entries(paths).map(([path, methods]) => ({
58
- path,
59
- methods: Object.entries(methods).map(([method, methodProps]) => {
60
- const obj: any = {
61
- ...methodProps,
62
- type: method,
63
- tags: methodProps.tags || [],
64
- responses: Object.entries(methodProps.responses).map(([code, codeProps]) => {
65
- const contentType = Object.keys(codeProps.content || {})[0]
66
- return {
67
- code,
68
- content: {
69
- contentType,
70
- schema: {
71
- ...codeProps.content?.[contentType]?.schema,
72
- properties: JSON.stringify(codeProps.content?.[contentType]?.schema?.properties),
73
- },
74
- },
75
- }
76
- }),
77
- }
78
- // Add parameters if it does not exist in the original JSON
79
- if (!methodProps?.parameters) {
80
- obj.parameters = []
81
- }
82
-
83
- if (method.toLowerCase() != 'get') {
84
- const contentType = Object.keys(methodProps?.requestBody?.content || {})[0]
85
- const reqSchema = methodProps?.requestBody?.content?.schema
86
- const requestBodyData = methodProps?.requestBody?.content?.schema?.properties
87
- ? {
88
- content: {
89
- contentType,
90
- schema: {
91
- ...reqSchema,
92
- properties: reqSchema?.properties ? JSON.stringify(reqSchema?.properties) : '{}',
93
- },
94
- },
95
- }
96
- : {
97
- content: {
98
- contentType: 'application/json',
99
- schema: {
100
- properties: '{}',
101
- type: 'object',
102
- },
103
- },
104
- }
105
-
106
- obj['requestBody'] = requestBodyData
107
- }
108
-
109
- return obj
110
- }),
111
- }))
112
-
113
- return transformedPaths
114
- }
115
-
116
- export const transformPathsArrayToOrigin = (paths: TransformedPathsArray): OpenAPIFile['paths'] => {
117
- return paths.reduce((acc, { path, methods }) => {
118
- acc[path] = methods.reduce((methodAcc, { type, tags, responses, requestBody, ...rest }) => {
119
- // Initialize the method object
120
- methodAcc[type] = {
121
- ...rest,
122
- tags,
123
- responses: responses.reduce((respAcc, { code, content }) => {
124
- respAcc[code] = {
125
- description: 'Success', // Assuming this is static from the original data
126
- content: content.contentType
127
- ? {
128
- [content.contentType]: {
129
- schema: {
130
- ...(content.schema as object),
131
- properties: JSON.parse((content?.schema as any)?.properties as string),
132
- },
133
- },
134
- }
135
- : {},
136
- }
137
- return respAcc
138
- }, {} as Record<string, any>),
139
- }
140
-
141
- const parsedRequestBodyProps =
142
- type !== 'get' ? JSON.parse(requestBody.content.schema.properties) : {}
143
- // Add requestBody for non-GET methods
144
- if (type !== 'get') {
145
- methodAcc[type].requestBody = {
146
- content: {
147
- [requestBody.content.contentType]: {
148
- schema: {
149
- ...requestBody.content.schema,
150
- properties: parsedRequestBodyProps,
151
- },
152
- },
153
- },
154
- }
155
- }
156
-
157
- return methodAcc
158
- }, {} as Record<string, any>)
159
-
160
- return acc
161
- }, {} as OpenAPIFile['paths'])
162
- }
1
+ import { TransformedPathsArray } from '@entities/layout.type'
2
+ import { OpenAPIFile, SecurityScheme } from '@entities/openApi'
3
+ import { TransformedOpenApi } from '@entities/transformedOpenApi'
4
+
5
+ export const transformOpenApiObject = (openApiJson: OpenAPIFile): TransformedOpenApi => {
6
+ if (openApiJson.components && openApiJson.components.securitySchemes) {
7
+ const authKey = Object.keys(openApiJson.components.securitySchemes)?.at(0)
8
+ if (authKey) {
9
+ openApiJson.components.securitySchemes[authKey].type =
10
+ openApiJson?.components?.securitySchemes?.[
11
+ authKey
12
+ ]?.type?.toUpperCase() as SecurityScheme['type']
13
+ }
14
+ } else {
15
+ openApiJson.components = {
16
+ securitySchemes: {
17
+ Public: {
18
+ type: 'http',
19
+ scheme: 'public',
20
+ },
21
+ },
22
+ }
23
+ }
24
+
25
+ if (!openApiJson.tags) {
26
+ openApiJson.tags = []
27
+ }
28
+
29
+ return {
30
+ ...openApiJson,
31
+ paths: transformPathsToArray(openApiJson.paths),
32
+ } as TransformedOpenApi
33
+ }
34
+
35
+ export const transformOpenApiObjectToOrigin = (values: TransformedOpenApi): OpenAPIFile => {
36
+ const object = {
37
+ ...values,
38
+ paths: transformPathsArrayToOrigin(values.paths),
39
+ }
40
+ if (object.components && object.components.securitySchemes) {
41
+ const authKey = Object.keys(object.components.securitySchemes)?.at(0)
42
+ if (authKey) {
43
+ if (object.components.securitySchemes[authKey].type.toLowerCase() == 'APIKEY'.toLowerCase()) {
44
+ object.components.securitySchemes[authKey].in = object.components.securitySchemes[
45
+ authKey
46
+ ].in.toUpperCase() as SecurityScheme['in']
47
+ }
48
+ object.components.securitySchemes[authKey].type = object?.components?.securitySchemes?.[
49
+ authKey
50
+ ]?.type?.toUpperCase() as SecurityScheme['type']
51
+ }
52
+ }
53
+ return object
54
+ }
55
+
56
+ export const transformPathsToArray = (paths: OpenAPIFile['paths']): TransformedPathsArray | any => {
57
+ const transformedPaths = Object.entries(paths).map(([path, methods]) => ({
58
+ path,
59
+ methods: Object.entries(methods).map(([method, methodProps]) => {
60
+ const obj: any = {
61
+ ...methodProps,
62
+ type: method,
63
+ tags: methodProps.tags || [],
64
+ responses: Object.entries(methodProps.responses).map(([code, codeProps]) => {
65
+ const contentType = Object.keys(codeProps.content || {})[0]
66
+ return {
67
+ code,
68
+ content: {
69
+ contentType,
70
+ schema: {
71
+ ...codeProps.content?.[contentType]?.schema,
72
+ properties: JSON.stringify(codeProps.content?.[contentType]?.schema?.properties),
73
+ },
74
+ },
75
+ }
76
+ }),
77
+ }
78
+ // Add parameters if it does not exist in the original JSON
79
+ if (!methodProps?.parameters) {
80
+ obj.parameters = []
81
+ }
82
+
83
+ if (method.toLowerCase() != 'get') {
84
+ const contentType = Object.keys(methodProps?.requestBody?.content || {})[0]
85
+ const reqSchema = methodProps?.requestBody?.content?.schema
86
+ const requestBodyData = methodProps?.requestBody?.content?.schema?.properties
87
+ ? {
88
+ content: {
89
+ contentType,
90
+ schema: {
91
+ ...reqSchema,
92
+ properties: reqSchema?.properties ? JSON.stringify(reqSchema?.properties) : '{}',
93
+ },
94
+ },
95
+ }
96
+ : {
97
+ content: {
98
+ contentType: 'application/json',
99
+ schema: {
100
+ properties: '{}',
101
+ type: 'object',
102
+ },
103
+ },
104
+ }
105
+
106
+ obj['requestBody'] = requestBodyData
107
+ }
108
+
109
+ return obj
110
+ }),
111
+ }))
112
+
113
+ return transformedPaths
114
+ }
115
+
116
+ export const transformPathsArrayToOrigin = (paths: TransformedPathsArray): OpenAPIFile['paths'] => {
117
+ return paths.reduce((acc, { path, methods }) => {
118
+ acc[path] = methods.reduce((methodAcc, { type, tags, responses, requestBody, ...rest }) => {
119
+ // Initialize the method object
120
+ methodAcc[type] = {
121
+ ...rest,
122
+ tags,
123
+ responses: responses.reduce((respAcc, { code, content }) => {
124
+ respAcc[code] = {
125
+ description: 'Success', // Assuming this is static from the original data
126
+ content: content.contentType
127
+ ? {
128
+ [content.contentType]: {
129
+ schema: {
130
+ ...(content.schema as object),
131
+ properties: JSON.parse((content?.schema as any)?.properties as string),
132
+ },
133
+ },
134
+ }
135
+ : {},
136
+ }
137
+ return respAcc
138
+ }, {} as Record<string, any>),
139
+ }
140
+
141
+ const parsedRequestBodyProps =
142
+ type !== 'get' ? JSON.parse(requestBody.content.schema.properties) : {}
143
+ // Add requestBody for non-GET methods
144
+ if (type !== 'get') {
145
+ methodAcc[type].requestBody = {
146
+ content: {
147
+ [requestBody.content.contentType]: {
148
+ schema: {
149
+ ...requestBody.content.schema,
150
+ properties: parsedRequestBodyProps,
151
+ },
152
+ },
153
+ },
154
+ }
155
+ }
156
+
157
+ return methodAcc
158
+ }, {} as Record<string, any>)
159
+
160
+ return acc
161
+ }, {} as OpenAPIFile['paths'])
162
+ }
@@ -1,20 +1,20 @@
1
- export const handleStatusColor = (code: number): string => {
2
- if (code >= 200 && code < 300) {
3
- return 'green' // 2xx codes
4
- } else if (code >= 400 && code < 500) {
5
- return 'red' // 4xx codes
6
- } else if (code >= 500 && code < 600) {
7
- return 'red' // 5xx codes
8
- } else if (code >= 100 && code < 200) {
9
- return 'blue' // 1xx codes (Informational)
10
- } else if (code >= 300 && code < 400) {
11
- return 'orange' // 3xx codes (Redirection)
12
- } else {
13
- return 'gray' // Default or invalid status codes
14
- }
15
- }
16
-
17
- export const capitalize = (str)=> {
18
- if (!str) return "";
19
- return str.charAt(0).toUpperCase() + str.slice(1);
1
+ export const handleStatusColor = (code: number): string => {
2
+ if (code >= 200 && code < 300) {
3
+ return 'green' // 2xx codes
4
+ } else if (code >= 400 && code < 500) {
5
+ return 'red' // 4xx codes
6
+ } else if (code >= 500 && code < 600) {
7
+ return 'red' // 5xx codes
8
+ } else if (code >= 100 && code < 200) {
9
+ return 'blue' // 1xx codes (Informational)
10
+ } else if (code >= 300 && code < 400) {
11
+ return 'orange' // 3xx codes (Redirection)
12
+ } else {
13
+ return 'gray' // Default or invalid status codes
14
+ }
15
+ }
16
+
17
+ export const capitalize = (str)=> {
18
+ if (!str) return "";
19
+ return str.charAt(0).toUpperCase() + str.slice(1);
20
20
  }
package/src/index.ts CHANGED
@@ -1 +1 @@
1
- export { default as Layout } from './layout/layout'
1
+ export { default as Layout } from './layout/layout'