@digi-frontend/dgate-api-documentation 1.0.57 → 1.0.60

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 (81) hide show
  1. package/dist/_virtual/index4.js +1 -1
  2. package/dist/_virtual/index5.js +1 -1
  3. package/dist/_virtual/index6.js +1 -1
  4. package/dist/_virtual/index7.js +1 -1
  5. package/dist/node_modules/digitinary-ui/dist/index.js.map +1 -1
  6. package/dist/node_modules/highlight.js/lib/core.js.map +1 -1
  7. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +1 -1
  8. package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
  9. package/dist/node_modules/react-fast-compare/index.js +1 -1
  10. package/dist/node_modules/react-fast-compare/index.js.map +1 -1
  11. package/dist/node_modules/react-property/lib/index.js.map +1 -1
  12. package/dist/node_modules/toposort/index.js +1 -1
  13. package/dist/node_modules/yup/index.esm.js +1 -1
  14. package/dist/node_modules/yup/index.esm.js.map +1 -1
  15. package/dist/src/components/InfoForm/InfoForm.js +1 -1
  16. package/dist/src/components/InfoForm/InfoForm.js.map +1 -1
  17. package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
  18. package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
  19. package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
  20. package/dist/src/components/SVGLoader/SVGLoader.js.map +1 -1
  21. package/dist/src/components/SectionHead/SectionHead.js.map +1 -1
  22. package/dist/src/components/SimpleLabelValue/SimpleLabelValue.js.map +1 -1
  23. package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
  24. package/dist/src/components/dialog/index.js.map +1 -1
  25. package/dist/src/components/table/table.js +1 -1
  26. package/dist/src/components/table/table.js.map +1 -1
  27. package/dist/src/components/table/tags-table.js.map +1 -1
  28. package/dist/src/context/SectionToggleContext.js +2 -0
  29. package/dist/src/context/SectionToggleContext.js.map +1 -0
  30. package/dist/src/helpers/docs.helper.js +1 -1
  31. package/dist/src/helpers/docs.helper.js.map +1 -1
  32. package/dist/src/helpers/layout.helper.js.map +1 -1
  33. package/dist/src/layout/docsComponents/Codebox/Codebox.js.map +1 -1
  34. package/dist/src/layout/docsComponents/DocsAside/DocsAside.js +1 -1
  35. package/dist/src/layout/docsComponents/DocsAside/DocsAside.js.map +1 -1
  36. package/dist/src/layout/docsComponents/DocsContent/DocsContent.js +1 -1
  37. package/dist/src/layout/docsComponents/DocsContent/DocsContent.js.map +1 -1
  38. package/dist/src/layout/docsComponents/DocsContent/EndpointPage/index.js +1 -1
  39. package/dist/src/layout/docsComponents/DocsContent/EndpointPage/index.js.map +1 -1
  40. package/dist/src/layout/docsComponents/DocsContent/OverviewPage/index.js +1 -1
  41. package/dist/src/layout/docsComponents/DocsContent/OverviewPage/index.js.map +1 -1
  42. package/dist/src/layout/docsComponents/DocsHeader/DocsHeader.js.map +1 -1
  43. package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js +1 -1
  44. package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js.map +1 -1
  45. package/dist/src/layout/docsLayout.js +1 -1
  46. package/dist/src/layout/docsLayout.js.map +1 -1
  47. package/dist/src/layout/layout.js +1 -1
  48. package/dist/src/layout/layout.js.map +1 -1
  49. package/dist/src/utils/index.js +1 -1
  50. package/dist/src/utils/index.js.map +1 -1
  51. package/dist/styles.css +753 -753
  52. package/dist/types/context/SectionToggleContext.d.ts +37 -0
  53. package/dist/types/layout/docsComponents/DocsContent/DocsContent.d.ts +2 -3
  54. package/dist/types/layout/docsComponents/DocsContent/EndpointPage/index.d.ts +4 -2
  55. package/dist/types/layout/docsComponents/DocsContent/OverviewPage/index.d.ts +2 -2
  56. package/dist/types/layout/docsComponents/DocsHeader/DocsHeader.d.ts +5 -2
  57. package/dist/types/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.d.ts +3 -4
  58. package/dist/types/layout/docsLayout.d.ts +1 -6
  59. package/dist/types/types/docsLayout.type.d.ts +7 -0
  60. package/dist/types/utils/index.d.ts +1 -0
  61. package/package.json +1 -1
  62. package/src/components/InfoForm/InfoForm.tsx +2 -1
  63. package/src/components/table/table.tsx +1 -3
  64. package/src/context/SectionToggleContext.tsx +121 -0
  65. package/src/helpers/docs.helper.ts +1 -1
  66. package/src/layout/docsComponents/DocsAside/DocsAside.tsx +3 -3
  67. package/src/layout/docsComponents/DocsAside/style.module.scss +3 -3
  68. package/src/layout/docsComponents/DocsContent/DocsContent.tsx +18 -7
  69. package/src/layout/docsComponents/DocsContent/EndpointPage/index.tsx +46 -10
  70. package/src/layout/docsComponents/DocsContent/OverviewPage/index.tsx +37 -30
  71. package/src/layout/docsComponents/DocsHeader/DocsHeader.tsx +4 -3
  72. package/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.tsx +68 -44
  73. package/src/layout/docsLayout.tsx +35 -96
  74. package/src/layout/layout.tsx +1 -0
  75. package/src/types/docsLayout.type.ts +7 -0
  76. package/src/utils/index.ts +5 -0
  77. package/the_npm_commands.sh +12 -0
  78. package/variables.txt +4 -0
  79. package/dist/src/layout/docsComponents/DocsContent/TagPage/index.js +0 -2
  80. package/dist/src/layout/docsComponents/DocsContent/TagPage/index.js.map +0 -1
  81. package/dist/types/layout/docsComponents/DocsContent/TagPage/index.d.ts +0 -8
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from 'react';
2
+ export declare enum SectionEnum {
3
+ OVERVIEW = "overview",
4
+ RESOURCE = "resource",
5
+ API_SECTION = "apiSection",
6
+ TAG_SECTION = "tagSection",
7
+ ENDPOINTS_SECTION = "endpointsSection"
8
+ }
9
+ type SectionKey = `api_${string}_${SectionEnum}` | `api_${string}_${SectionEnum}_${string | number}` | `api_${string}_${SectionEnum}_${string | number}_${string | number}`;
10
+ type ExpandedSections = Record<SectionKey, boolean>;
11
+ interface SectionToggleContextType {
12
+ expandedSections: ExpandedSections;
13
+ toggleSection: (apiId: string, sections: ToggleSectionDescriptor[], options?: ToggleOptions) => void;
14
+ generateSectionKey: ({ apiId, type, index, id }: GenerateSectionKeyParams) => SectionKey;
15
+ }
16
+ interface SectionToggleProviderProps {
17
+ children: ReactNode;
18
+ }
19
+ export interface ToggleSectionDescriptor {
20
+ type: SectionEnum;
21
+ index?: string | number;
22
+ setTo?: boolean;
23
+ id?: string;
24
+ }
25
+ export interface ToggleOptions {
26
+ resetOthers?: boolean;
27
+ filterKeys?: SectionEnum[];
28
+ }
29
+ interface GenerateSectionKeyParams {
30
+ apiId: string;
31
+ type: SectionEnum;
32
+ index?: string | number;
33
+ id?: string | number;
34
+ }
35
+ export declare const useSectionToggle: () => SectionToggleContextType;
36
+ export declare const SectionToggleProvider: ({ children }: SectionToggleProviderProps) => import("react/jsx-runtime").JSX.Element;
37
+ export {};
@@ -1,13 +1,12 @@
1
1
  import React from 'react';
