@digi-frontend/dgate-api-documentation 1.1.12 → 1.3.0
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/.editorconfig +13 -0
- package/.prettierignore +8 -0
- package/.prettierrc +15 -0
- package/dist/_virtual/index4.js +1 -1
- package/dist/_virtual/index5.js +1 -1
- package/dist/_virtual/index6.js +1 -1
- package/dist/_virtual/index7.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/createPopper.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/createPopper.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/enums.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/enums.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/applyStyles.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/applyStyles.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/eventListeners.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/eventListeners.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/flip.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/flip.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/hide.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/hide.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/offset.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/modifiers/offset.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/debounce.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/debounce.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/detectOverflow.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/detectOverflow.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/expandToHashMap.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/expandToHashMap.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositePlacement.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositePlacement.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/mergeByName.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/mergeByName.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/orderModifiers.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/orderModifiers.js.map +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/userAgent.js +1 -1
- package/dist/node_modules/@popperjs/core/lib/utils/userAgent.js.map +1 -1
- package/dist/node_modules/@tippyjs/react/dist/tippy-react.esm.js +1 -1
- package/dist/node_modules/@tippyjs/react/dist/tippy-react.esm.js.map +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/dom-serializer/lib/foreignNames.js +1 -1
- package/dist/node_modules/dom-serializer/lib/foreignNames.js.map +1 -1
- package/dist/node_modules/dom-serializer/lib/index.js +1 -1
- package/dist/node_modules/dom-serializer/lib/index.js.map +1 -1
- package/dist/node_modules/dom-serializer/node_modules/entities/lib/decode.js +1 -1
- package/dist/node_modules/dom-serializer/node_modules/entities/lib/decode.js.map +1 -1
- package/dist/node_modules/dom-serializer/node_modules/entities/lib/generated/decode-data-html.js +1 -1
- package/dist/node_modules/dom-serializer/node_modules/entities/lib/generated/decode-data-html.js.map +1 -1
- package/dist/node_modules/dom-serializer/node_modules/entities/lib/generated/decode-data-xml.js +1 -1
- package/dist/node_modules/dom-serializer/node_modules/entities/lib/generated/decode-data-xml.js.map +1 -1
- package/dist/node_modules/domhandler/lib/node.js +1 -1
- package/dist/node_modules/domhandler/lib/node.js.map +1 -1
- package/dist/node_modules/domutils/lib/feeds.js +1 -1
- package/dist/node_modules/domutils/lib/feeds.js.map +1 -1
- package/dist/node_modules/domutils/lib/helpers.js +1 -1
- package/dist/node_modules/domutils/lib/helpers.js.map +1 -1
- package/dist/node_modules/domutils/lib/legacy.js +1 -1
- package/dist/node_modules/domutils/lib/legacy.js.map +1 -1
- package/dist/node_modules/domutils/lib/querying.js +1 -1
- package/dist/node_modules/domutils/lib/querying.js.map +1 -1
- package/dist/node_modules/domutils/lib/stringify.js +1 -1
- package/dist/node_modules/domutils/lib/stringify.js.map +1 -1
- package/dist/node_modules/entities/dist/commonjs/decode.js +1 -1
- package/dist/node_modules/entities/dist/commonjs/decode.js.map +1 -1
- package/dist/node_modules/entities/dist/commonjs/generated/decode-data-html.js +1 -1
- package/dist/node_modules/entities/dist/commonjs/generated/decode-data-html.js.map +1 -1
- package/dist/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +1 -1
- package/dist/node_modules/entities/dist/commonjs/generated/decode-data-xml.js.map +1 -1
- package/dist/node_modules/formik/dist/formik.esm.js +1 -1
- package/dist/node_modules/formik/dist/formik.esm.js.map +1 -1
- package/dist/node_modules/formik/node_modules/deepmerge/dist/es.js +1 -1
- package/dist/node_modules/formik/node_modules/deepmerge/dist/es.js.map +1 -1
- package/dist/node_modules/highlight.js/lib/core.js +1 -1
- package/dist/node_modules/highlight.js/lib/core.js.map +1 -1
- package/dist/node_modules/highlight.js/lib/languages/json.js +1 -1
- package/dist/node_modules/highlight.js/lib/languages/json.js.map +1 -1
- package/dist/node_modules/html-react-parser/lib/utilities.js.map +1 -1
- package/dist/node_modules/htmlparser2/dist/commonjs/Tokenizer.js +1 -1
- package/dist/node_modules/htmlparser2/dist/commonjs/Tokenizer.js.map +1 -1
- package/dist/node_modules/htmlparser2/dist/commonjs/index.js +1 -1
- package/dist/node_modules/htmlparser2/dist/commonjs/index.js.map +1 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs.js +1 -1
- package/dist/node_modules/js-yaml/dist/js-yaml.mjs.js.map +1 -1
- package/dist/node_modules/lodash-es/_baseClone.js +1 -1
- package/dist/node_modules/lodash-es/_baseClone.js.map +1 -1
- package/dist/node_modules/lodash-es/_getSymbols.js +1 -1
- package/dist/node_modules/lodash-es/_getSymbols.js.map +1 -1
- package/dist/node_modules/lodash-es/_memoizeCapped.js +1 -1
- package/dist/node_modules/lodash-es/_memoizeCapped.js.map +1 -1
- package/dist/node_modules/lodash-es/_stringToPath.js +1 -1
- package/dist/node_modules/lodash-es/_stringToPath.js.map +1 -1
- package/dist/node_modules/property-expr/index.js +1 -1
- package/dist/node_modules/property-expr/index.js.map +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js +1 -1
- package/dist/node_modules/react/cjs/react-jsx-runtime.development.js.map +1 -1
- package/dist/node_modules/react-property/lib/index.js +1 -1
- package/dist/node_modules/react-property/lib/index.js.map +1 -1
- package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js +1 -1
- package/dist/node_modules/react-syntax-highlighter/dist/esm/create-element.js.map +1 -1
- package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js +1 -1
- package/dist/node_modules/react-syntax-highlighter/dist/esm/highlight.js.map +1 -1
- package/dist/node_modules/react-toastify/dist/index.mjs.js +1 -1
- package/dist/node_modules/react-toastify/dist/index.mjs.js.map +1 -1
- package/dist/node_modules/style-to-js/cjs/index.js +1 -1
- package/dist/node_modules/style-to-js/cjs/index.js.map +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js.map +1 -1
- package/dist/node_modules/tiny-case/index.js +1 -1
- package/dist/node_modules/tiny-case/index.js.map +1 -1
- package/dist/node_modules/tippy.js/dist/tippy.esm.js +1 -1
- package/dist/node_modules/tippy.js/dist/tippy.esm.js.map +1 -1
- package/dist/node_modules/toposort/index.js +1 -1
- package/dist/node_modules/toposort/index.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +1 -1
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/node_modules/yup/index.esm.js +1 -1
- package/dist/node_modules/yup/index.esm.js.map +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 +1 -1
- package/dist/src/components/JsonInput/JsonInput.js.map +1 -1
- package/dist/src/components/LivePreview/LivePreview.js +1 -1
- package/dist/src/components/LivePreview/LivePreview.js.map +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js +1 -1
- package/dist/src/components/MethodAccordion/MethodAccordion.js.map +1 -1
- package/dist/src/components/SVGLoader/SVGLoader.js +1 -1
- package/dist/src/components/SVGLoader/SVGLoader.js.map +1 -1
- package/dist/src/components/Tooltip/Tooltip.js +1 -1
- package/dist/src/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/src/components/table/table.js +1 -1
- package/dist/src/components/table/table.js.map +1 -1
- package/dist/src/components/table/tags-table.js +1 -1
- package/dist/src/components/table/tags-table.js.map +1 -1
- package/dist/src/constants/methods.constant.js +1 -1
- package/dist/src/constants/methods.constant.js.map +1 -1
- package/dist/src/context/SectionToggleContext.js +1 -1
- package/dist/src/context/SectionToggleContext.js.map +1 -1
- package/dist/src/helpers/docs.helper.js +1 -1
- package/dist/src/helpers/docs.helper.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/docsComponents/DocsAside/DocsAside.js +1 -1
- package/dist/src/layout/docsComponents/DocsAside/DocsAside.js.map +1 -1
- package/dist/src/layout/docsComponents/DocsContent/DocsContent.js +1 -1
- package/dist/src/layout/docsComponents/DocsContent/DocsContent.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/DocsContent/OverviewPage/index.js +1 -1
- package/dist/src/layout/docsComponents/DocsContent/OverviewPage/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/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js +1 -1
- package/dist/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.js.map +1 -1
- package/dist/src/layout/docsLayout.js +1 -1
- package/dist/src/layout/docsLayout.js.map +1 -1
- package/dist/src/layout/layout.js +1 -1
- package/dist/src/layout/layout.js.map +1 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/validator/form.scheme.js +1 -1
- package/dist/src/validator/form.scheme.js.map +1 -1
- package/dist/styles.css +773 -773
- package/index.ts +2 -0
- package/package.json +4 -9
- package/rollup.config.js +37 -0
- package/src/assets/icons/AddRow.svg +3 -0
- package/src/assets/icons/ApiIcon.svg +12 -0
- package/src/assets/icons/ArrowBack.svg +3 -0
- package/src/assets/icons/BookIcon.svg +6 -0
- package/src/assets/icons/CheckMarkSquare.svg +5 -0
- package/src/assets/icons/CloseIcon.svg +4 -0
- package/src/assets/icons/CopySticker.svg +6 -0
- package/src/assets/icons/DeleteIcon.svg +3 -0
- package/src/assets/icons/DownArrow.svg +3 -0
- package/src/assets/icons/EditIcon.svg +3 -0
- package/src/assets/icons/FilterIcon.svg +4 -0
- package/src/assets/icons/Plus.svg +5 -0
- package/src/assets/icons/PlusSquare.svg +3 -0
- package/src/assets/icons/RequestOption.svg +5 -0
- package/src/assets/icons/UpArrow.svg +3 -0
- package/src/assets/icons/arrow-down.svg +3 -0
- package/src/assets/icons/arrow-up.svg +10 -0
- package/src/assets/icons/arrowDownGray.svg +3 -0
- package/src/assets/icons/arrowRightGray.svg +3 -0
- package/src/assets/icons/close-circle.svg +5 -0
- package/src/assets/icons/copy.svg +4 -0
- package/src/assets/icons/deleteOutlinedIcon.svg +8 -0
- package/src/assets/icons/document.svg +6 -0
- package/src/assets/icons/eye.svg +4 -0
- package/src/assets/icons/index.ts +27 -0
- package/src/assets/icons/infoIcon.svg +5 -0
- package/src/assets/icons/newCopyIcon.svg +4 -0
- package/src/assets/icons/searchIcon.svg +4 -0
- package/src/components/Chips/Chips.tsx +87 -0
- package/src/components/InfoForm/InfoForm.tsx +432 -0
- package/src/components/JsonInput/JsonInput.tsx +149 -0
- package/src/components/LivePreview/LivePreview.tsx +224 -0
- package/src/components/MethodAccordion/MethodAccordion.tsx +1070 -0
- package/src/components/SVGLoader/SVGLoader.tsx +96 -0
- package/src/components/SectionHead/SectionHead.tsx +22 -0
- package/src/components/SimpleLabelValue/SimpleLabelValue.tsx +31 -0
- package/src/components/SimpleLabelValue/index.ts +1 -0
- package/src/components/Tooltip/Tooltip.tsx +85 -0
- package/src/components/dialog/dialog.ts +61 -0
- package/src/components/dialog/index.tsx +88 -0
- package/src/components/table/table.tsx +508 -0
- package/src/components/table/tags-table.tsx +348 -0
- package/src/constants/index.ts +95 -0
- package/src/constants/methods.constant.ts +26 -0
- package/src/constants/regex.ts +7 -0
- package/src/context/SectionToggleContext.tsx +121 -0
- package/src/global.d.ts +13 -0
- package/src/helpers/docs.helper.ts +42 -0
- package/src/helpers/layout.helper.ts +290 -0
- package/src/helpers/methodAccordion.helper.ts +20 -0
- package/src/index.ts +2 -0
- package/src/layout/docsComponents/Codebox/Codebox.tsx +61 -0
- package/src/layout/docsComponents/DocsAside/DocsAside.tsx +112 -0
- package/src/layout/docsComponents/DocsContent/DocsContent.tsx +51 -0
- package/src/layout/docsComponents/DocsContent/EndpointPage/index.tsx +307 -0
- package/src/layout/docsComponents/DocsContent/OverviewPage/index.tsx +223 -0
- package/src/layout/docsComponents/DocsHeader/DocsHeader.tsx +188 -0
- package/src/layout/docsComponents/DocsSideMenuTree/DocsSideMenuTree.tsx +229 -0
- package/src/layout/docsComponents/index.tsx +28 -0
- package/src/layout/docsLayout.tsx +123 -0
- package/src/layout/layout.module.css +65 -0
- package/src/layout/layout.tsx +177 -0
- package/src/types/docsLayout.type.ts +7 -0
- package/src/types/index.ts +28 -0
- package/src/types/layout.type.ts +32 -0
- package/src/types/openApi.ts +109 -0
- package/src/types/transformedOpenApi.ts +52 -0
- package/src/utils/index.ts +15 -0
- package/src/validator/form.scheme.ts +96 -0
- package/tsconfig.json +33 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { JSX, useEffect, useState } from 'react'
|
|
2
|
+
import { Alert, Button } from 'digitinary-ui'
|
|
3
|
+
import MethodsAccordion from '../components/MethodAccordion/MethodAccordion'
|
|
4
|
+
import styles from './layout.module.css'
|
|
5
|
+
import InfoForm from '../components/InfoForm/InfoForm'
|
|
6
|
+
import SectionHead from '../components/SectionHead/SectionHead'
|
|
7
|
+
import { transformOpenApiObject, transformOpenApiObjectToOrigin } from '../helpers/layout.helper'
|
|
8
|
+
import { OpenAPIFile } from '../types/openApi'
|
|
9
|
+
import LivePreview from '../components/LivePreview/LivePreview'
|
|
10
|
+
import { FormikProvider, useFormik } from 'formik'
|
|
11
|
+
import { schemaValidation } from '../validator/form.scheme'
|
|
12
|
+
import { TransformedOpenApi } from '@entities/transformedOpenApi'
|
|
13
|
+
import { methodColorMapping } from '../constants/index'
|
|
14
|
+
import CommonDialog from '../components/dialog'
|
|
15
|
+
|
|
16
|
+
interface ILayoutProps {
|
|
17
|
+
openApiJson?: OpenAPIFile
|
|
18
|
+
handleSave?: (values: unknown) => unknown
|
|
19
|
+
setIsFormDirty?: any
|
|
20
|
+
openApiErrors?: any
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Layout = ({
|
|
24
|
+
openApiJson,
|
|
25
|
+
handleSave,
|
|
26
|
+
setIsFormDirty,
|
|
27
|
+
openApiErrors,
|
|
28
|
+
}: ILayoutProps): JSX.Element => {
|
|
29
|
+
const clonedOpenApiJson = structuredClone(openApiJson)
|
|
30
|
+
const transformedOpenApi = transformOpenApiObject(clonedOpenApiJson)
|
|
31
|
+
const formik = useFormik<TransformedOpenApi>({
|
|
32
|
+
initialValues: structuredClone(transformedOpenApi),
|
|
33
|
+
validationSchema: schemaValidation,
|
|
34
|
+
validateOnMount: true,
|
|
35
|
+
onSubmit: (values, { validateForm, resetForm, setSubmitting }) => {
|
|
36
|
+
// Handle save logic
|
|
37
|
+
try {
|
|
38
|
+
const originalOpenApiForm = transformOpenApiObjectToOrigin(values)
|
|
39
|
+
handleSave(originalOpenApiForm)
|
|
40
|
+
resetForm({
|
|
41
|
+
values: values, // You can reset it to the same values if you want
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
validateForm(values)
|
|
45
|
+
} catch (err) {
|
|
46
|
+
setSubmitting(false)
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
const { dirty, isValid, isSubmitting, values, setFieldValue, handleSubmit, errors } = formik
|
|
51
|
+
const [isPublishDialogOpen, setIsPublishDialogOpen] = useState(false)
|
|
52
|
+
|
|
53
|
+
const [openMethodIndex, setOpenMethodIndex] = useState<number | null>(null)
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (setIsFormDirty) {
|
|
57
|
+
setIsFormDirty(dirty)
|
|
58
|
+
}
|
|
59
|
+
}, [dirty])
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<div className={styles.docsLayout}>
|
|
63
|
+
{dirty && (
|
|
64
|
+
<Alert className={styles.apiDocAlert} color="warning" severity="warning">
|
|
65
|
+
There are changes you made may not be saved
|
|
66
|
+
</Alert>
|
|
67
|
+
)}
|
|
68
|
+
<div className={styles.layoutContainer}>
|
|
69
|
+
<div className={`${styles.editorSide} ${styles.docSide}`}>
|
|
70
|
+
<SectionHead
|
|
71
|
+
className={styles.editorSectionHead_title}
|
|
72
|
+
text={
|
|
73
|
+
<div className={styles.editorSectionHead_content}>
|
|
74
|
+
API Documentation
|
|
75
|
+
<Button
|
|
76
|
+
className={styles.methodForm_submitBtn}
|
|
77
|
+
size="medium"
|
|
78
|
+
fullWidth={false}
|
|
79
|
+
type="submit"
|
|
80
|
+
variant="contained"
|
|
81
|
+
color="primary"
|
|
82
|
+
onClick={() => setIsPublishDialogOpen(true)}
|
|
83
|
+
disabled={!isValid || isSubmitting || !dirty}
|
|
84
|
+
>
|
|
85
|
+
Save
|
|
86
|
+
</Button>
|
|
87
|
+
</div>
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
<FormikProvider value={formik}>
|
|
91
|
+
<InfoForm />
|
|
92
|
+
</FormikProvider>
|
|
93
|
+
<SectionHead className={styles.editorSectionHead} text="Endpoints" />
|
|
94
|
+
<FormikProvider value={formik}>
|
|
95
|
+
{values.paths.map((path, pathIndex) => (
|
|
96
|
+
<>
|
|
97
|
+
{path.methods
|
|
98
|
+
.sort(
|
|
99
|
+
(a, b) => methodColorMapping[a.type].order - methodColorMapping[b.type].order
|
|
100
|
+
)
|
|
101
|
+
.map((method, methodIndex) => (
|
|
102
|
+
<MethodsAccordion
|
|
103
|
+
tags={values.tags}
|
|
104
|
+
method={method}
|
|
105
|
+
path={path.path}
|
|
106
|
+
setFieldValue={(key, value) => {
|
|
107
|
+
const h = `paths[${pathIndex}].methods[${methodIndex}].${key}`
|
|
108
|
+
setFieldValue(h, value)
|
|
109
|
+
}}
|
|
110
|
+
isOpen={openMethodIndex === parseInt(`${pathIndex}${methodIndex}`)}
|
|
111
|
+
setIsOpen={(open) => setOpenMethodIndex(open ? parseInt(`${pathIndex}${methodIndex}`) : null)}
|
|
112
|
+
errors={(formik.errors.paths?.[pathIndex] as any)?.methods?.[methodIndex]}
|
|
113
|
+
/>
|
|
114
|
+
))}
|
|
115
|
+
</>
|
|
116
|
+
))}
|
|
117
|
+
</FormikProvider>
|
|
118
|
+
</div>
|
|
119
|
+
<div className={`${styles.livePreviewSide} ${styles.docSide}`}>
|
|
120
|
+
{transformedOpenApi && (
|
|
121
|
+
<FormikProvider value={formik}>
|
|
122
|
+
<LivePreview transformedData={transformedOpenApi} openApiErrors={openApiErrors} />
|
|
123
|
+
</FormikProvider>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
<CommonDialog
|
|
128
|
+
status="warning"
|
|
129
|
+
content={
|
|
130
|
+
<>
|
|
131
|
+
<h5
|
|
132
|
+
style={{
|
|
133
|
+
fontWeight: 600,
|
|
134
|
+
fontSize: '1.5rem',
|
|
135
|
+
lineHeight: '1.875rem',
|
|
136
|
+
color: '#FAAD14',
|
|
137
|
+
textAlign: 'center',
|
|
138
|
+
margin: 0,
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
Publish Changes
|
|
142
|
+
</h5>
|
|
143
|
+
<p
|
|
144
|
+
style={{
|
|
145
|
+
textAlign: 'center',
|
|
146
|
+
fontWeight: 400,
|
|
147
|
+
fontSize: '1rem',
|
|
148
|
+
lineHeight: '1.4375rem',
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
Are you sure to Publish the changes?
|
|
152
|
+
</p>
|
|
153
|
+
</>
|
|
154
|
+
}
|
|
155
|
+
onSubmit={{
|
|
156
|
+
onClick: () => {
|
|
157
|
+
handleSubmit()
|
|
158
|
+
setIsPublishDialogOpen(false)
|
|
159
|
+
},
|
|
160
|
+
text: 'Publish',
|
|
161
|
+
color: 'warning',
|
|
162
|
+
fullWidth: true,
|
|
163
|
+
}}
|
|
164
|
+
onCancel={{
|
|
165
|
+
text: 'Cancel',
|
|
166
|
+
color: 'action',
|
|
167
|
+
fullWidth: true,
|
|
168
|
+
variant: 'outlined',
|
|
169
|
+
}}
|
|
170
|
+
onClose={() => setIsPublishDialogOpen(false)}
|
|
171
|
+
open={isPublishDialogOpen}
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export default Layout
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { OpenAPIFile } from './openApi'
|
|
2
|
+
|
|
3
|
+
export interface ApiSpecModel {
|
|
4
|
+
apiSpecId: string
|
|
5
|
+
contextPath: string
|
|
6
|
+
apiVersions: {
|
|
7
|
+
addVersionToContextPath: boolean
|
|
8
|
+
apiSpecId: string
|
|
9
|
+
name: string
|
|
10
|
+
metaData: {
|
|
11
|
+
version: string
|
|
12
|
+
}
|
|
13
|
+
}[]
|
|
14
|
+
associatedProduct: {
|
|
15
|
+
availableOnDevPortal: boolean
|
|
16
|
+
name: string
|
|
17
|
+
premium: boolean
|
|
18
|
+
productId: number
|
|
19
|
+
}
|
|
20
|
+
metaData: {
|
|
21
|
+
version: string
|
|
22
|
+
apiVersionOf: string
|
|
23
|
+
openApiJson: OpenAPIFile
|
|
24
|
+
tags: string[]
|
|
25
|
+
createdDateTime: string
|
|
26
|
+
lastUpdatedDateTime: string
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HTTPMethod } from './openApi'
|
|
2
|
+
|
|
3
|
+
export type TransformedMethod = {
|
|
4
|
+
type: HTTPMethod
|
|
5
|
+
tags: string[]
|
|
6
|
+
summary?: string
|
|
7
|
+
parameters: any
|
|
8
|
+
requestBody: {
|
|
9
|
+
content: {
|
|
10
|
+
contentType: string
|
|
11
|
+
schema: {
|
|
12
|
+
properties: string
|
|
13
|
+
type: string
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
responses: {
|
|
18
|
+
code: string
|
|
19
|
+
content: {
|
|
20
|
+
contentType?: string
|
|
21
|
+
schema?: unknown
|
|
22
|
+
}
|
|
23
|
+
headers: any
|
|
24
|
+
}[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type TransformedPath = {
|
|
28
|
+
path: string
|
|
29
|
+
methods: TransformedMethod[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type TransformedPathsArray = TransformedPath[]
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export interface OpenAPIFile {
|
|
2
|
+
openapi: string
|
|
3
|
+
info: {
|
|
4
|
+
title: string
|
|
5
|
+
description: string
|
|
6
|
+
version: string
|
|
7
|
+
}
|
|
8
|
+
servers?: {
|
|
9
|
+
url: string
|
|
10
|
+
description?: string
|
|
11
|
+
}[]
|
|
12
|
+
paths: {
|
|
13
|
+
[path: string]: Partial<
|
|
14
|
+
Record<
|
|
15
|
+
HTTPMethod,
|
|
16
|
+
{
|
|
17
|
+
tags: string[]
|
|
18
|
+
responses: Responses
|
|
19
|
+
summary?: string
|
|
20
|
+
description?: string
|
|
21
|
+
parameters?: Parameter[]
|
|
22
|
+
requestBody?: RequestBody
|
|
23
|
+
}
|
|
24
|
+
>
|
|
25
|
+
>
|
|
26
|
+
}
|
|
27
|
+
components?: {
|
|
28
|
+
schemas?: {
|
|
29
|
+
[schemaName: string]: Schema
|
|
30
|
+
}
|
|
31
|
+
securitySchemes?: {
|
|
32
|
+
[schemeName: string]: SecurityScheme
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
security?: {
|
|
36
|
+
[schemeName: string]: string[]
|
|
37
|
+
}[]
|
|
38
|
+
tags?: {
|
|
39
|
+
name: string
|
|
40
|
+
description?: string
|
|
41
|
+
externalDocs?: {
|
|
42
|
+
url: string
|
|
43
|
+
description: string
|
|
44
|
+
}[]
|
|
45
|
+
}[]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface Tags {
|
|
49
|
+
name: string
|
|
50
|
+
description?: string
|
|
51
|
+
externalDocs?: {
|
|
52
|
+
url: string
|
|
53
|
+
description: string
|
|
54
|
+
}[]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface Parameter {
|
|
58
|
+
name: string
|
|
59
|
+
in: 'query' | 'header' | 'path' | 'cookie'
|
|
60
|
+
description?: string
|
|
61
|
+
required: boolean
|
|
62
|
+
schema: Schema
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface RequestBody {
|
|
66
|
+
description?: string
|
|
67
|
+
required: boolean
|
|
68
|
+
content: {
|
|
69
|
+
[contentType: string]: {
|
|
70
|
+
schema: Schema
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface Responses {
|
|
76
|
+
[statusCode: string]: {
|
|
77
|
+
description: string
|
|
78
|
+
headers?: any
|
|
79
|
+
content?: {
|
|
80
|
+
[contentType: string]: {
|
|
81
|
+
schema: Schema
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Schema {
|
|
88
|
+
type?: string
|
|
89
|
+
format?: string
|
|
90
|
+
properties?: {
|
|
91
|
+
[propertyName: string]: Schema
|
|
92
|
+
}
|
|
93
|
+
items?: Schema
|
|
94
|
+
enum?: string[]
|
|
95
|
+
required?: string[]
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface SecurityScheme {
|
|
99
|
+
type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect'
|
|
100
|
+
description?: string
|
|
101
|
+
name?: string
|
|
102
|
+
in?: 'query' | 'header' | 'cookie'
|
|
103
|
+
scheme?: string
|
|
104
|
+
bearerFormat?: string
|
|
105
|
+
flows?: any
|
|
106
|
+
openIdConnectUrl?: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type HTTPMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { TransformedPathsArray } from "./layout.type";
|
|
2
|
+
|
|
3
|
+
export interface TransformedOpenApi {
|
|
4
|
+
openapi: string;
|
|
5
|
+
info: {
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
servers?: {
|
|
11
|
+
url: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
}[];
|
|
14
|
+
paths: TransformedPathsArray;
|
|
15
|
+
components?: {
|
|
16
|
+
schemas?: {
|
|
17
|
+
[schemaName: string]: Schema;
|
|
18
|
+
};
|
|
19
|
+
securitySchemes?: {
|
|
20
|
+
[schemeName: string]: SecurityScheme;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
security?: {
|
|
24
|
+
[schemeName: string]: string[];
|
|
25
|
+
}[];
|
|
26
|
+
tags?: {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Schema {
|
|
33
|
+
type?: string;
|
|
34
|
+
format?: string;
|
|
35
|
+
properties?: {
|
|
36
|
+
[propertyName: string]: Schema;
|
|
37
|
+
};
|
|
38
|
+
items?: Schema;
|
|
39
|
+
enum?: string[];
|
|
40
|
+
required?: string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface SecurityScheme {
|
|
44
|
+
type: "apiKey" | "http" | "oauth2" | "openIdConnect";
|
|
45
|
+
description?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
in?: "query" | "header" | "cookie";
|
|
48
|
+
scheme?: string;
|
|
49
|
+
bearerFormat?: string;
|
|
50
|
+
flows?: any;
|
|
51
|
+
openIdConnectUrl?: string;
|
|
52
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { toast } from "react-toastify"
|
|
2
|
+
|
|
3
|
+
export const copyToClipboard = async (text: string) => {
|
|
4
|
+
try {
|
|
5
|
+
await navigator.clipboard.writeText(text)
|
|
6
|
+
toast.success('Copied to your clipboard!')
|
|
7
|
+
} catch (err) {
|
|
8
|
+
return err
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const capitalizeFirstLetter = (text: string) => {
|
|
13
|
+
if (!text) return ''
|
|
14
|
+
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase()
|
|
15
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as yup from 'yup'
|
|
2
|
+
export const schemaValidation = yup.object({
|
|
3
|
+
openapi: yup.string().required(),
|
|
4
|
+
info: yup
|
|
5
|
+
.object({
|
|
6
|
+
title: yup.string().trim().required('API Name is required.'),
|
|
7
|
+
description: yup.string().trim().required('API Description is required.'),
|
|
8
|
+
version: yup.string().required('API Version is required'),
|
|
9
|
+
})
|
|
10
|
+
.required(),
|
|
11
|
+
servers: yup
|
|
12
|
+
.array(
|
|
13
|
+
yup.object({
|
|
14
|
+
url: yup
|
|
15
|
+
.string()
|
|
16
|
+
.required()
|
|
17
|
+
.test(
|
|
18
|
+
'is-url-or-slash',
|
|
19
|
+
'Must be a valid URL or "/"',
|
|
20
|
+
(value) => value === '/' || yup.string().url().isValidSync(value)
|
|
21
|
+
),
|
|
22
|
+
description: yup.string().optional(),
|
|
23
|
+
})
|
|
24
|
+
)
|
|
25
|
+
.optional(),
|
|
26
|
+
paths: yup
|
|
27
|
+
.array()
|
|
28
|
+
.of(
|
|
29
|
+
yup.object().shape({
|
|
30
|
+
path: yup.string().required(),
|
|
31
|
+
methods: yup
|
|
32
|
+
.array()
|
|
33
|
+
.of(
|
|
34
|
+
yup.object().shape({
|
|
35
|
+
summary: yup.string().trim().required('Endpoint Name is required.'),
|
|
36
|
+
description: yup.string().trim().optional(),
|
|
37
|
+
type: yup.string().optional(),
|
|
38
|
+
tags: yup.array().of(yup.string()).optional(),
|
|
39
|
+
requestBody: yup.mixed().optional(),
|
|
40
|
+
})
|
|
41
|
+
)
|
|
42
|
+
.required(),
|
|
43
|
+
})
|
|
44
|
+
)
|
|
45
|
+
.required(),
|
|
46
|
+
components: yup
|
|
47
|
+
.object({
|
|
48
|
+
schemas: yup
|
|
49
|
+
.lazy((value) =>
|
|
50
|
+
yup.object(
|
|
51
|
+
value
|
|
52
|
+
? Object.keys(value).reduce((acc, key) => {
|
|
53
|
+
acc[key] = yup.object({
|
|
54
|
+
type: yup.string().optional(),
|
|
55
|
+
format: yup.string().optional(),
|
|
56
|
+
properties: yup
|
|
57
|
+
.lazy((props) =>
|
|
58
|
+
yup.object(
|
|
59
|
+
props
|
|
60
|
+
? Object.keys(props).reduce((acc, propKey) => {
|
|
61
|
+
acc[propKey] = yup.mixed()
|
|
62
|
+
return acc
|
|
63
|
+
}, {})
|
|
64
|
+
: {}
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
.optional(),
|
|
68
|
+
items: yup.mixed().optional(),
|
|
69
|
+
enum: yup.array(yup.string()).optional(),
|
|
70
|
+
required: yup.array(yup.string()).optional(),
|
|
71
|
+
})
|
|
72
|
+
return acc
|
|
73
|
+
}, {})
|
|
74
|
+
: {}
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
.optional(),
|
|
78
|
+
securitySchemes: yup.object().optional(),
|
|
79
|
+
})
|
|
80
|
+
.optional(),
|
|
81
|
+
security: yup
|
|
82
|
+
.array(
|
|
83
|
+
yup.object().shape({
|
|
84
|
+
schemeName: yup.array(yup.string()).optional(),
|
|
85
|
+
})
|
|
86
|
+
)
|
|
87
|
+
.optional(),
|
|
88
|
+
tags: yup
|
|
89
|
+
.array(
|
|
90
|
+
yup.object({
|
|
91
|
+
name: yup.string().required(),
|
|
92
|
+
description: yup.string().optional(),
|
|
93
|
+
})
|
|
94
|
+
)
|
|
95
|
+
.optional(),
|
|
96
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"target": "ES6",
|
|
6
|
+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"declarationDir": "dist/types",
|
|
9
|
+
"jsx": "react-jsx",
|
|
10
|
+
"strict": false,
|
|
11
|
+
"moduleResolution": "node",
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"importHelpers": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"plugins": [
|
|
18
|
+
{
|
|
19
|
+
"name": "typescript-plugin-css-modules"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"baseUrl": "./",
|
|
23
|
+
"paths": {
|
|
24
|
+
"@components/*": ["src/components/*"],
|
|
25
|
+
"@icons": ["src/assets/icons"],
|
|
26
|
+
"@constants/*": ["src/constants/*"],
|
|
27
|
+
"@entities/*": ["src/types/*"],
|
|
28
|
+
"@helpers/*": ["src/helpers/*"]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"include": ["src", "src/global.d.ts"], // Add "src/global.d.ts" here
|
|
32
|
+
"exclude": ["node_modules", "dist"]
|
|
33
|
+
}
|