@stoplight/elements-core 9.0.12-beta-0.2 → 9.0.12-beta-0.4
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/package.json +14 -74
- package/.storybook/main.js +0 -6
- package/.storybook/manager.js +0 -1
- package/.storybook/preview.jsx +0 -50
- package/dist/LICENSE +0 -190
- package/dist/README.md +0 -1
- package/dist/package.json +0 -64
- package/jest.config.js +0 -10
- package/src/__fixtures__/articles/basic.md +0 -10
- package/src/__fixtures__/articles/kitchen-sink.md +0 -318
- package/src/__fixtures__/articles/long-page-heading.md +0 -955
- package/src/__fixtures__/articles/multiple-try-its.md +0 -54
- package/src/__fixtures__/articles/schema-with-refs.ts +0 -82
- package/src/__fixtures__/http-request.json +0 -11
- package/src/__fixtures__/models/model-with-no-examples.json +0 -15
- package/src/__fixtures__/models/model-with-one-example.json +0 -23
- package/src/__fixtures__/models/model-with-three-examples.json +0 -35
- package/src/__fixtures__/operations/application-octet-stream-post.ts +0 -39
- package/src/__fixtures__/operations/base64-file-upload.ts +0 -43
- package/src/__fixtures__/operations/big-response.ts +0 -4690
- package/src/__fixtures__/operations/bundled-parameter.ts +0 -128
- package/src/__fixtures__/operations/empty-response.ts +0 -15
- package/src/__fixtures__/operations/examples-request-body.ts +0 -135
- package/src/__fixtures__/operations/head-todos.ts +0 -49
- package/src/__fixtures__/operations/invalid-response-example.ts +0 -45
- package/src/__fixtures__/operations/multipart-formdata-post.ts +0 -61
- package/src/__fixtures__/operations/operation-minimal.ts +0 -11
- package/src/__fixtures__/operations/operation-parameters.ts +0 -337
- package/src/__fixtures__/operations/operation-with-examples.ts +0 -113
- package/src/__fixtures__/operations/operation-without-servers.ts +0 -16
- package/src/__fixtures__/operations/patch-todos.ts +0 -49
- package/src/__fixtures__/operations/put-todos.ts +0 -862
- package/src/__fixtures__/operations/referenced-body.ts +0 -62
- package/src/__fixtures__/operations/request-body-empty-schema.ts +0 -35
- package/src/__fixtures__/operations/request-body.ts +0 -62
- package/src/__fixtures__/operations/securedOperation.ts +0 -118
- package/src/__fixtures__/operations/security-basic.ts +0 -24
- package/src/__fixtures__/operations/security-bearer.ts +0 -25
- package/src/__fixtures__/operations/simple-get.ts +0 -17
- package/src/__fixtures__/operations/simple.ts +0 -103
- package/src/__fixtures__/operations/string-numeric-enums.ts +0 -32
- package/src/__fixtures__/operations/urlencoded-post-oneof.ts +0 -81
- package/src/__fixtures__/operations/urlencoded-post.ts +0 -54
- package/src/__fixtures__/operations/vendor-extensions.ts +0 -337
- package/src/__fixtures__/operations/with-url-variables.ts +0 -47
- package/src/__fixtures__/operations/x-code-samples.ts +0 -348
- package/src/__fixtures__/schemas/circular.ts +0 -1906
- package/src/__fixtures__/schemas/contact.json +0 -293
- package/src/__fixtures__/schemas/media-entry.json +0 -69
- package/src/__fixtures__/schemas/simple.json +0 -27
- package/src/__fixtures__/schemas/todo-full.v1.json +0 -35
- package/src/__fixtures__/schemas/todo-partial.v1.json +0 -14
- package/src/__fixtures__/schemas/user.v1.json +0 -17
- package/src/__fixtures__/security-schemes/index.ts +0 -38
- package/src/__fixtures__/services/petstore.ts +0 -167
- package/src/__fixtures__/services/with-unnamed-servers.ts +0 -38
- package/src/__fixtures__/services/with-url-variables.ts +0 -83
- package/src/__fixtures__/services/without-origin.ts +0 -20
- package/src/__fixtures__/table-of-contents/nested.ts +0 -44
- package/src/__fixtures__/table-of-contents/studio-template.ts +0 -100
- package/src/__fixtures__/table-of-contents/studio.ts +0 -559
- package/src/components/Docs/Article/Article.spec.tsx +0 -38
- package/src/components/Docs/Article/Article.stories.tsx +0 -17
- package/src/components/Docs/Article/index.tsx +0 -38
- package/src/components/Docs/Docs.stories.tsx +0 -33
- package/src/components/Docs/Docs.tsx +0 -272
- package/src/components/Docs/HttpOperation/Badges.tsx +0 -49
- package/src/components/Docs/HttpOperation/Body.tsx +0 -115
- package/src/components/Docs/HttpOperation/Callbacks.tsx +0 -89
- package/src/components/Docs/HttpOperation/HttpOperation.spec.tsx +0 -787
- package/src/components/Docs/HttpOperation/HttpOperation.stories.ts +0 -14
- package/src/components/Docs/HttpOperation/HttpOperation.tsx +0 -260
- package/src/components/Docs/HttpOperation/LazySchemaTreePreviewer.tsx +0 -651
- package/src/components/Docs/HttpOperation/Parameters.spec.tsx +0 -101
- package/src/components/Docs/HttpOperation/Parameters.tsx +0 -118
- package/src/components/Docs/HttpOperation/Request.tsx +0 -152
- package/src/components/Docs/HttpOperation/Responses.tsx +0 -301
- package/src/components/Docs/HttpOperation/index.ts +0 -1
- package/src/components/Docs/HttpService/AdditionalInfo.stories.ts +0 -48
- package/src/components/Docs/HttpService/AdditionalInfo.tsx +0 -61
- package/src/components/Docs/HttpService/ExportButton.tsx +0 -35
- package/src/components/Docs/HttpService/HttpService.spec.tsx +0 -429
- package/src/components/Docs/HttpService/HttpService.stories.ts +0 -14
- package/src/components/Docs/HttpService/HttpService.tsx +0 -99
- package/src/components/Docs/HttpService/SecuritySchemes.tsx +0 -82
- package/src/components/Docs/HttpService/ServerInfo.tsx +0 -196
- package/src/components/Docs/HttpService/index.ts +0 -1
- package/src/components/Docs/Model/Model.spec.tsx +0 -241
- package/src/components/Docs/Model/Model.stories.tsx +0 -16
- package/src/components/Docs/Model/Model.tsx +0 -192
- package/src/components/Docs/Model/index.ts +0 -1
- package/src/components/Docs/NodeVendorExtensions.tsx +0 -55
- package/src/components/Docs/Sections.tsx +0 -54
- package/src/components/Docs/Security/PanelContent.tsx +0 -38
- package/src/components/Docs/Security/index.ts +0 -1
- package/src/components/Docs/Skeleton.tsx +0 -12
- package/src/components/Docs/TwoColumnLayout.tsx +0 -27
- package/src/components/Docs/index.ts +0 -1
- package/src/components/Docs/story-helper.ts +0 -46
- package/src/components/Docs/story-renderer-helper.tsx +0 -56
- package/src/components/Layout/MobileTopNav.tsx +0 -78
- package/src/components/Layout/ResponsiveSidebarLayout.tsx +0 -175
- package/src/components/Layout/SidebarLayout.tsx +0 -107
- package/src/components/LinkHeading.tsx +0 -21
- package/src/components/LoadMore.tsx +0 -20
- package/src/components/Loading/Loading.tsx +0 -9
- package/src/components/Logo.tsx +0 -25
- package/src/components/MarkdownViewer/CustomComponents/CodeComponent.spec.ts +0 -90
- package/src/components/MarkdownViewer/CustomComponents/CodeComponent.tsx +0 -164
- package/src/components/MarkdownViewer/CustomComponents/Provider.tsx +0 -20
- package/src/components/MarkdownViewer/CustomComponents/ReactRouterLink.tsx +0 -27
- package/src/components/MarkdownViewer/CustomComponents/ResolvedImage.tsx +0 -86
- package/src/components/MarkdownViewer/CustomComponents/ScrollToHashElement.tsx +0 -96
- package/src/components/MarkdownViewer/MarkdownViewer.spec.tsx +0 -170
- package/src/components/MarkdownViewer/index.tsx +0 -10
- package/src/components/NonIdealState.tsx +0 -20
- package/src/components/PoweredByLink.tsx +0 -30
- package/src/components/RequestSamples/RequestSamples.stories.tsx +0 -67
- package/src/components/RequestSamples/RequestSamples.tsx +0 -246
- package/src/components/RequestSamples/__tests__/RequestSamples.test.tsx +0 -131
- package/src/components/RequestSamples/__tests__/__snapshots__/convertRequestToSample.spec.ts.snap +0 -746
- package/src/components/RequestSamples/__tests__/convertRequestToSample.spec.ts +0 -118
- package/src/components/RequestSamples/convertRequestToSample.ts +0 -56
- package/src/components/RequestSamples/extractCodeSamples.ts +0 -50
- package/src/components/RequestSamples/index.ts +0 -2
- package/src/components/RequestSamples/requestSampleConfigs.ts +0 -182
- package/src/components/ResponseExamples/ResponseExamples.spec.tsx +0 -121
- package/src/components/ResponseExamples/ResponseExamples.stories.tsx +0 -21
- package/src/components/ResponseExamples/ResponseExamples.tsx +0 -79
- package/src/components/TableOfContents/TableOfContents.spec.tsx +0 -301
- package/src/components/TableOfContents/TableOfContents.stories.tsx +0 -121
- package/src/components/TableOfContents/TableOfContents.tsx +0 -406
- package/src/components/TableOfContents/constants.ts +0 -45
- package/src/components/TableOfContents/index.ts +0 -2
- package/src/components/TableOfContents/types.ts +0 -51
- package/src/components/TableOfContents/utils.ts +0 -84
- package/src/components/TryIt/Auth/APIKeyAuth.tsx +0 -19
- package/src/components/TryIt/Auth/Auth.tsx +0 -169
- package/src/components/TryIt/Auth/AuthTokenInput.tsx +0 -37
- package/src/components/TryIt/Auth/BasicAuth.tsx +0 -62
- package/src/components/TryIt/Auth/BearerAuth.tsx +0 -19
- package/src/components/TryIt/Auth/DigestAuth.tsx +0 -35
- package/src/components/TryIt/Auth/OAuth2Auth.tsx +0 -19
- package/src/components/TryIt/Auth/authentication-utils.ts +0 -113
- package/src/components/TryIt/Body/BinaryBody.tsx +0 -52
- package/src/components/TryIt/Body/FormDataBody.tsx +0 -145
- package/src/components/TryIt/Body/RequestBody.tsx +0 -71
- package/src/components/TryIt/Body/__tests__/BinaryBody.test.tsx +0 -29
- package/src/components/TryIt/Body/__tests__/FormDataBody.test.tsx +0 -94
- package/src/components/TryIt/Body/request-body-utils.ts +0 -127
- package/src/components/TryIt/Body/useTextRequestBodyState.ts +0 -27
- package/src/components/TryIt/Mocking/MockingButton.tsx +0 -98
- package/src/components/TryIt/Mocking/mocking-utils.ts +0 -56
- package/src/components/TryIt/Mocking/useMockingOptions.ts +0 -6
- package/src/components/TryIt/Parameters/FileUploadParameterEditors.tsx +0 -62
- package/src/components/TryIt/Parameters/OperationParameters.tsx +0 -39
- package/src/components/TryIt/Parameters/ParameterEditor.tsx +0 -118
- package/src/components/TryIt/Parameters/__tests__/parameter-utils.spec.ts +0 -60
- package/src/components/TryIt/Parameters/parameter-utils.spec.ts +0 -118
- package/src/components/TryIt/Parameters/parameter-utils.ts +0 -179
- package/src/components/TryIt/Parameters/useOperationParameters.ts +0 -60
- package/src/components/TryIt/Response/ReponseCodeViewer.tsx +0 -28
- package/src/components/TryIt/Response/Response.spec.tsx +0 -174
- package/src/components/TryIt/Response/Response.tsx +0 -172
- package/src/components/TryIt/Response/hooks/useLineCount.ts +0 -7
- package/src/components/TryIt/Servers/ServerVariables.tsx +0 -33
- package/src/components/TryIt/Servers/ServersDropdown.tsx +0 -53
- package/src/components/TryIt/Servers/VariableEditor.tsx +0 -51
- package/src/components/TryIt/Servers/useServerVariables.ts +0 -19
- package/src/components/TryIt/TryIt.spec.tsx +0 -1511
- package/src/components/TryIt/TryIt.stories.tsx +0 -77
- package/src/components/TryIt/TryIt.tsx +0 -384
- package/src/components/TryIt/TryItWithRequestSamples.spec.tsx +0 -143
- package/src/components/TryIt/TryItWithRequestSamples.stories.tsx +0 -32
- package/src/components/TryIt/TryItWithRequestSamples.tsx +0 -42
- package/src/components/TryIt/build-request.spec.ts +0 -213
- package/src/components/TryIt/build-request.ts +0 -357
- package/src/components/TryIt/chosenServer.ts +0 -5
- package/src/components/TryIt/index.ts +0 -3
- package/src/components/__tests__/LinkHeading.spec.tsx +0 -125
- package/src/constants.ts +0 -176
- package/src/containers/MockingProvider.tsx +0 -23
- package/src/context/InlineRefResolver.spec.tsx +0 -183
- package/src/context/InlineRefResolver.tsx +0 -94
- package/src/context/Options.tsx +0 -27
- package/src/context/Persistence.tsx +0 -24
- package/src/context/RouterType.tsx +0 -9
- package/src/core.css +0 -97
- package/src/hoc/utils.ts +0 -5
- package/src/hoc/withMosaicProvider.spec.tsx +0 -48
- package/src/hoc/withMosaicProvider.tsx +0 -28
- package/src/hoc/withQueryClientProvider.spec.tsx +0 -38
- package/src/hoc/withQueryClientProvider.tsx +0 -35
- package/src/hoc/withRouter.tsx +0 -71
- package/src/hooks/useBundleRefsIntoDocument.ts +0 -60
- package/src/hooks/useFirstRender.ts +0 -8
- package/src/hooks/useIsCompact.ts +0 -26
- package/src/hooks/useParsedData.ts +0 -99
- package/src/hooks/useParsedValue.ts +0 -19
- package/src/hooks/useResponsiveLayout.tsx +0 -51
- package/src/hooks/useRouter.tsx +0 -31
- package/src/hooks/useUniqueId.ts +0 -4
- package/src/index.ts +0 -48
- package/src/styled.tsx +0 -22
- package/src/styles.css +0 -4
- package/src/types.ts +0 -170
- package/src/utils/__tests__/securitySchemes.spec.ts +0 -137
- package/src/utils/exampleGeneration/exampleGeneration.spec.tsx +0 -18
- package/src/utils/exampleGeneration/exampleGeneration.ts +0 -110
- package/src/utils/fileToBase64.ts +0 -11
- package/src/utils/guards.ts +0 -48
- package/src/utils/headers.ts +0 -316
- package/src/utils/http-spec/IServer.ts +0 -100
- package/src/utils/http-spec/__tests__/IServer.spec.ts +0 -51
- package/src/utils/http-spec/examples.ts +0 -5
- package/src/utils/http.ts +0 -9
- package/src/utils/jotai/persistAtom.ts +0 -31
- package/src/utils/node.ts +0 -19
- package/src/utils/oas/__tests__/security.spec.ts +0 -18
- package/src/utils/oas/security.ts +0 -76
- package/src/utils/ref-resolving/ReferenceResolver.ts +0 -29
- package/src/utils/ref-resolving/resolvedObject.test.ts +0 -415
- package/src/utils/ref-resolving/resolvedObject.ts +0 -109
- package/src/utils/securitySchemes.ts +0 -117
- package/src/utils/string.ts +0 -15
- package/src/utils/tests/chooseOption.ts +0 -7
- package/src/web-components/createElementClass.ts +0 -154
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -7
- /package/{dist/__fixtures__ → __fixtures__}/articles/schema-with-refs.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/application-octet-stream-post.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/base64-file-upload.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/big-response.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/examples-request-body.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/head-todos.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/multipart-formdata-post.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-minimal.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-parameters.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-with-examples.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-without-servers.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/patch-todos.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/put-todos.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/referenced-body.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/request-body-empty-schema.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/request-body.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/securedOperation.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/security-basic.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/security-bearer.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/simple-get.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/string-numeric-enums.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/urlencoded-post-oneof.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/urlencoded-post.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/with-url-variables.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/security-schemes/index.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/petstore.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/with-unnamed-servers.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/with-url-variables.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/without-origin.d.ts +0 -0
- /package/{dist/components → components}/Docs/Article/Article.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/Article/Article.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/Article/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/Docs.d.ts +0 -0
- /package/{dist/components → components}/Docs/Docs.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Badges.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Body.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Callbacks.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/HttpOperation.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/HttpOperation.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/HttpOperation.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/LazySchemaTreePreviewer.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Parameters.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Parameters.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Request.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Responses.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/AdditionalInfo.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/AdditionalInfo.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/ExportButton.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/HttpService.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/HttpService.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/HttpService.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/SecuritySchemes.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/ServerInfo.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/Model.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/Model.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/Model.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/NodeVendorExtensions.d.ts +0 -0
- /package/{dist/components → components}/Docs/Sections.d.ts +0 -0
- /package/{dist/components → components}/Docs/Security/PanelContent.d.ts +0 -0
- /package/{dist/components → components}/Docs/Security/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/Skeleton.d.ts +0 -0
- /package/{dist/components → components}/Docs/TwoColumnLayout.d.ts +0 -0
- /package/{dist/components → components}/Docs/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/story-helper.d.ts +0 -0
- /package/{dist/components → components}/Docs/story-renderer-helper.d.ts +0 -0
- /package/{dist/components → components}/Layout/MobileTopNav.d.ts +0 -0
- /package/{dist/components → components}/Layout/ResponsiveSidebarLayout.d.ts +0 -0
- /package/{dist/components → components}/Layout/SidebarLayout.d.ts +0 -0
- /package/{dist/components → components}/LinkHeading.d.ts +0 -0
- /package/{dist/components → components}/LoadMore.d.ts +0 -0
- /package/{dist/components → components}/Loading/Loading.d.ts +0 -0
- /package/{dist/components → components}/Logo.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/CodeComponent.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/CodeComponent.spec.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/Provider.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/ReactRouterLink.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/ResolvedImage.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/ScrollToHashElement.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/MarkdownViewer.spec.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/index.d.ts +0 -0
- /package/{dist/components → components}/NonIdealState.d.ts +0 -0
- /package/{dist/components → components}/PoweredByLink.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/RequestSamples.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/RequestSamples.stories.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/convertRequestToSample.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/extractCodeSamples.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/index.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/requestSampleConfigs.d.ts +0 -0
- /package/{dist/components → components}/ResponseExamples/ResponseExamples.d.ts +0 -0
- /package/{dist/components → components}/ResponseExamples/ResponseExamples.spec.d.ts +0 -0
- /package/{dist/components → components}/ResponseExamples/ResponseExamples.stories.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.spec.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.stories.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/constants.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/index.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/types.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/APIKeyAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/Auth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/AuthTokenInput.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/BasicAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/BearerAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/DigestAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/OAuth2Auth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/authentication-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/BinaryBody.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/FormDataBody.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/RequestBody.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/request-body-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/useTextRequestBodyState.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Mocking/MockingButton.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Mocking/mocking-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Mocking/useMockingOptions.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/FileUploadParameterEditors.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/OperationParameters.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/ParameterEditor.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/parameter-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/parameter-utils.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/useOperationParameters.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/ReponseCodeViewer.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/Response.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/Response.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/hooks/useLineCount.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/ServerVariables.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/ServersDropdown.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/VariableEditor.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/useServerVariables.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryIt.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryIt.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryIt.stories.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryItWithRequestSamples.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryItWithRequestSamples.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryItWithRequestSamples.stories.d.ts +0 -0
- /package/{dist/components → components}/TryIt/build-request.d.ts +0 -0
- /package/{dist/components → components}/TryIt/build-request.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/chosenServer.d.ts +0 -0
- /package/{dist/components → components}/TryIt/index.d.ts +0 -0
- /package/{dist/constants.d.ts → constants.d.ts} +0 -0
- /package/{dist/containers → containers}/MockingProvider.d.ts +0 -0
- /package/{dist/context → context}/InlineRefResolver.d.ts +0 -0
- /package/{dist/context → context}/InlineRefResolver.spec.d.ts +0 -0
- /package/{dist/context → context}/Options.d.ts +0 -0
- /package/{dist/context → context}/Persistence.d.ts +0 -0
- /package/{dist/context → context}/RouterType.d.ts +0 -0
- /package/{dist/core.css → core.css} +0 -0
- /package/{dist/hoc → hoc}/utils.d.ts +0 -0
- /package/{dist/hoc → hoc}/withMosaicProvider.d.ts +0 -0
- /package/{dist/hoc → hoc}/withMosaicProvider.spec.d.ts +0 -0
- /package/{dist/hoc → hoc}/withQueryClientProvider.d.ts +0 -0
- /package/{dist/hoc → hoc}/withQueryClientProvider.spec.d.ts +0 -0
- /package/{dist/hoc → hoc}/withRouter.d.ts +0 -0
- /package/{dist/hooks → hooks}/useBundleRefsIntoDocument.d.ts +0 -0
- /package/{dist/hooks → hooks}/useFirstRender.d.ts +0 -0
- /package/{dist/hooks → hooks}/useIsCompact.d.ts +0 -0
- /package/{dist/hooks → hooks}/useParsedData.d.ts +0 -0
- /package/{dist/hooks → hooks}/useParsedValue.d.ts +0 -0
- /package/{dist/hooks → hooks}/useResponsiveLayout.d.ts +0 -0
- /package/{dist/hooks → hooks}/useRouter.d.ts +0 -0
- /package/{dist/hooks → hooks}/useUniqueId.d.ts +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.esm.js → index.esm.js} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/index.mjs → index.mjs} +0 -0
- /package/{dist/styled.d.ts → styled.d.ts} +0 -0
- /package/{dist/styles.min.css → styles.min.css} +0 -0
- /package/{dist/types.d.ts → types.d.ts} +0 -0
- /package/{dist/utils → utils}/exampleGeneration/exampleGeneration.d.ts +0 -0
- /package/{dist/utils → utils}/exampleGeneration/exampleGeneration.spec.d.ts +0 -0
- /package/{dist/utils → utils}/fileToBase64.d.ts +0 -0
- /package/{dist/utils → utils}/guards.d.ts +0 -0
- /package/{dist/utils → utils}/headers.d.ts +0 -0
- /package/{dist/utils → utils}/http-spec/IServer.d.ts +0 -0
- /package/{dist/utils → utils}/http-spec/examples.d.ts +0 -0
- /package/{dist/utils → utils}/http.d.ts +0 -0
- /package/{dist/utils → utils}/jotai/persistAtom.d.ts +0 -0
- /package/{dist/utils → utils}/node.d.ts +0 -0
- /package/{dist/utils → utils}/oas/security.d.ts +0 -0
- /package/{dist/utils → utils}/ref-resolving/ReferenceResolver.d.ts +0 -0
- /package/{dist/utils → utils}/ref-resolving/resolvedObject.d.ts +0 -0
- /package/{dist/utils → utils}/ref-resolving/resolvedObject.test.d.ts +0 -0
- /package/{dist/utils → utils}/securitySchemes.d.ts +0 -0
- /package/{dist/utils → utils}/string.d.ts +0 -0
- /package/{dist/utils → utils}/tests/chooseOption.d.ts +0 -0
- /package/{dist/web-components → web-components}/createElementClass.d.ts +0 -0
|
@@ -1,651 +0,0 @@
|
|
|
1
|
-
import { Box, Flex, VStack } from '@stoplight/mosaic';
|
|
2
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
interface LazySchemaTreePreviewerProps {
|
|
5
|
-
schema: any;
|
|
6
|
-
root?: any;
|
|
7
|
-
title?: string;
|
|
8
|
-
level?: number;
|
|
9
|
-
path?: string;
|
|
10
|
-
maskState?: Record<string, { checked: boolean; required: 0 | 1 | 2 }>;
|
|
11
|
-
setMaskState?: React.Dispatch<React.SetStateAction<Record<string, { checked: boolean; required: 0 | 1 | 2 }>>>;
|
|
12
|
-
hideData?: Array<{ path: string; required?: boolean }>;
|
|
13
|
-
complexData?: ComplexData;
|
|
14
|
-
parentRequired?: string[];
|
|
15
|
-
propertyKey?: string;
|
|
16
|
-
_subType?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface SchemaWithMinItems {
|
|
20
|
-
minItems?: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface SchemaWithEnum {
|
|
24
|
-
enum?: any[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
type ComplexData = Array<{ location: string; isComplex?: boolean; paths: Array<{ path: string; required?: boolean }> }>;
|
|
28
|
-
|
|
29
|
-
type Schema = SchemaWithMinItems | SchemaWithEnum | object;
|
|
30
|
-
|
|
31
|
-
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
32
|
-
|
|
33
|
-
function resolvePointer(obj: any, pointer: string) {
|
|
34
|
-
const parts = pointer.replace(/^#\//, '').split('/');
|
|
35
|
-
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function detectCircularPath(path: string): boolean {
|
|
39
|
-
const ignored = ['properties', 'items'];
|
|
40
|
-
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
41
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
42
|
-
const current = parts[i];
|
|
43
|
-
const rest = parts.slice(i + 1);
|
|
44
|
-
if (rest.includes(current)) {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
function dereference(node: any, root: any, visited: WeakSet<object> = new WeakSet(), depth = 0, maxDepth = 10): any {
|
|
51
|
-
if (!node || typeof node !== 'object') return node;
|
|
52
|
-
if (depth > maxDepth) return node;
|
|
53
|
-
|
|
54
|
-
if (node.$ref || node['x-iata-$ref']) {
|
|
55
|
-
let refPath = node.$ref || node['x-iata-$ref'];
|
|
56
|
-
if (refPath.includes('#/%24defs')) {
|
|
57
|
-
refPath = refPath.replace('#/%24defs', '$defs');
|
|
58
|
-
} else {
|
|
59
|
-
refPath = refPath.replace('__bundled__', 'definitions');
|
|
60
|
-
}
|
|
61
|
-
if (visited.has(node))
|
|
62
|
-
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
63
|
-
|
|
64
|
-
visited.add(node);
|
|
65
|
-
const target = resolvePointer(root, refPath);
|
|
66
|
-
if (!target) return node;
|
|
67
|
-
const result = { ...target };
|
|
68
|
-
if ('description' in node) result.description = node.description;
|
|
69
|
-
if ('title' in node) result.title = node.title;
|
|
70
|
-
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (Array.isArray(node)) {
|
|
74
|
-
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const result: Record<string, any> = {};
|
|
78
|
-
for (const key in node) {
|
|
79
|
-
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const trimSlashes = (str: string) => {
|
|
85
|
-
return str.replace(/^\/|\/$/g, '');
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
function isPropertiesAllHidden(path: string, hideData: Array<{ path: string; required?: boolean }>) {
|
|
89
|
-
const current = trimSlashes(path);
|
|
90
|
-
const parts = current.split('/');
|
|
91
|
-
for (let i = parts.length; i >= 2; i--) {
|
|
92
|
-
if (parts[i - 1] === 'properties') {
|
|
93
|
-
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
94
|
-
const block = hideData.find(
|
|
95
|
-
h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'),
|
|
96
|
-
);
|
|
97
|
-
if (block && block.required === undefined) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function isRequiredOverride(path: string, hideData: Array<{ path: string; required?: boolean }>) {
|
|
106
|
-
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
107
|
-
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// New utility for array/items-based hiding
|
|
111
|
-
function isPathHidden(path: string, hideData: Array<{ path: string; required?: boolean }>, complexData: ComplexData) {
|
|
112
|
-
const isComplex = checkIfIsComplex(path, complexData);
|
|
113
|
-
|
|
114
|
-
if (isComplex === null) {
|
|
115
|
-
return false;
|
|
116
|
-
} else if (isComplex) {
|
|
117
|
-
const normalizedPath = trimSlashes(path);
|
|
118
|
-
|
|
119
|
-
// Direct match (root-level or property-level)
|
|
120
|
-
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
121
|
-
if (direct && direct.required === undefined) return true;
|
|
122
|
-
|
|
123
|
-
// Check for ancestor "properties" disables (properties/carr/properties, etc)
|
|
124
|
-
if (isPropertiesAllHidden(path, hideData)) return true;
|
|
125
|
-
|
|
126
|
-
// Check for array/items disables: e.g. properties/aircraftGroup/items/aircraft/items/aircraftGroup
|
|
127
|
-
// Go up the path looking for a hideData.path which is a prefix of this path and ends with '/items/[field]'
|
|
128
|
-
for (const h of hideData) {
|
|
129
|
-
const hPath = trimSlashes(h.path);
|
|
130
|
-
if (h.required !== undefined) continue;
|
|
131
|
-
// Must be prefix
|
|
132
|
-
if (
|
|
133
|
-
normalizedPath.length > hPath.length &&
|
|
134
|
-
normalizedPath.startsWith(hPath) &&
|
|
135
|
-
// hPath is items/field (array hiding)
|
|
136
|
-
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))
|
|
137
|
-
) {
|
|
138
|
-
// Hide all descendants under this path
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return false;
|
|
143
|
-
} else {
|
|
144
|
-
return !hideData.some(h => h.path === path || h.path.startsWith(path + '/'));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const checkIfIsComplex = (path: string, complexData: ComplexData) => {
|
|
149
|
-
let isComplex = null;
|
|
150
|
-
for (const complex of complexData) {
|
|
151
|
-
if (path.startsWith(complex.location)) {
|
|
152
|
-
isComplex = complex?.isComplex;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return isComplex;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const LazySchemaTreePreviewer: React.FC<LazySchemaTreePreviewerProps> = ({
|
|
160
|
-
schema,
|
|
161
|
-
root = schema,
|
|
162
|
-
title,
|
|
163
|
-
level = 1,
|
|
164
|
-
path = '',
|
|
165
|
-
hideData = [],
|
|
166
|
-
complexData = [],
|
|
167
|
-
parentRequired,
|
|
168
|
-
propertyKey,
|
|
169
|
-
_subType,
|
|
170
|
-
}) => {
|
|
171
|
-
const [expanded, setExpanded] = useState(false);
|
|
172
|
-
const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
|
|
173
|
-
const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
|
|
174
|
-
const [isHoveringSelector, setIsHoveringSelector] = useState(false);
|
|
175
|
-
const isRoot = level === 1 && (title === undefined || path === '');
|
|
176
|
-
console.log("In LazySchemaTreePreviewer Beta 0.2:", { schema, path, isRoot });
|
|
177
|
-
useEffect(() => {
|
|
178
|
-
setSelectedSchemaIndex(0);
|
|
179
|
-
}, [schema?.anyOf, schema?.oneOf]);
|
|
180
|
-
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
181
|
-
|
|
182
|
-
const shouldHideAllChildren =
|
|
183
|
-
(isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
184
|
-
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
185
|
-
|
|
186
|
-
// Check if the node has expandable children
|
|
187
|
-
const hasExpandableChildren = useMemo(() => {
|
|
188
|
-
if (shouldHideAllChildren) return false;
|
|
189
|
-
if (schema?.type === 'object' && (schema?.properties || schema?.allOf || schema?.anyOf || schema?.oneOf)) {
|
|
190
|
-
let props = schema?.properties;
|
|
191
|
-
if (schema?.allOf) {
|
|
192
|
-
schema?.allOf.forEach((item: any) => {
|
|
193
|
-
props = { ...props, ...item.properties };
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
if (schema?.anyOf && schema?.anyOf.length > 0) {
|
|
197
|
-
const selectedSchema = schema?.anyOf[selectedSchemaIndex] || schema?.anyOf[0];
|
|
198
|
-
props = { ...props, ...selectedSchema.properties };
|
|
199
|
-
}
|
|
200
|
-
if (schema?.oneOf && schema?.oneOf.length > 0) {
|
|
201
|
-
const selectedSchema = schema?.oneOf[selectedSchemaIndex] || schema?.oneOf[0];
|
|
202
|
-
props = { ...props, ...selectedSchema.properties };
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (props && Object.keys(props).length > 0) {
|
|
206
|
-
for (const [key] of Object.entries(props)) {
|
|
207
|
-
const childPath = `${path}/properties/${key}`;
|
|
208
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
209
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
210
|
-
if (!shouldHideChild) return true;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
if (
|
|
215
|
-
schema?.type === 'array' &&
|
|
216
|
-
schema?.items &&
|
|
217
|
-
Object.keys(schema?.items).length > 0 &&
|
|
218
|
-
!schema?.items?.circular
|
|
219
|
-
) {
|
|
220
|
-
const resolvedItems = dereference(schema?.items, root);
|
|
221
|
-
const itemsPath = `${path}/items`;
|
|
222
|
-
|
|
223
|
-
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
224
|
-
for (const [key] of Object.entries(resolvedItems.properties)) {
|
|
225
|
-
const childPath = `${itemsPath}/properties/${key}`;
|
|
226
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
227
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
228
|
-
if (!shouldHideChild) return true;
|
|
229
|
-
}
|
|
230
|
-
} else if (
|
|
231
|
-
resolvedItems &&
|
|
232
|
-
resolvedItems.type === 'array' &&
|
|
233
|
-
resolvedItems.items &&
|
|
234
|
-
resolvedItems.items.length > 0
|
|
235
|
-
) {
|
|
236
|
-
const childPath = `${path}/items`;
|
|
237
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
238
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
239
|
-
if (!shouldHideChild) return true;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return false;
|
|
244
|
-
}, [schema, path, hideData, complexData, shouldHideAllChildren, root, selectedSchemaIndex]);
|
|
245
|
-
|
|
246
|
-
const shouldHideNode = useMemo(() => {
|
|
247
|
-
if (isRoot) return false;
|
|
248
|
-
if (isPathHidden(path, hideData, complexData) && thisNodeRequiredOverride === undefined) return true;
|
|
249
|
-
return false;
|
|
250
|
-
}, [path, hideData, isRoot, thisNodeRequiredOverride, complexData]);
|
|
251
|
-
|
|
252
|
-
if (!schema || shouldHideNode) {
|
|
253
|
-
return null;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const displayTitle = level === 1 && (title === undefined || path === '') ? '' : title ?? schema?.title ?? 'Node';
|
|
257
|
-
|
|
258
|
-
const handleToggle = () => {
|
|
259
|
-
const circular = detectCircularPath(path);
|
|
260
|
-
if (!circular) {
|
|
261
|
-
setExpanded(prev => !prev);
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const renderChildren = () => {
|
|
266
|
-
if (shouldHideAllChildren) return null;
|
|
267
|
-
if (!expanded && !isRoot) return null;
|
|
268
|
-
|
|
269
|
-
const children: JSX.Element[] = [];
|
|
270
|
-
|
|
271
|
-
if (schema?.type === 'object' && (schema?.properties || schema?.allOf || schema?.anyOf || schema?.oneOf)) {
|
|
272
|
-
let props = schema?.properties;
|
|
273
|
-
|
|
274
|
-
if (schema?.allOf) {
|
|
275
|
-
schema?.allOf.forEach((item: any) => {
|
|
276
|
-
props = { ...props, ...item.properties };
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
if (schema?.anyOf && schema?.anyOf.length > 0) {
|
|
280
|
-
const selectedSchema = schema?.anyOf[selectedSchemaIndex] || schema?.anyOf[0];
|
|
281
|
-
props = { ...props, ...selectedSchema.properties };
|
|
282
|
-
}
|
|
283
|
-
if (schema?.oneOf && schema?.oneOf.length > 0) {
|
|
284
|
-
const selectedSchema = schema?.oneOf[selectedSchemaIndex] || schema?.oneOf[0];
|
|
285
|
-
props = { ...props, ...selectedSchema.properties };
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
for (const [key, child] of Object.entries(props || {})) {
|
|
289
|
-
const childPath = `${path}/properties/${key}`;
|
|
290
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
291
|
-
|
|
292
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
293
|
-
const resolved = dereference(child, root);
|
|
294
|
-
|
|
295
|
-
if (!shouldHideChild) {
|
|
296
|
-
children.push(
|
|
297
|
-
<li key={key}>
|
|
298
|
-
<LazySchemaTreePreviewer
|
|
299
|
-
schema={resolved}
|
|
300
|
-
root={root}
|
|
301
|
-
title={key}
|
|
302
|
-
level={level + 1}
|
|
303
|
-
path={childPath}
|
|
304
|
-
hideData={hideData}
|
|
305
|
-
complexData={complexData}
|
|
306
|
-
parentRequired={schema?.required}
|
|
307
|
-
propertyKey={key}
|
|
308
|
-
_subType={resolved?.items?.type}
|
|
309
|
-
/>
|
|
310
|
-
</li>,
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
} else if (
|
|
315
|
-
schema?.type === 'array' &&
|
|
316
|
-
schema?.items &&
|
|
317
|
-
Object.keys(schema?.items).length > 0 &&
|
|
318
|
-
!schema?.items?.circular
|
|
319
|
-
) {
|
|
320
|
-
const resolvedItems = dereference(schema?.items, root);
|
|
321
|
-
const itemsPath = `${path}/items`;
|
|
322
|
-
|
|
323
|
-
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
324
|
-
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
325
|
-
const childPath = `${itemsPath}/properties/${key}`;
|
|
326
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
327
|
-
|
|
328
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
329
|
-
const resolved = dereference(child, root);
|
|
330
|
-
|
|
331
|
-
if (!shouldHideChild) {
|
|
332
|
-
children.push(
|
|
333
|
-
<li key={key}>
|
|
334
|
-
<LazySchemaTreePreviewer
|
|
335
|
-
schema={resolved}
|
|
336
|
-
root={root}
|
|
337
|
-
title={key}
|
|
338
|
-
level={level + 2}
|
|
339
|
-
path={childPath}
|
|
340
|
-
hideData={hideData}
|
|
341
|
-
complexData={complexData}
|
|
342
|
-
parentRequired={resolvedItems.required}
|
|
343
|
-
propertyKey={key}
|
|
344
|
-
_subType={resolvedItems?.items?.type}
|
|
345
|
-
/>
|
|
346
|
-
</li>,
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
} else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
351
|
-
const childPath = `${path}/items`;
|
|
352
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
353
|
-
|
|
354
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
355
|
-
|
|
356
|
-
if (!shouldHideChild) {
|
|
357
|
-
children.push(
|
|
358
|
-
<li key="items">
|
|
359
|
-
<LazySchemaTreePreviewer
|
|
360
|
-
schema={resolvedItems}
|
|
361
|
-
root={root}
|
|
362
|
-
title="items"
|
|
363
|
-
level={level + 1}
|
|
364
|
-
path={childPath}
|
|
365
|
-
hideData={hideData}
|
|
366
|
-
complexData={complexData}
|
|
367
|
-
parentRequired={schema?.required}
|
|
368
|
-
propertyKey="items"
|
|
369
|
-
_subType={resolvedItems?.items?.type}
|
|
370
|
-
/>
|
|
371
|
-
</li>,
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
return children.length > 0 ? <ul className="ml-6 border-l border-gray-200 pl-2">{children}</ul> : null;
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
const combinedSchemaSelector = () => {
|
|
380
|
-
return (
|
|
381
|
-
<>
|
|
382
|
-
<Box
|
|
383
|
-
pos="fixed"
|
|
384
|
-
top={0}
|
|
385
|
-
left={0}
|
|
386
|
-
right={0}
|
|
387
|
-
bottom={0}
|
|
388
|
-
bg="transparent"
|
|
389
|
-
style={{ zIndex: 999 }}
|
|
390
|
-
onClick={() => setShowSchemaDropdown(false)}
|
|
391
|
-
/>
|
|
392
|
-
<Box
|
|
393
|
-
pos="absolute"
|
|
394
|
-
bg="canvas"
|
|
395
|
-
rounded
|
|
396
|
-
boxShadow="md"
|
|
397
|
-
style={{
|
|
398
|
-
zIndex: 1000,
|
|
399
|
-
top: '100%',
|
|
400
|
-
left: 0,
|
|
401
|
-
minWidth: '150px',
|
|
402
|
-
maxWidth: '200px',
|
|
403
|
-
marginTop: '2px',
|
|
404
|
-
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
405
|
-
}}
|
|
406
|
-
fontSize="sm"
|
|
407
|
-
onClick={(e: React.MouseEvent<HTMLDivElement>) => e.stopPropagation()}
|
|
408
|
-
>
|
|
409
|
-
{(schema?.anyOf || schema?.oneOf)?.map((schemaOption: any, index: number) => (
|
|
410
|
-
<Box
|
|
411
|
-
key={index}
|
|
412
|
-
px={3}
|
|
413
|
-
py={2}
|
|
414
|
-
cursor="pointer"
|
|
415
|
-
bg={selectedSchemaIndex === index ? 'primary-tint' : 'canvas'}
|
|
416
|
-
fontSize="xs"
|
|
417
|
-
display="flex"
|
|
418
|
-
alignItems="center"
|
|
419
|
-
style={{
|
|
420
|
-
borderBottom:
|
|
421
|
-
index < (schema?.anyOf || schema?.oneOf).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
|
|
422
|
-
gap: '8px',
|
|
423
|
-
}}
|
|
424
|
-
onMouseEnter={(e: React.MouseEvent<HTMLDivElement>) => {
|
|
425
|
-
if (selectedSchemaIndex !== index) {
|
|
426
|
-
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
427
|
-
}
|
|
428
|
-
}}
|
|
429
|
-
onMouseLeave={(e: React.MouseEvent<HTMLDivElement>) => {
|
|
430
|
-
if (selectedSchemaIndex !== index) {
|
|
431
|
-
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
432
|
-
}
|
|
433
|
-
}}
|
|
434
|
-
onClick={() => {
|
|
435
|
-
setSelectedSchemaIndex(index);
|
|
436
|
-
setShowSchemaDropdown(false);
|
|
437
|
-
}}
|
|
438
|
-
>
|
|
439
|
-
<Box flex={1} color="body">
|
|
440
|
-
{schemaOption.type || 'object'}
|
|
441
|
-
</Box>
|
|
442
|
-
{selectedSchemaIndex === index && (
|
|
443
|
-
<Box color="primary" fontSize="xs">
|
|
444
|
-
✓
|
|
445
|
-
</Box>
|
|
446
|
-
)}
|
|
447
|
-
</Box>
|
|
448
|
-
))}
|
|
449
|
-
</Box>
|
|
450
|
-
</>
|
|
451
|
-
);
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
const renderMinEnums = (schema: Schema) => {
|
|
455
|
-
if (!schema || typeof schema !== 'object') return null;
|
|
456
|
-
const boxStyle: any = {
|
|
457
|
-
background: 'rgba(245, 247, 250, 0.5)',
|
|
458
|
-
border: '1px solid #a0aec0',
|
|
459
|
-
borderRadius: '4px',
|
|
460
|
-
padding: '0px 2px',
|
|
461
|
-
display: 'inline-block',
|
|
462
|
-
overflowWrap: 'break-word',
|
|
463
|
-
textAlign: 'left',
|
|
464
|
-
maxWidth: 'fit-content',
|
|
465
|
-
maxHeight: 'fit-content',
|
|
466
|
-
};
|
|
467
|
-
if ('minItems' in schema) {
|
|
468
|
-
const schemaWithMinItems = schema as SchemaWithMinItems;
|
|
469
|
-
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
470
|
-
return (
|
|
471
|
-
<Box className="sl-text-muted" fontFamily="ui" fontWeight="normal" mr={2} style={boxStyle}>
|
|
472
|
-
{`>=${schemaWithMinItems.minItems} items`}
|
|
473
|
-
</Box>
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if ('enum' in schema && Array.isArray((schema as SchemaWithEnum).enum)) {
|
|
479
|
-
return (
|
|
480
|
-
<div>
|
|
481
|
-
Allowed values:{' '}
|
|
482
|
-
{(schema as SchemaWithEnum).enum!.map((val, idx) => (
|
|
483
|
-
<Box key={idx} className="sl-text-muted" fontFamily="ui" fontWeight="normal" mr={2} style={boxStyle}>
|
|
484
|
-
{val}
|
|
485
|
-
</Box>
|
|
486
|
-
))}
|
|
487
|
-
</div>
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
return null;
|
|
491
|
-
};
|
|
492
|
-
|
|
493
|
-
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
494
|
-
let showRequiredLabel = false;
|
|
495
|
-
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
496
|
-
if (hideDataEntry?.required === true || (hideDataEntry?.required === undefined && isRequired)) {
|
|
497
|
-
showRequiredLabel = true;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (schema?.$ref) {
|
|
501
|
-
// eslint-disable-next-line no-param-reassign
|
|
502
|
-
schema = dereference(schema, root);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
return (
|
|
506
|
-
<div className="mb-1">
|
|
507
|
-
<Flex maxW="full" pl={3} py={2} data-test="schema-row" pos="relative">
|
|
508
|
-
<VStack spacing={1} maxW="full" className="w-full">
|
|
509
|
-
<Flex onClick={!isRoot ? handleToggle : undefined} className={`w-full ${isRoot ? '' : 'cursor-pointer'}`}>
|
|
510
|
-
{!isRoot ? (
|
|
511
|
-
<Box mr={2} className="sl-font-mono sl-font-semibold sl-mr-2">
|
|
512
|
-
{hasExpandableChildren &&
|
|
513
|
-
!TYPES.includes(schema?.type) &&
|
|
514
|
-
!detectCircularPath(path) &&
|
|
515
|
-
!schema?.items?.circular &&
|
|
516
|
-
!schema?.circular ? (
|
|
517
|
-
<i
|
|
518
|
-
role="img"
|
|
519
|
-
aria-hidden="true"
|
|
520
|
-
className={`sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm`}
|
|
521
|
-
></i>
|
|
522
|
-
) : (
|
|
523
|
-
<span className="sl-icon fal fa-fw fa-sm" aria-hidden="true"></span>
|
|
524
|
-
)}
|
|
525
|
-
{' ' + displayTitle}
|
|
526
|
-
</Box>
|
|
527
|
-
) : null}
|
|
528
|
-
{!isRoot ? (
|
|
529
|
-
<Box mr={2} pos="relative">
|
|
530
|
-
<Box
|
|
531
|
-
display="inline-flex"
|
|
532
|
-
alignItems="center"
|
|
533
|
-
onMouseEnter={() => {
|
|
534
|
-
if (schema?.anyOf || schema?.oneOf) {
|
|
535
|
-
setIsHoveringSelector(true);
|
|
536
|
-
}
|
|
537
|
-
}}
|
|
538
|
-
onMouseLeave={() => {
|
|
539
|
-
if (!showSchemaDropdown) {
|
|
540
|
-
setIsHoveringSelector(false);
|
|
541
|
-
}
|
|
542
|
-
}}
|
|
543
|
-
onClick={(e: React.MouseEvent<HTMLDivElement>) => {
|
|
544
|
-
if (schema?.anyOf || schema?.oneOf) {
|
|
545
|
-
e.stopPropagation();
|
|
546
|
-
setShowSchemaDropdown(prev => !prev);
|
|
547
|
-
}
|
|
548
|
-
}}
|
|
549
|
-
style={{
|
|
550
|
-
cursor: schema?.anyOf || schema?.oneOf ? 'pointer' : 'default',
|
|
551
|
-
}}
|
|
552
|
-
>
|
|
553
|
-
<span className="sl-truncate sl-text-muted">
|
|
554
|
-
{(() => {
|
|
555
|
-
let typeDisplay =
|
|
556
|
-
schema?.type === 'object' && schema?.title ? schema?.title : schema?.type || root?.title;
|
|
557
|
-
|
|
558
|
-
if (schema?.anyOf && schema?.anyOf.length > 0) {
|
|
559
|
-
return `any of ${typeDisplay}`;
|
|
560
|
-
} else if (schema?.oneOf && schema?.oneOf.length > 0) {
|
|
561
|
-
return `one of ${typeDisplay}`;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
return typeDisplay;
|
|
565
|
-
})()}
|
|
566
|
-
{schema?.items && schema?.items?.title !== undefined ? ` [${schema?.items?.title}] ` : null}
|
|
567
|
-
</span>
|
|
568
|
-
{(schema?.anyOf || schema?.oneOf) && (
|
|
569
|
-
<Box
|
|
570
|
-
display="inline-flex"
|
|
571
|
-
alignItems="center"
|
|
572
|
-
ml={1}
|
|
573
|
-
style={{
|
|
574
|
-
opacity: isHoveringSelector ? 1 : 0.6,
|
|
575
|
-
transition: 'opacity 0.2s',
|
|
576
|
-
}}
|
|
577
|
-
>
|
|
578
|
-
<i
|
|
579
|
-
className="sl-icon fas fa-chevron-down"
|
|
580
|
-
style={{
|
|
581
|
-
fontSize: '10px',
|
|
582
|
-
opacity: 0.6,
|
|
583
|
-
}}
|
|
584
|
-
/>
|
|
585
|
-
</Box>
|
|
586
|
-
)}
|
|
587
|
-
</Box>
|
|
588
|
-
<span className="text-gray-500">{schema?.format !== undefined ? `<${schema?.format}>` : null}</span>
|
|
589
|
-
{(schema?.anyOf || schema?.oneOf) && showSchemaDropdown && combinedSchemaSelector()}
|
|
590
|
-
</Box>
|
|
591
|
-
) : null}
|
|
592
|
-
</Flex>
|
|
593
|
-
<Flex pl={1} w="full" align="start" direction="col" style={{ overflow: 'visible', paddingLeft: '20px' }}>
|
|
594
|
-
{schema?.description && (
|
|
595
|
-
<Box fontFamily="ui" fontWeight="light">
|
|
596
|
-
<span className="sl-prose sl-markdown-viewer" style={{ fontSize: '12px' }}>
|
|
597
|
-
{schema?.description}
|
|
598
|
-
</span>
|
|
599
|
-
</Box>
|
|
600
|
-
)}
|
|
601
|
-
{!isRoot && schema?.examples !== undefined && (
|
|
602
|
-
<Flex align="center" mb={1} style={{ flexWrap: 'wrap' }}>
|
|
603
|
-
<span className="text-gray-500" style={{ marginRight: 8, flexShrink: 0 }}>
|
|
604
|
-
Example
|
|
605
|
-
</span>
|
|
606
|
-
<Box
|
|
607
|
-
className="sl-text-muted"
|
|
608
|
-
fontFamily="ui"
|
|
609
|
-
fontWeight="normal"
|
|
610
|
-
mr={2}
|
|
611
|
-
style={{
|
|
612
|
-
background: 'rgba(245, 247, 250, 0.5)',
|
|
613
|
-
border: '1px solid #a0aec0',
|
|
614
|
-
borderRadius: '4px',
|
|
615
|
-
padding: '4px 8px',
|
|
616
|
-
display: 'inline-block',
|
|
617
|
-
overflowWrap: 'break-word',
|
|
618
|
-
textAlign: 'left',
|
|
619
|
-
maxWidth: '530px',
|
|
620
|
-
}}
|
|
621
|
-
>
|
|
622
|
-
{JSON.stringify(schema?.examples)}
|
|
623
|
-
</Box>
|
|
624
|
-
</Flex>
|
|
625
|
-
)}
|
|
626
|
-
</Flex>
|
|
627
|
-
<Flex pl={1} w="full" align="start" direction="col" style={{ overflow: 'visible', paddingLeft: '20px' }}>
|
|
628
|
-
{schema &&
|
|
629
|
-
typeof schema === 'object' &&
|
|
630
|
-
('minItems' in schema || 'enum' in schema) &&
|
|
631
|
-
renderMinEnums(schema)}
|
|
632
|
-
</Flex>
|
|
633
|
-
</VStack>
|
|
634
|
-
{!isRoot && (
|
|
635
|
-
<label className="inline-flex items-top ml-2">
|
|
636
|
-
<Box mr={2} fontFamily="ui" fontWeight="normal">
|
|
637
|
-
{showRequiredLabel && (
|
|
638
|
-
<div className="sl-ml-2 sl-text-warning">
|
|
639
|
-
<span style={{ marginLeft: '10px' }}>required</span>
|
|
640
|
-
</div>
|
|
641
|
-
)}
|
|
642
|
-
</Box>
|
|
643
|
-
</label>
|
|
644
|
-
)}
|
|
645
|
-
</Flex>
|
|
646
|
-
{renderChildren()}
|
|
647
|
-
</div>
|
|
648
|
-
);
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
export default LazySchemaTreePreviewer;
|