2
2
  import './style.scss';
3
3
  import { EndpointData, OverviewData } from 'src/layout/docsLayout';
4
- declare const DocsContent: ({ data, activeType, setActiveItemData, setActiveType, setExpandedSections, onProductNavigate, }: {
4
+ declare const DocsContent: ({ data, activeType, setActiveItemData, setActiveType, onProductNavigate, apis, }: {
5
5
  data: OverviewData | EndpointData;
6
6
  activeType: "OVERVIEW" | "ENDPOINT";
7
7
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>;
8
8
  setActiveType: React.Dispatch<React.SetStateAction<"OVERVIEW" | "ENDPOINT">>;
9
- setExpandedSections: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
10
- toggleSection: (apiId: string, sectionId: string, resetOthers?: boolean, key?: string[]) => void;
11
9
  onProductNavigate?: (productId: number) => void;
10
+ apis: OverviewData[];
12
11
  }) => import("react/jsx-runtime").JSX.Element;
13
12
  export default DocsContent;
@@ -1,5 +1,7 @@
1
+ import { EndpointData, OverviewData } from 'src/layout/docsLayout';
1
2
  import './style.scss';
2
- import { EndpointData } from 'src/layout/docsLayout';
3
- export declare const EndpointPage: ({ data }: {
3
+ export declare const EndpointPage: ({ data, setActiveType, setActiveItemData, }: {
4
4
  data: EndpointData;
5
+ setActiveType: React.Dispatch<React.SetStateAction<"OVERVIEW" | "ENDPOINT">>;
6
+ setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>;
5
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import './style.scss';
2
2
  import { EndpointData, OverviewData } from 'src/layout/docsLayout';
3
- export declare const OverviewPage: ({ data, setActiveItemData, setActiveType, setExpandedSections, onProductNavigate, }: {
3
+ export declare const OverviewPage: ({ data, setActiveItemData, setActiveType, onProductNavigate, apis, }: {
4
4
  data: OverviewData;
5
5
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>;
6
6
  setActiveType: React.Dispatch<React.SetStateAction<"OVERVIEW" | "ENDPOINT">>;
7
- setExpandedSections: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
8
7
  onProductNavigate?: (productId: number) => void;
8
+ apis: OverviewData[];
9
9
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,6 @@
1
- import React from 'react';
2
- declare const DocsHeader: React.FC;
1
+ import { OverviewData } from '../../../../src/layout/docsLayout';
2
+ declare const DocsHeader: ({ transformedOpenApis, updateFilteredData, }: {
3
+ transformedOpenApis: OverviewData[];
4
+ updateFilteredData: (filteredItems: OverviewData[], isReset?: boolean) => void;
5
+ }) => import("react/jsx-runtime").JSX.Element;
3
6
  export default DocsHeader;
@@ -1,19 +1,18 @@
1
1
  import './style.scss';
2
2
  import React from 'react';
3
3
  import { EndpointData, OverviewData } from 'src/layout/docsLayout';
4
- declare const DocsSideMenuTree: ({ apis, setActiveItemData, activeItemData, activeType, expandedSections, setExpandedSections, isFirstApiExpanded, setIsFirstApiExpanded, setActiveType, toggleSection, canSelectFirstApi, canFocusSection, setCanFocusSection, }: {
4
+ declare const DocsSideMenuTree: ({ apis, setActiveItemData, isFirstApiExpanded, setIsFirstApiExpanded, setActiveType, canSelectFirstApi, canFocusSection, setCanFocusSection, activeApiId, setCanSelectFirstApi, }: {
5
5
  apis: OverviewData[];
6
6
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>;
7
7
  activeItemData: OverviewData | EndpointData;
8
- expandedSections: Record<string, boolean>;
9
- setExpandedSections: (newSections: Record<string, boolean>) => void;
10
8
  isFirstApiExpanded: boolean;
11
9
  setIsFirstApiExpanded: React.Dispatch<React.SetStateAction<boolean>>;
12
10
  setActiveType: React.Dispatch<React.SetStateAction<"OVERVIEW" | "ENDPOINT">>;
13
11
  activeType: "OVERVIEW" | "ENDPOINT";
14
- toggleSection: (apiId: string, sectionId: string, resetOthers?: boolean, key?: string[]) => void;
15
12
  canSelectFirstApi?: boolean;
16
13
  canFocusSection: boolean;
17
14
  setCanFocusSection: React.Dispatch<React.SetStateAction<boolean>>;
15
+ activeApiId: string;
16
+ setCanSelectFirstApi: React.Dispatch<React.SetStateAction<boolean>>;
18
17
  }) => import("react/jsx-runtime").JSX.Element;
19
18
  export default DocsSideMenuTree;
@@ -18,12 +18,7 @@ export interface TagData {
18
18
  requestBody?: RequestBody;
19
19
  }
20
20
  export interface EndpointData extends TagData {
21
- api: {
22
- id: string;
23
- description: string;
24
- title: string;
25
- version: string;
26
- };
21
+ api: OverviewData;
27
22
  }
28
23
  export interface OverviewData extends Omit<ApiSpecModel, 'metaData'> {
29
24
  description: string;
@@ -0,0 +1,7 @@
1
+ export declare enum SectionEnum {
2
+ OVERVIEW = "overview",
3
+ RESOURCE = "resource",
4
+ API_SECTION = "apiSection",
5
+ TAG_SECTION = "tagSection",
6
+ ENDPOINTS_SECTION = "endpointsSection"
7
+ }
@@ -1 +1,2 @@
1
1
  export declare const copyToClipboard: (text: string) => Promise<any>;
2
+ export declare const capitalizeFirstLetter: (text: string) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digi-frontend/dgate-api-documentation",
3
- "version": "1.0.57",
3
+ "version": "1.0.60",
4
4
  "main": "dist/src/index.js",
5
5
  "module": "dist/src/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -409,8 +409,9 @@ const InfoForm = ({ readOnly }: { readOnly?: boolean }) => {
409
409
  }}
410
410
  onCancel={{
411
411
  text: 'Cancel',
412
- color: 'normal',
412
+ color: 'action',
413
413
  fullWidth: true,
414
+ variant: 'outlined',
414
415
  }}
415
416
  onClose={() => setOpenDeleteDialog(false)}
416
417
  open={openDeleteDialog}
@@ -251,9 +251,7 @@ const ParamterTable = ({
251
251
 
252
252
  <td key={'parameter enum'}>
253
253
  <div data-id="TEXT_DESCRIPTION" className="tableData">
254
- {values?.schema &&
255
- values?.schema?.type?.toLowerCase() != 'array' &&
256
- values?.schema?.type?.toLowerCase() != 'object' ? (
254
+ {!!values?.schema ? (
257
255
  <Tooltip
258
256
  disabled={
259
257
  values?.schema?.type?.toLowerCase() == 'array' ||
@@ -0,0 +1,121 @@
1
+ import React, { createContext, useContext, useState, ReactNode, useMemo, useCallback } from 'react'
2
+
3
+ export enum SectionEnum {
4
+ OVERVIEW = 'overview',
5
+ RESOURCE = 'resource',
6
+ API_SECTION = 'apiSection',
7
+ TAG_SECTION = 'tagSection',
8
+ ENDPOINTS_SECTION = 'endpointsSection',
9
+ }
10
+
11
+ type SectionKey =
12
+ | `api_${string}_${SectionEnum}`
13
+ | `api_${string}_${SectionEnum}_${string | number}`
14
+ | `api_${string}_${SectionEnum}_${string | number}_${string | number}`
15
+ type ExpandedSections = Record<SectionKey, boolean>
16
+
17
+ interface SectionToggleContextType {
18
+ expandedSections: ExpandedSections
19
+ toggleSection: (
20
+ apiId: string,
21
+ sections: ToggleSectionDescriptor[],
22
+ options?: ToggleOptions
23
+ ) => void
24
+ generateSectionKey: ({ apiId, type, index, id }: GenerateSectionKeyParams) => SectionKey
25
+ }
26
+
27
+ interface SectionToggleProviderProps {
28
+ children: ReactNode
29
+ }
30
+
31
+ export interface ToggleSectionDescriptor {
32
+ type: SectionEnum
33
+ index?: string | number
34
+ setTo?: boolean
35
+ id?: string
36
+ }
37
+
38
+ export interface ToggleOptions {
39
+ resetOthers?: boolean
40
+ filterKeys?: SectionEnum[]
41
+ }
42
+
43
+ interface GenerateSectionKeyParams {
44
+ apiId: string
45
+ type: SectionEnum
46
+ index?: string | number
47
+ id?: string | number
48
+ }
49
+
50
+ const SectionToggleContext = createContext<SectionToggleContextType | null>(null)
51
+
52
+ export const useSectionToggle = () => {
53
+ const context = useContext(SectionToggleContext)
54
+ if (!context) {
55
+ throw new Error('useSectionToggle must be used within SectionToggleProvider')
56
+ }
57
+ return context
58
+ }
59
+
60
+ export const SectionToggleProvider = ({ children }: SectionToggleProviderProps) => {
61
+ const [expandedSections, setExpandedSections] = useState<ExpandedSections>({})
62
+
63
+ const generateSectionKey = ({ apiId, type, index, id }: GenerateSectionKeyParams): SectionKey => {
64
+ let key = `api_${apiId}_${type}`
65
+
66
+ if (index !== undefined) key += `_${index}`
67
+ if (id !== undefined) key += `_${id}`
68
+
69
+ return key as SectionKey
70
+ }
71
+
72
+ const toggleSection = useCallback(
73
+ (apiId: string, sections: ToggleSectionDescriptor[], options: ToggleOptions = {}) => {
74
+ const { resetOthers = false, filterKeys = [] } = options
75
+
76
+ const sectionIds = sections.map(({ type, index, id }) =>
77
+ generateSectionKey({ apiId, type, index, id })
78
+ )
79
+
80
+ const sectionToggles = Object.fromEntries(
81
+ sections.map(({ type, index, setTo, id }) => {
82
+ const sectionId = generateSectionKey({ apiId, type, index, id })
83
+ const currentValue = expandedSections[sectionId]
84
+
85
+ return [sectionId, setTo !== undefined ? setTo : !currentValue]
86
+ })
87
+ )
88
+
89
+ if (resetOthers && filterKeys.length > 0) {
90
+ const filtered = Object.fromEntries(
91
+ Object.entries(expandedSections).filter(([key]) => {
92
+ const shouldKeep = key.includes(apiId) && !filterKeys.some((k) => key.includes(k))
93
+ return shouldKeep || sectionIds.includes(key as SectionKey)
94
+ })
95
+ )
96
+ const newState = { ...filtered, ...sectionToggles }
97
+ setExpandedSections(newState)
98
+ } else {
99
+ setExpandedSections((prev) => {
100
+ const next = { ...prev, ...sectionToggles }
101
+
102
+ return next
103
+ })
104
+ }
105
+ },
106
+ [expandedSections]
107
+ )
108
+
109
+ const contextValue = useMemo(
110
+ () => ({
111
+ expandedSections,
112
+ toggleSection,
113
+ generateSectionKey,
114
+ }),
115
+ [expandedSections, toggleSection]
116
+ )
117
+
118
+ return (
119
+ <SectionToggleContext.Provider value={contextValue}>{children}</SectionToggleContext.Provider>
120
+ )
121
+ }
@@ -10,7 +10,7 @@ export const transformOpenApiToDocs = (api: ApiSpecModel): OverviewData => {
10
10
  : api.metaData.openApiJson
11
11
 
12
12
  const groupedPathsByTags: Record<string, TagData[]> = { default: [] }
13
- const validTags = new Set(parsedOpenApi.tags.map(({ name }) => name))
13
+ const validTags = new Set(parsedOpenApi?.tags?.map(({ name }) => name) || [])
14
14
 
15
15
  for (const [path, methods] of Object.entries(parsedOpenApi.paths)) {
16
16
  for (const [method, methodData] of Object.entries(methods)) {
@@ -28,7 +28,7 @@ const DocsAside = ({ data }: { data: EndpointData }) => {
28
28
  const stringifyRequestBody = () => {
29
29
  if (data?.requestBody?.content) {
30
30
  const contentKey = Object.keys(data?.requestBody?.content)[0]
31
- return JSON.stringify(data?.requestBody?.content[contentKey], null, 2)
31
+ return JSON.stringify(data?.requestBody?.content[contentKey]?.schema?.properties, null, 2)
32
32
  } else {
33
33
  return '{}'
34
34
  }
@@ -37,7 +37,7 @@ const DocsAside = ({ data }: { data: EndpointData }) => {
37
37
  const stringifyResponseBody = () => {
38
38
  if (currentResponse?.data) {
39
39
  const contentKey = Object.keys(currentResponse.data?.content)[0]
40
- return JSON.stringify(currentResponse.data?.content[contentKey], null, 2)
40
+ return JSON.stringify(currentResponse.data?.content[contentKey]?.schema?.properties, null, 2)
41
41
  } else {
42
42
  return '{}'
43
43
  }
@@ -52,7 +52,7 @@ const DocsAside = ({ data }: { data: EndpointData }) => {
52
52
  </span>{' '}
53
53
  <span>{data.path}</span>
54
54
  </h4>
55
- {data?.requestBody?.content && (
55
+ {!['delete', 'get'].includes(data.method) && data?.requestBody?.content && (
56
56
  <div className={styles.codeboxSection}>
57
57
  <div className={styles.codeboxHeader}>
58
58
  <h6 className={styles.codeboxTitle}>Request</h6>
@@ -103,11 +103,11 @@
103
103
 
104
104
  :global(.multiSelectGroup .selectDisplay),
105
105
  :global(.multiSelectGroup) {
106
- width: 6.25rem;
107
- height: 1.5rem;
106
+ width: 6.25rem !important;
107
+ height: 1.5rem !important;
108
108
  }
109
109
 
110
110
  :global(.multiSelectGroup .selectDisplay .displayValueContainer .iconsContainer) {
111
- padding-right: 0.75rem;
111
+ padding-right: 0.75rem !important;
112
112
  }
113
113
  }
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { useEffect, useRef } from 'react'
2
2
  import './style.scss'
3
3
  import { OverviewPage } from './OverviewPage'
4
4
  import { EndpointPage } from './EndpointPage'
@@ -9,29 +9,40 @@ const DocsContent = ({
9
9
  activeType,
10
10
  setActiveItemData,
11
11
  setActiveType,
12
- setExpandedSections,
13
12
  onProductNavigate,
13
+ apis,
14
14
  }: {
15
15
  data: OverviewData | EndpointData
16
16
  activeType: 'OVERVIEW' | 'ENDPOINT'
17
17
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>
18
18
  setActiveType: React.Dispatch<React.SetStateAction<'OVERVIEW' | 'ENDPOINT'>>
19
- setExpandedSections: React.Dispatch<React.SetStateAction<Record<string, boolean>>>
20
- toggleSection: (apiId: string, sectionId: string, resetOthers?: boolean, key?: string[]) => void
21
19
  onProductNavigate?: (productId: number) => void
20
+ apis: OverviewData[]
22
21
  }) => {
22
+ const containerRef = useRef(null)
23
+
24
+ useEffect(() => {
25
+ // This will scroll to the top when changing the overview
26
+ if (activeType === 'OVERVIEW' && containerRef?.current) {
27
+ containerRef?.current?.scrollTo({ top: 0, behavior: 'smooth' })
28
+ }
29
+ }, [data, activeType])
23
30
  return (
24
- <main>
31
+ <main ref={containerRef}>
25
32
  {activeType === 'OVERVIEW' ? (
26
33
  <OverviewPage
27
34
  data={data as OverviewData}
28
35
  setActiveItemData={setActiveItemData}
29
36
  setActiveType={setActiveType}
30
- setExpandedSections={setExpandedSections}
31
37
  onProductNavigate={onProductNavigate}
38
+ apis={apis}
32
39
  />
33
40
  ) : (
34
- <EndpointPage data={data as EndpointData} />
41
+ <EndpointPage
42
+ data={data as EndpointData}
43
+ setActiveType={setActiveType}
44
+ setActiveItemData={setActiveItemData}
45
+ />
35
46
  )}
36
47
  </main>
37
48
  )
@@ -1,4 +1,3 @@
1
- import './style.scss'
2
1
  import SVGLoader from '../../../../components/SVGLoader/SVGLoader'
3
2
  import {
4
3
  ArrowBack,
@@ -8,14 +7,26 @@ import {
8
7
  } from '../../../../assets/icons/index'
9
8
  import { SelectGroup } from 'digitinary-ui'
10
9
  import { useEffect, useState } from 'react'
11
- import { EndpointData } from 'src/layout/docsLayout'
10
+ import { EndpointData, OverviewData } from 'src/layout/docsLayout'
12
11
  import { handleStatusColor } from '../../../../helpers/methodAccordion.helper'
13
12
  import { httpStatusCodes } from '../../../../constants/index'
14
13
  import styles from '../../Codebox/style.module.scss'
15
14
  import Tooltip from '../../../../components/Tooltip/Tooltip'
15
+ import './style.scss'
16
+ import { SectionEnum, useSectionToggle } from '../../../../../src/context/SectionToggleContext'
17
+ import { capitalizeFirstLetter } from '../../../../../src/utils'
16
18
 
17
- export const EndpointPage = ({ data }: { data: EndpointData }) => {
19
+ export const EndpointPage = ({
20
+ data,
21
+ setActiveType,
22
+ setActiveItemData,
23
+ }: {
24
+ data: EndpointData
25
+ setActiveType: React.Dispatch<React.SetStateAction<'OVERVIEW' | 'ENDPOINT'>>
26
+ setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>
27
+ }) => {
18
28
  const [activeTab, setActiveTab] = useState('header')
29
+ const { toggleSection } = useSectionToggle()
19
30
 
20
31
  const httpStatusCodeOptions = httpStatusCodes.map((code) => ({
21
32
  label: (
@@ -47,7 +58,17 @@ export const EndpointPage = ({ data }: { data: EndpointData }) => {
47
58
  return (
48
59
  <div className="api-details-expanded">
49
60
  <div className="test-button">
50
- <button className="back-button" onClick={() => window.history.back()}>
61
+ <button
62
+ className="back-button"
63
+ onClick={() => {
64
+ toggleSection(data.api.apiSpecId, [{ type: SectionEnum.OVERVIEW, setTo: true }], {
65
+ resetOthers: true,
66
+ filterKeys: [SectionEnum.RESOURCE],
67
+ })
68
+ setActiveType('OVERVIEW')
69
+ setActiveItemData(data.api)
70
+ }}
71
+ >
51
72
  <SVGLoader src={ArrowBack} />
52
73
  </button>
53
74
 
@@ -55,8 +76,8 @@ export const EndpointPage = ({ data }: { data: EndpointData }) => {
55
76
  <button className="disabled">Test</button>
56
77
  </Tooltip>
57
78
  </div>
58
- <h3> Api Name</h3>
59
- <h1 className="api-title">{data?.api?.title}</h1>
79
+ <h3>{data.api.title}</h3>
80
+ <h1 className="api-title">{data?.summary}</h1>
60
81
  <div className="url-box">
61
82
  <div style={{ textAlign: 'center' }}>
62
83
  <span className={`method-label ${data?.method?.toLowerCase()}`}>{data.method}</span>
@@ -67,7 +88,7 @@ export const EndpointPage = ({ data }: { data: EndpointData }) => {
67
88
  </span>
68
89
  </div>
69
90
 
70
- <p className="api-desc">{data?.api?.description || 'No Description'}</p>
91
+ <p className="api-desc">{data?.description || 'No Description'}</p>
71
92
 
72
93
  <h3>Request</h3>
73
94
 
@@ -108,7 +129,14 @@ export const EndpointPage = ({ data }: { data: EndpointData }) => {
108
129
  <tr key={index}>
109
130
  <td>{row.name}</td>
110
131
  <td>{row.required ? 'True' : 'False'}</td>
111
- <td>{row.schema?.type || '-'}</td>
132
+ <td style={{ textTransform: 'capitalize' }}>
133
+ <span>{row?.schema?.type || '-'}</span>
134
+ {row?.schema?.type === 'array' && row?.schema?.items?.type && (
135
+ <span style={{ color: '#616874', fontSize: '0.75rem' }}>
136
+ _{capitalizeFirstLetter(row.schema?.items?.type)}
137
+ </span>
138
+ )}
139
+ </td>
112
140
  <td>{Array.isArray(row.schema?.enum) ? row.schema.enum.join(' / ') : '-'}</td>
113
141
  <td className="desc-cell">
114
142
  <div className={`desc-text ${expanded === index ? 'expanded' : ''}`}>
@@ -179,11 +207,19 @@ export const EndpointPage = ({ data }: { data: EndpointData }) => {
179
207
  <tbody>
180
208
  {!!headersList &&
181
209
  Object.keys(headersList) &&
182
- Object.keys(headersList).map((key, index) => (
210
+ Object.keys(headersList).map((key) => (
183
211
  <tr>
184
212
  <td>{key}</td>
185
213
  <td>{headersList[key]?.required.toString()}</td>
186
- <td>{headersList[key]?.schema?.type}</td>
214
+ <td style={{ textTransform: 'capitalize' }}>
215
+ <span>{headersList[key]?.schema?.type || '-'}</span>
216
+ {headersList[key]?.schema?.type === 'array' &&
217
+ headersList[key]?.schema?.items?.type && (
218
+ <span style={{ color: '#616874', fontSize: '0.75rem' }}>
219
+ _{capitalizeFirstLetter(headersList[key]?.schema?.items?.type)}
220
+ </span>
221
+ )}
222
+ </td>
187
223
  <td>{headersList[key]?.schema?.enum?.join('/')}</td>
188
224
  <td>{headersList[key]?.description}</td>
189
225
  </tr>
@@ -2,20 +2,23 @@ import './style.scss'
2
2
  import SVGLoader from '../../../../components/SVGLoader/SVGLoader'
3
3
  import { arrowRightGray, CopySticker } from '../../../../assets/icons/index'
4
4
  import { EndpointData, OverviewData } from 'src/layout/docsLayout'
5
+ import { SectionEnum, useSectionToggle } from '../../../../../src/context/SectionToggleContext'
5
6
 
6
7
  export const OverviewPage = ({
7
8
  data,
8
9
  setActiveItemData,
9
10
  setActiveType,
10
- setExpandedSections,
11
11
  onProductNavigate,
12
+ apis,
12
13
  }: {
13
14
  data: OverviewData
14
15
  setActiveItemData: React.Dispatch<React.SetStateAction<OverviewData | EndpointData>>
15
16
  setActiveType: React.Dispatch<React.SetStateAction<'OVERVIEW' | 'ENDPOINT'>>
16
- setExpandedSections: React.Dispatch<React.SetStateAction<Record<string, boolean>>>
17
17
  onProductNavigate?: (productId: number) => void
18
+ apis: OverviewData[]
18
19
  }) => {
20
+ const { toggleSection } = useSectionToggle()
21
+
19
22
  const handleVersionClick = (verObj) => {
20
23
  if (verObj.apiSpecId === data.apiSpecId) {
21
24
  setActiveType('OVERVIEW')
@@ -28,30 +31,26 @@ export const OverviewPage = ({
28
31
  return
29
32
  }
30
33
 
31
- const newData = {
32
- ...data,
33
- ...matchedVersion,
34
- version: matchedVersion.metaData?.version || '',
35
- title: matchedVersion.name || '',
36
- apiSpecId: matchedVersion.apiSpecId,
37
- }
38
-
39
- setActiveItemData({
40
- ...newData,
41
- api: {
42
- id: newData.apiSpecId,
43
- title: newData.title,
44
- description: newData.description,
45
- version: newData.version,
46
- ...newData,
47
- },
48
- })
34
+ const matchedApi = apis.find((api) => api.apiSpecId === matchedVersion.apiSpecId)
35
+ setActiveItemData(matchedApi)
49
36
 
50
37
  setActiveType('OVERVIEW')
51
- setExpandedSections((prev) => ({
52
- ...prev,
53
- [`api-${newData.apiSpecId}-section`]: true,
54
- }))
38
+ toggleSection(
39
+ matchedApi.apiSpecId,
40
+ [
41
+ { type: SectionEnum.API_SECTION, setTo: true },
42
+ { type: SectionEnum.OVERVIEW, setTo: true },
43
+ ],
44
+ {
45
+ resetOthers: true,
46
+ filterKeys: [
47
+ SectionEnum.OVERVIEW,
48
+ SectionEnum.API_SECTION,
49
+ SectionEnum.ENDPOINTS_SECTION,
50
+ SectionEnum.TAG_SECTION,
51
+ ],
52
+ }
53
+ )
55
54
  }
56
55
 
57
56
  const handleClick = (endpoint) => {
@@ -67,12 +66,20 @@ export const OverviewPage = ({
67
66
  })
68
67
  setActiveType('ENDPOINT')
69
68
 
70
- setExpandedSections((prev) => ({
71
- ...prev,
72
- [`api-${data.apiSpecId}-section`]: true,
73
- [`api-${data.apiSpecId}-endpoints`]: true,
74
- [`api-${data.apiSpecId}-resource-${endpoint.id}`]: true,
75
- }))
69
+ const tagSectionIndex = Object.entries(data.tags)
70
+ .sort(([a], [b]) => (a === 'default' ? 1 : b === 'default' ? -1 : a.localeCompare(b)))
71
+ .findIndex(([_, tagData]) => tagData.find((t) => t.id === endpoint.id))
72
+
73
+ toggleSection(
74
+ data.apiSpecId,
75
+ [
76
+ { type: SectionEnum.API_SECTION, setTo: true },
77
+ { type: SectionEnum.ENDPOINTS_SECTION, setTo: true },
78
+ { type: SectionEnum.TAG_SECTION, setTo: true, index: tagSectionIndex },
79
+ { type: SectionEnum.RESOURCE, setTo: true, id: endpoint.id },
80
+ ],
81
+ { resetOthers: true, filterKeys: [SectionEnum.OVERVIEW] }
82
+ )
76
83
  }
77
84
 
78
85
  return (
@@ -13,13 +13,14 @@ import Tooltip from '../../../components/Tooltip/Tooltip'
13
13
  import CommonDialog from '../../../components/dialog/index'
14
14
  import { METHOD_OPTIONS } from '../../../constants/methods.constant'
15
15
  import styles from './DocsHeader.module.scss'
16
+ import { OverviewData } from '../../../../src/layout/docsLayout'
16
17
 
17
- const DocsHeader: React.FC = ({
18
+ const DocsHeader = ({
18
19
  transformedOpenApis,
19
20
  updateFilteredData,
20
21
  }: {
21
- transformedOpenApis: any[]
22
- updateFilteredData: any
22
+ transformedOpenApis: OverviewData[]
23
+ updateFilteredData: (filteredItems: OverviewData[], isReset?: boolean) => void
23
24
  }) => {
24
25
  const [showSearchFilter, setShowSearchFilter] = useState<boolean>(false)
25
26
  const [apiName, setApiName] = useState<string>('')