@redocly/openapi-docs 3.12.0-rc.7 → 3.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/redocly-openapi-docs.min.js +2153 -1963
- package/lib/components/ApiInfo/ApiInfo.js +29 -1
- package/lib/components/ApiInfo/Metadata.js +29 -1
- package/lib/components/ApiInfo/index.js +2 -1
- package/lib/components/ApiInfo/styled.js +17 -8
- package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
- package/lib/components/CallbackSamples/index.js +2 -1
- package/lib/components/Callbacks/CallbackDetails.js +17 -3
- package/lib/components/Callbacks/CallbackOperation.js +24 -3
- package/lib/components/Callbacks/CallbackSummary.js +19 -3
- package/lib/components/Callbacks/CallbacksList.js +16 -1
- package/lib/components/Callbacks/index.js +4 -1
- package/lib/components/Callbacks/styled.js +6 -3
- package/lib/components/Content/Content.js +10 -1
- package/lib/components/Content/index.js +2 -1
- package/lib/components/Content/useAutoScroll.js +50 -1
- package/lib/components/ContentItem/ContentItem.js +31 -1
- package/lib/components/ContentItem/index.js +2 -1
- package/lib/components/ContentItem/useIsExpanded.js +33 -1
- package/lib/components/ContentItems/ContentItems.js +19 -1
- package/lib/components/ContentItems/Items.js +13 -1
- package/lib/components/ContentItems/VirtualList.js +35 -1
- package/lib/components/ContentItems/helpers.js +49 -1
- package/lib/components/ContentItems/index.js +2 -1
- package/lib/components/ContentItems/useScrollOnRender.js +26 -1
- package/lib/components/Discriminator/Discriminator.js +27 -2
- package/lib/components/Discriminator/index.js +2 -1
- package/lib/components/Download/DownloadSpecification.js +46 -4
- package/lib/components/Download/index.js +2 -1
- package/lib/components/Download/types.js +2 -0
- package/lib/components/Download/useDownloadInfo.js +42 -1
- package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
- package/lib/components/ErrorBoundary/index.js +2 -1
- package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
- package/lib/components/ExpandAllButton/index.js +2 -1
- package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
- package/lib/components/ExternalDocumentation/index.js +2 -1
- package/lib/components/Language/LanguageDropdown.js +21 -1
- package/lib/components/Language/LanguageItem.js +33 -1
- package/lib/components/Language/LanguageList.js +93 -1
- package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
- package/lib/components/Language/constants.js +3 -1
- package/lib/components/Language/index.js +4 -1
- package/lib/components/Language/styled.js +29 -15
- package/lib/components/Markdown/Markdown.js +64 -1
- package/lib/components/Markdown/index.js +3 -1
- package/lib/components/Markdown/types.js +2 -0
- package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
- package/lib/components/MediaTypeSwitch/index.js +2 -1
- package/lib/components/OperationItem/Description.d.ts +1 -4
- package/lib/components/OperationItem/Description.js +9 -1
- package/lib/components/OperationItem/OperationItem.js +70 -5
- package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
- package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
- package/lib/components/OperationItem/index.js +2 -1
- package/lib/components/OperationItem/types.js +2 -0
- package/lib/components/Overlay.js +48 -3
- package/lib/components/Overview/Overview.js +20 -1
- package/lib/components/Overview/index.js +2 -1
- package/lib/components/PageFooter/PageFooter.js +19 -1
- package/lib/components/PageFooter/index.js +2 -1
- package/lib/components/Panel/ResponsePanel.js +12 -6
- package/lib/components/Panel/Trigger.js +4 -2
- package/lib/components/Panel/index.js +3 -1
- package/lib/components/PanelItem/PanelItem.js +6 -1
- package/lib/components/PanelItem/index.js +3 -1
- package/lib/components/PanelItem/styled.js +20 -10
- package/lib/components/PayloadSamples/Example.js +6 -1
- package/lib/components/PayloadSamples/ExampleValue.js +30 -1
- package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
- package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
- package/lib/components/PayloadSamples/index.js +7 -1
- package/lib/components/PayloadSamples/styled.js +9 -4
- package/lib/components/PayloadSamples/types.js +2 -0
- package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
- package/lib/components/PropertyDetails/EnumValues.js +37 -1
- package/lib/components/PropertyDetails/Examples.js +26 -1
- package/lib/components/PropertyDetails/Extensions.js +17 -2
- package/lib/components/PropertyDetails/FieldDetail.js +15 -2
- package/lib/components/PropertyDetails/FieldDetails.js +51 -6
- package/lib/components/PropertyDetails/Pattern.js +21 -1
- package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
- package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
- package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
- package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
- package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
- package/lib/components/PropertyDetails/index.js +4 -1
- package/lib/components/PropertyDetails/styled.js +15 -7
- package/lib/components/PropertyDetails/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
- package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
- package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
- package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
- package/lib/components/RenderHook/RenderHook.js +17 -1
- package/lib/components/RenderHook/index.js +2 -1
- package/lib/components/Replay/EmbeddedReplay.js +41 -3
- package/lib/components/Replay/Replay.js +99 -1
- package/lib/components/Replay/index.js +3 -1
- package/lib/components/Replay/utils.js +208 -1
- package/lib/components/Request/RequestDetails.js +33 -2
- package/lib/components/Request/types.js +2 -0
- package/lib/components/RequestParameters/Body.js +8 -1
- package/lib/components/RequestParameters/ParametersGroup.js +19 -4
- package/lib/components/RequestParameters/RequestParameters.js +40 -1
- package/lib/components/RequestParameters/index.js +4 -1
- package/lib/components/RequestSamples/CodeSample.js +55 -2
- package/lib/components/RequestSamples/Example.js +37 -1
- package/lib/components/RequestSamples/RequestSamples.js +89 -5
- package/lib/components/RequestSamples/index.js +3 -1
- package/lib/components/RequestSamples/useCodeSamples.js +92 -1
- package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
- package/lib/components/ResponseSamples/Summary.js +9 -1
- package/lib/components/ResponseSamples/index.js +2 -1
- package/lib/components/Responses/OperationResponseList.js +42 -2
- package/lib/components/Responses/ResponseDetails.js +18 -1
- package/lib/components/Responses/ResponseHeaders.js +15 -1
- package/lib/components/Responses/index.js +6 -1
- package/lib/components/Responses/styled.js +14 -6
- package/lib/components/Responses/types.js +2 -0
- package/lib/components/RightPanel/RightPanel.js +21 -1
- package/lib/components/RightPanel/index.js +2 -1
- package/lib/components/Samples/ExampleSwitch.js +33 -1
- package/lib/components/Samples/index.js +3 -1
- package/lib/components/Samples/use-example-key.js +12 -1
- package/lib/components/Schema/ArraySchema.js +45 -1
- package/lib/components/Schema/ObjectSchema.js +29 -1
- package/lib/components/Schema/OneOfSchema.js +47 -3
- package/lib/components/Schema/RecursiveSchema.js +10 -1
- package/lib/components/Schema/Schema.js +63 -2
- package/lib/components/Schema/SubSchema.js +20 -1
- package/lib/components/Schema/helpers.js +16 -1
- package/lib/components/Schema/index.js +5 -1
- package/lib/components/Schema/types.js +2 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
- package/lib/components/SchemaDefinition/index.js +2 -1
- package/lib/components/SectionContent/SectionContent.js +49 -6
- package/lib/components/SectionContent/index.js +2 -1
- package/lib/components/SectionItem/SectionItem.js +14 -1
- package/lib/components/SectionItem/index.js +2 -1
- package/lib/components/Security/Divider.js +9 -2
- package/lib/components/Security/OAuthFlow.js +11 -1
- package/lib/components/Security/OAuthScopes.js +59 -9
- package/lib/components/Security/Security.js +15 -1
- package/lib/components/Security/SecurityButton.js +31 -7
- package/lib/components/Security/SecurityFlow.js +28 -4
- package/lib/components/Security/SecurityModal.js +34 -5
- package/lib/components/Security/SecuritySchemeItem.js +15 -4
- package/lib/components/Security/helper.js +16 -1
- package/lib/components/Security/index.js +11 -1
- package/lib/components/Security/styled.js +6 -3
- package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
- package/lib/components/SelectOrLabel/index.js +2 -1
- package/lib/components/ServerList/ServerList.js +36 -10
- package/lib/components/ServerList/index.js +2 -1
- package/lib/components/ServerList/types.js +2 -0
- package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
- package/lib/components/ServerListDropdown/index.js +2 -1
- package/lib/components/ServerListDropdown/styled.js +15 -6
- package/lib/components/SideMenu/SideMenu.js +13 -2
- package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
- package/lib/components/SideMenu/index.js +2 -1
- package/lib/components/SideMenu/types.js +2 -0
- package/lib/components/StickySidebar/SidebarActions.js +14 -2
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
- package/lib/components/StickySidebar/index.js +2 -1
- package/lib/components/Tabs/Tabs.js +16 -5
- package/lib/components/Tabs/index.js +3 -1
- package/lib/components/Tabs/useTabsState.js +22 -1
- package/lib/components/TagItem/OperationNavigationItems.js +18 -4
- package/lib/components/TagItem/OperationsNavigation.js +46 -2
- package/lib/components/TagItem/TagItem.js +41 -8
- package/lib/components/TagItem/index.js +2 -1
- package/lib/components/TagItem/styled.js +5 -2
- package/lib/components/TagItem/types.js +2 -0
- package/lib/components/ViewNested/ViewNested.js +42 -9
- package/lib/components/ViewNested/index.js +2 -1
- package/lib/components/common/Badges.js +21 -5
- package/lib/components/common/BodyContent/BodyContent.js +31 -4
- package/lib/components/common/BodyContent/index.js +2 -1
- package/lib/components/common/ClearButton/ClearButton.js +5 -1
- package/lib/components/common/ClearButton/index.js +3 -1
- package/lib/components/common/ClearButton/styled.js +5 -2
- package/lib/components/common/ClearButton/types.js +2 -0
- package/lib/components/common/CodeBlockPanel.js +7 -3
- package/lib/components/common/ConstraintsView.js +14 -2
- package/lib/components/common/Dropdown/Dropdown.js +22 -4
- package/lib/components/common/Dropdown/index.js +2 -1
- package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
- package/lib/components/common/ExpandableExample/index.js +2 -1
- package/lib/components/common/Extensions.js +17 -2
- package/lib/components/common/Fields/fields-layout.js +76 -51
- package/lib/components/common/Fields/fields.js +39 -17
- package/lib/components/common/Fields/index.js +3 -1
- package/lib/components/common/LinkToField.js +33 -6
- package/lib/components/common/OperationItemTitle.d.ts +1 -0
- package/lib/components/common/OperationItemTitle.js +16 -5
- package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
- package/lib/components/common/SchemaSelection/index.js +2 -1
- package/lib/components/common/Select/Select.js +21 -1
- package/lib/components/common/Select/index.js +3 -1
- package/lib/components/common/Select/styled.js +17 -9
- package/lib/components/common/Select/types.js +2 -0
- package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
- package/lib/components/common/Skeleton/Skeleton.js +15 -5
- package/lib/components/common/Skeleton/index.js +3 -1
- package/lib/components/common/headers.js +4 -2
- package/lib/components/common/index.js +14 -1
- package/lib/components/common/linkify.js +28 -4
- package/lib/components/common/mixins.js +4 -2
- package/lib/components/common/panels.js +58 -33
- package/lib/components/common/schema.js +16 -8
- package/lib/components/common/styled.js +15 -7
- package/lib/components/index.js +25 -1
- package/lib/components/pluggable/RedocExample.js +20 -1
- package/lib/components/pluggable/RedocSchema.js +22 -1
- package/lib/components/pluggable/index.js +3 -1
- package/lib/components/pluggable/styled.components.js +9 -4
- package/lib/constants.js +30 -1
- package/lib/empty.js +7 -1
- package/lib/events/codeSampleCopy.js +19 -1
- package/lib/events/creator.js +5 -1
- package/lib/events/index.js +8 -1
- package/lib/events/languageSwitch.js +18 -1
- package/lib/events/panelToggle.js +16 -1
- package/lib/events/serverSwitch.js +13 -1
- package/lib/events/tryItOpen.js +12 -1
- package/lib/events/tryItSent.js +12 -1
- package/lib/events/types.js +11 -1
- package/lib/hoc/types.js +2 -0
- package/lib/hoc/utils.js +4 -1
- package/lib/hoc/withRouter.js +17 -1
- package/lib/hoc/withStore.js +28 -1
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/useActivateExample.js +35 -1
- package/lib/hooks/useActiveWithFallback.js +12 -1
- package/lib/hooks/useContentItems.js +10 -1
- package/lib/hooks/useLicense.js +17 -1
- package/lib/hooks/usePerformanceMetrics.js +26 -1
- package/lib/hooks/useRouter.js +17 -1
- package/lib/hooks/useTelemetry.js +5 -1
- package/lib/hooks/useTranslate.js +6 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
- package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
- package/lib/icons/CSharpIcon/index.js +2 -1
- package/lib/icons/CurlIcon/CurlIcon.js +8 -2
- package/lib/icons/CurlIcon/index.js +2 -1
- package/lib/icons/GOIcon/GOIcon.js +7 -1
- package/lib/icons/GOIcon/index.js +2 -1
- package/lib/icons/JavaIcon/JavaIcon.js +7 -1
- package/lib/icons/JavaIcon/index.js +2 -1
- package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
- package/lib/icons/JavaScriptIcon/index.js +2 -1
- package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
- package/lib/icons/NodeJSIcon/index.js +2 -1
- package/lib/icons/PHPIcon/PHPIcon.js +7 -1
- package/lib/icons/PHPIcon/index.js +2 -1
- package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
- package/lib/icons/PayloadIcon/index.js +2 -1
- package/lib/icons/PythonIcon/PythonIcon.js +7 -1
- package/lib/icons/PythonIcon/index.js +2 -1
- package/lib/icons/RIcon/RIcon.js +7 -1
- package/lib/icons/RIcon/index.js +2 -1
- package/lib/icons/RubyIcon/RubyIcon.js +7 -1
- package/lib/icons/RubyIcon/index.js +2 -1
- package/lib/index.js +49 -1
- package/lib/jotai/app.js +113 -1
- package/lib/jotai/operation.js +28 -1
- package/lib/jotai/replay.js +5 -1
- package/lib/jotai/store.js +8 -1
- package/lib/jotai/use-write-atom.js +9 -1
- package/lib/models/callback.js +28 -1
- package/lib/models/code-sample-options.js +2 -0
- package/lib/models/example.js +17 -1
- package/lib/models/field.js +109 -1
- package/lib/models/group.js +38 -1
- package/lib/models/index.js +14 -1
- package/lib/models/mediaContent.js +26 -1
- package/lib/models/mediaType.js +153 -1
- package/lib/models/operation.js +166 -1
- package/lib/models/request.js +25 -1
- package/lib/models/response.js +46 -1
- package/lib/models/schema.js +474 -2
- package/lib/models/security.js +84 -1
- package/lib/models/tab.js +2 -0
- package/lib/models/types.js +2 -0
- package/lib/services/OpenAPIParser.js +321 -1
- package/lib/services/check.js +104 -1
- package/lib/services/code-samples/constants.js +16 -1
- package/lib/services/code-samples/generator.js +540 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.d.ts +5 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +2 -2
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
- package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
- package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
- package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
- package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
- package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
- package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
- package/lib/services/code-samples/httpsnippet/index.js +166 -1
- package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
- package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
- package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
- package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
- package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
- package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
- package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
- package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
- package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
- package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
- package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
- package/lib/services/code-samples/index.js +3 -1
- package/lib/services/code-samples/types.js +2 -0
- package/lib/services/config-options/helpers.js +49 -1
- package/lib/services/config-options/index.js +3 -1
- package/lib/services/config-options/normalizeOptions.js +83 -1
- package/lib/services/config-options/types.js +2 -0
- package/lib/services/history/helpers.js +63 -1
- package/lib/services/history/index.js +2 -1
- package/lib/services/index.js +9 -1
- package/lib/services/menu/builder.js +47 -1
- package/lib/services/menu/index.js +2 -1
- package/lib/services/menu/markdown.js +93 -1
- package/lib/services/menu/operation.js +50 -1
- package/lib/services/menu/tags.js +166 -1
- package/lib/services/types.d.ts +0 -3
- package/lib/services/types.js +2 -0
- package/lib/services/utils.js +83 -1
- package/lib/standalone.js +68 -1
- package/lib/styled-components.js +6 -1
- package/lib/types/app.js +2 -0
- package/lib/types/index.js +4 -1
- package/lib/types/open-api.d.ts +1 -0
- package/lib/types/open-api.js +2 -0
- package/lib/types/security.js +2 -0
- package/lib/utils/JsonPointer.js +84 -1
- package/lib/utils/areArraysEqual.js +4 -1
- package/lib/utils/argValuesHelpers.js +35 -1
- package/lib/utils/compose.js +2 -1
- package/lib/utils/configure-helpers.js +223 -1
- package/lib/utils/convertSwagger2OpenAPI.js +14 -1
- package/lib/utils/cookies.js +73 -1
- package/lib/utils/debounce.js +22 -1
- package/lib/utils/debug.js +11 -1
- package/lib/utils/dom.js +65 -1
- package/lib/utils/environments.js +13 -1
- package/lib/utils/helpers.js +222 -12
- package/lib/utils/index.js +25 -1
- package/lib/utils/isMobile.js +13 -1
- package/lib/utils/loadAndBundleSpec.js +32 -1
- package/lib/utils/local-storage.js +12 -1
- package/lib/utils/object.js +31 -1
- package/lib/utils/openapi.js +592 -1
- package/lib/utils/parameters.js +13 -1
- package/lib/utils/path.js +22 -1
- package/lib/utils/queryString.js +60 -1
- package/lib/utils/replaceVariables.js +14 -1
- package/lib/utils/saveTextBeforeHeading.js +35 -1
- package/lib/utils/security-details.js +49 -1
- package/lib/utils/session-storage.js +12 -1
- package/lib/utils/simplifyAstStructure.js +22 -1
- package/lib/utils/sort.js +21 -1
- package/lib/utils/string.js +65 -1
- package/lib/utils/telemetry.js +7 -1
- package/lib/utils/test-utils.js +26 -1
- package/lib/utils/theme-helpers.js +24 -3
- package/lib/utils/url.js +38 -1
- package/package.json +5 -5
|
@@ -1 +1,18 @@
|
|
|
1
|
-
const
|
|
1
|
+
export const cycleColorsByLevel = (level) => {
|
|
2
|
+
if (level === undefined) {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
const levelColors = [
|
|
6
|
+
'#9D00FF',
|
|
7
|
+
'#615CEA',
|
|
8
|
+
'#147DF5',
|
|
9
|
+
'#08BFCC',
|
|
10
|
+
'#08CC7A',
|
|
11
|
+
'#81CC08',
|
|
12
|
+
'#E5BE00',
|
|
13
|
+
'#FF8700',
|
|
14
|
+
'#FF00B8',
|
|
15
|
+
];
|
|
16
|
+
return levelColors[level % levelColors.length];
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=cycleColorsByLevel.js.map
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { PropertyDetails } from './PropertyDetails.js';
|
|
2
|
+
export { FieldDetails } from './FieldDetails.js';
|
|
3
|
+
export { Extensions } from './Extensions.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import{Markdown as
|
|
1
|
+
import { Markdown as MarkdownWrapper } from '@redocly/theme/components/Markdown/Markdown';
|
|
2
|
+
import { styled } from '../../styled-components.js';
|
|
3
|
+
export const DescriptionEnumsBlock = styled(MarkdownWrapper) `
|
|
2
4
|
table.md {
|
|
3
5
|
margin: var(--spacing-xs) 0 0;
|
|
4
6
|
}
|
|
5
|
-
|
|
7
|
+
`;
|
|
8
|
+
export const TypeWrapper = styled.div `
|
|
6
9
|
line-height: 20px;
|
|
7
|
-
|
|
10
|
+
`;
|
|
11
|
+
export const ExampleSummary = styled.label `
|
|
8
12
|
display: block;
|
|
9
13
|
font-size: inherit;
|
|
10
14
|
margin-bottom: 0.2em;
|
|
11
15
|
font-weight: var(--font-weight-bold);
|
|
12
|
-
|
|
16
|
+
`;
|
|
17
|
+
export const ExampleWrap = styled.div `
|
|
13
18
|
margin-top: 1em;
|
|
14
19
|
font-size: var(--field-name-font-size);
|
|
15
|
-
|
|
20
|
+
`;
|
|
21
|
+
export const ExamplesList = styled.div `
|
|
16
22
|
padding-left: 1.5em;
|
|
17
23
|
margin-bottom: 1em;
|
|
18
|
-
|
|
24
|
+
`;
|
|
25
|
+
export const FieldDescriptionWrapper = styled.div `
|
|
19
26
|
p {
|
|
20
27
|
overflow-wrap: anywhere;
|
|
21
28
|
}
|
|
22
|
-
`;
|
|
29
|
+
`;
|
|
30
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1,114 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import markdocLib from '@markdoc/markdoc';
|
|
4
|
+
import { LayoutVariant } from '@redocly/config';
|
|
5
|
+
import { createStore, Provider } from 'jotai';
|
|
6
|
+
import { Heading } from '@redocly/theme/markdoc/components/Heading/Heading';
|
|
7
|
+
import { normalizeOptions, OpenAPIParser } from '../../services/index.js';
|
|
8
|
+
import { getMarkdownHeaderId } from './utils.js';
|
|
9
|
+
import { normalizeServers } from '../../utils/index.js';
|
|
10
|
+
import { SchemaDefinition } from '../SchemaDefinition/index.js';
|
|
11
|
+
import { appStore, appStoreOverrideAtom, environmentAtom, layoutAtom, userClaimsAtom, } from '../../jotai/app.js';
|
|
12
|
+
import { mapObject } from '../../utils/object.js';
|
|
13
|
+
import { mergeInMockServer } from '../../models/operation.js';
|
|
14
|
+
import { getDefaultOperationStore, operationStore } from '../../jotai/operation.js';
|
|
15
|
+
import { getServerEnvName } from '../../utils/environments.js';
|
|
16
|
+
import { globalStoreAtom } from '../../jotai/store.js';
|
|
17
|
+
const DEFAULT_OPTIONS = {
|
|
18
|
+
// java.io.ObjectStreamField is something generated from java code which is too deep so our docs build crash because of RAM
|
|
19
|
+
ignoreNamedSchemas: ['java.io.ObjectStreamField'],
|
|
20
|
+
maxDisplayedEnumValues: 10,
|
|
21
|
+
markdocOptions: {
|
|
22
|
+
tags: {
|
|
23
|
+
schemaDefinition: {
|
|
24
|
+
render: 'SchemaDefinition',
|
|
25
|
+
attributes: {
|
|
26
|
+
schemaRef: {
|
|
27
|
+
type: String,
|
|
28
|
+
},
|
|
29
|
+
exampleRef: {
|
|
30
|
+
type: String,
|
|
31
|
+
},
|
|
32
|
+
showReadOnly: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
},
|
|
35
|
+
showWriteOnly: {
|
|
36
|
+
type: Boolean,
|
|
37
|
+
},
|
|
38
|
+
htmlWrap: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: false,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
nodes: {
|
|
46
|
+
heading: {
|
|
47
|
+
children: ['inline'],
|
|
48
|
+
attributes: {
|
|
49
|
+
id: { type: String },
|
|
50
|
+
level: { type: Number, required: true, default: 1 },
|
|
51
|
+
},
|
|
52
|
+
transform(node, config) {
|
|
53
|
+
const attributes = node.transformAttributes(config);
|
|
54
|
+
const children = node.transformChildren(config);
|
|
55
|
+
const id = typeof attributes.id === 'string' ? attributes.id : getMarkdownHeaderId(children);
|
|
56
|
+
return new markdocLib.Tag('Heading', {
|
|
57
|
+
...attributes,
|
|
58
|
+
id,
|
|
59
|
+
level: node.attributes.level,
|
|
60
|
+
}, children);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
components: {
|
|
65
|
+
SchemaDefinition: SchemaDefinition,
|
|
66
|
+
Heading,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export const StoreProvider = memo(({ children, options: rawOptions, definitionUrl, definition, withState, }) => {
|
|
71
|
+
const createGlobalStore = useCallback(() => {
|
|
72
|
+
const options = normalizeOptions(rawOptions, DEFAULT_OPTIONS);
|
|
73
|
+
const parser = new OpenAPIParser(definition, definitionUrl, options);
|
|
74
|
+
return { options, parser };
|
|
75
|
+
}, [definition, definitionUrl, rawOptions]);
|
|
76
|
+
const initializedStore = useMemo(() => {
|
|
77
|
+
const store = createStore();
|
|
78
|
+
const globalStoreValue = createGlobalStore();
|
|
79
|
+
store.set(globalStoreAtom, globalStoreValue);
|
|
80
|
+
// fixme: move into separate function + collect all servers from all operations/paths
|
|
81
|
+
const globalServers = normalizeServers(globalStoreValue.parser.definitionUrl, mergeInMockServer(globalStoreValue.parser.definition?.servers || [], globalStoreValue.options.mockServer));
|
|
82
|
+
const serverEnvs = Object.fromEntries(globalServers.map((server) => [
|
|
83
|
+
getServerEnvName(server),
|
|
84
|
+
{
|
|
85
|
+
server: server.url,
|
|
86
|
+
...mapObject(server.variables || {}, (variable) => variable.default || ''),
|
|
87
|
+
},
|
|
88
|
+
]));
|
|
89
|
+
store.sub(appStore, () => undefined); // force mount so init data is read from storage
|
|
90
|
+
store.set(layoutAtom, globalStoreValue.options?.layout || LayoutVariant.THREE_PANEL); // set layout atom to update appStore atom with correct layout value
|
|
91
|
+
store.set(environmentAtom, { environments: serverEnvs });
|
|
92
|
+
store.set(userClaimsAtom, withState?.userClaims || {});
|
|
93
|
+
if (withState) {
|
|
94
|
+
store.set(appStoreOverrideAtom, {
|
|
95
|
+
environment: withState.environment,
|
|
96
|
+
environments: withState.environments,
|
|
97
|
+
activeMimeName: withState.activeMimeName,
|
|
98
|
+
userClaims: withState.userClaims,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (withState?.operation) {
|
|
102
|
+
const defaultStore = getDefaultOperationStore(withState.operation.pointer, withState.operation.state.requestValues, withState.operation.state.activeExampleName);
|
|
103
|
+
store.set(operationStore(withState.operation.pointer), defaultStore);
|
|
104
|
+
}
|
|
105
|
+
return store;
|
|
106
|
+
}, [createGlobalStore, withState]);
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (!withState?.layout)
|
|
109
|
+
return;
|
|
110
|
+
initializedStore.set(layoutAtom, withState?.layout);
|
|
111
|
+
}, [initializedStore, withState?.layout]);
|
|
112
|
+
return _jsx(Provider, { store: initializedStore, children: children });
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=Providers.js.map
|
|
@@ -1 +1,57 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useRef } from 'react';
|
|
3
|
+
import { LayoutVariant } from '@redocly/config';
|
|
4
|
+
import { useSetAtom } from 'jotai';
|
|
5
|
+
import { ThreePanelLayout } from '@redocly/theme/layouts/ThreePanelLayout';
|
|
6
|
+
import { SidebarLogo } from '@redocly/theme/components/SidebarLogo/SidebarLogo';
|
|
7
|
+
import { GlobalStyle as ThemeCommonStyle, useMount } from '@redocly/theme/core/openapi';
|
|
8
|
+
import { StoreProvider } from './Providers.js';
|
|
9
|
+
import { Overlay } from '../Overlay.js';
|
|
10
|
+
import { RedocWrap } from './styled.js';
|
|
11
|
+
import { StickyResponsiveSidebar } from '../StickySidebar/index.js';
|
|
12
|
+
import { SideMenu } from '../SideMenu/index.js';
|
|
13
|
+
import { Content } from '../Content/index.js';
|
|
14
|
+
import { useContentItems, useUppercase2LowercaseRedirect, useTelemetry, usePerformanceMetrics, } from '../../hooks/index.js';
|
|
15
|
+
import { withRouter } from '../../hoc/withRouter.js';
|
|
16
|
+
import { withStore } from '../../hoc/withStore.js';
|
|
17
|
+
import { compose } from '../../utils/index.js';
|
|
18
|
+
import { useLicense } from '../../hooks/useLicense.js'; // we need a full import path for overriding license in portal
|
|
19
|
+
import { allOperationsAtom } from '../../jotai/replay.js';
|
|
20
|
+
const RedoclyOpenAPIDocsComponent = compose(withRouter, withStore, memo)(({ licenseKey, onLoaded, children, options, layout, collapsedSidebar, parser, withCommonStyles, }) => {
|
|
21
|
+
const rootElementRef = useRef(null);
|
|
22
|
+
const { isValid: hasValidLicense, licenseInfo } = useLicense(licenseKey);
|
|
23
|
+
const setAllOperations = useSetAtom(allOperationsAtom);
|
|
24
|
+
const telemetry = useTelemetry();
|
|
25
|
+
// remove this when no more warnings are logged (https://github.com/Redocly/redocly/issues/6778)
|
|
26
|
+
useUppercase2LowercaseRedirect();
|
|
27
|
+
const { contentItems, flatItems } = useContentItems({ parser, options });
|
|
28
|
+
usePerformanceMetrics({
|
|
29
|
+
sendTelemetry: (data) => {
|
|
30
|
+
const lowercaseData = Object.fromEntries(Object.entries(data).map(([key, value]) => [key.toLowerCase(), value]));
|
|
31
|
+
telemetry.send({
|
|
32
|
+
type: 'openapi_docs.performance_metrics',
|
|
33
|
+
payload: {
|
|
34
|
+
cls: lowercaseData.cls,
|
|
35
|
+
lcp: lowercaseData.lcp,
|
|
36
|
+
fcp: lowercaseData.fcp,
|
|
37
|
+
ttfb: lowercaseData.ttfb,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
useMount(() => {
|
|
43
|
+
onLoaded?.();
|
|
44
|
+
telemetry.send({ type: 'openapi_docs.viewed', payload: { layout: layout } });
|
|
45
|
+
if (!options.hideReplay) {
|
|
46
|
+
const operations = flatItems.filter((item) => item.type === 'operation');
|
|
47
|
+
setAllOperations(operations);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const { hideSidebar, scrollYOffset } = options || {};
|
|
51
|
+
const xLogo = parser.definition?.info?.['x-logo'];
|
|
52
|
+
return (_jsxs(_Fragment, { children: [withCommonStyles && _jsx(ThemeCommonStyle, {}), _jsxs(RedocWrap, { className: "redoc-wrap", ref: rootElementRef, children: [!hasValidLicense && _jsx(Overlay, { licenseInfo: licenseInfo }), !hideSidebar && (_jsxs(StickyResponsiveSidebar, { scrollYOffset: scrollYOffset, className: "menu-content", collapsedSidebar: !collapsedSidebar, children: [_jsx(SidebarLogo, { imageUrl: xLogo?.url, href: xLogo?.href || parser.definition?.info?.contact?.url, altText: xLogo?.altText, backgroundColor: xLogo?.backgroundColor }), _jsx(SideMenu, { items: hasValidLicense ? contentItems : [] })] })), _jsxs(ThreePanelLayout, { className: "api-content", id: "api-content", layout: layout === LayoutVariant.THREE_PANEL ? LayoutVariant.THREE_PANEL : LayoutVariant.STACKED, collapsedSidebar: collapsedSidebar, children: [_jsx(Content, { items: hasValidLicense ? contentItems : [], routingBasePath: options.routingBasePath }), children] })] })] }));
|
|
53
|
+
});
|
|
54
|
+
export function RedoclyOpenAPIDocs({ onLoaded, children, store, withCommonStyles, }) {
|
|
55
|
+
return store?.definition ? (_jsx(StoreProvider, { ...store, children: _jsx(RedoclyOpenAPIDocsComponent, { onLoaded: onLoaded, basePath: store.options?.routingBasePath, licenseKey: store.options?.licenseKey, disableRouter: store.options?.disableRouter, withCommonStyles: withCommonStyles, children: children }) })) : null;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=RedoclyOpenAPIDocs.js.map
|
|
@@ -1 +1,86 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, isValidElement, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { Loading } from '@redocly/theme/components/Loaders/Loading';
|
|
4
|
+
import { useDeepCompareMemoize, fixSpec } from './utils.js';
|
|
5
|
+
import { argValueToBoolean } from '../../utils/index.js';
|
|
6
|
+
import { RedoclyOpenAPIDocs } from './RedoclyOpenAPIDocs.js';
|
|
7
|
+
import { loadAndBundleDefinition } from '../../utils/loadAndBundleSpec.js';
|
|
8
|
+
export async function loadSingle(spec, specUrl, options) {
|
|
9
|
+
let resolvedDefinition;
|
|
10
|
+
if (options?.skipBundle) {
|
|
11
|
+
if (!spec) {
|
|
12
|
+
throw new Error('spec must be specified when using "skipBundleAndConvert"');
|
|
13
|
+
}
|
|
14
|
+
resolvedDefinition = spec;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
resolvedDefinition = await loadAndBundleDefinition(spec || specUrl);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
fixSpec(resolvedDefinition);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// nope
|
|
24
|
+
}
|
|
25
|
+
return resolvedDefinition;
|
|
26
|
+
}
|
|
27
|
+
export function loadAndBundleSpecOrMd(url, title) {
|
|
28
|
+
if (url.endsWith('.md')) {
|
|
29
|
+
return loadAndBundleDefinition({
|
|
30
|
+
openapi: '3.0.0',
|
|
31
|
+
info: {
|
|
32
|
+
title: title || '',
|
|
33
|
+
version: '1.0',
|
|
34
|
+
description: { $ref: url },
|
|
35
|
+
},
|
|
36
|
+
paths: {},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return loadAndBundleDefinition(url);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const AppProvider = ({ options, definitionUrl, definition, activeSampleLanguage, children, }) => {
|
|
44
|
+
const [, setError] = useState();
|
|
45
|
+
const [loading, setLoading] = useState(true);
|
|
46
|
+
const [loadedSpec, setLoadedSpec] = useState(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
async function load() {
|
|
49
|
+
setLoading(true);
|
|
50
|
+
try {
|
|
51
|
+
setLoadedSpec(await loadSingle(definition, definitionUrl, options));
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
setError(() => {
|
|
55
|
+
throw e;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
load();
|
|
60
|
+
}, [definition, definitionUrl, options]); // do not reload based on options
|
|
61
|
+
const store = useMemo(() => {
|
|
62
|
+
if (!loadedSpec)
|
|
63
|
+
return undefined;
|
|
64
|
+
if (options?.unstable_hooks?.onInit) {
|
|
65
|
+
options.unstable_hooks?.onInit?.({
|
|
66
|
+
store: { definition: loadedSpec, options, definitionUrl, activeSampleLanguage },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return { definition: loadedSpec, options, definitionUrl, activeSampleLanguage };
|
|
70
|
+
},
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
useDeepCompareMemoize([loadedSpec, options, definitionUrl]));
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!store)
|
|
75
|
+
return;
|
|
76
|
+
setLoading(false);
|
|
77
|
+
}, [store]);
|
|
78
|
+
if (!store) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return !loading ? (isValidElement(children) ? (cloneElement(children, { store })) : null) : argValueToBoolean(options?.hideLoading, false) ? null : (_jsx(Loading, { color: "--loading-spinner-color" }));
|
|
82
|
+
};
|
|
83
|
+
export function RedoclyOpenAPIDocsStandalone({ definition, definitionUrl, options = {}, activeItemId, activeSampleLanguage, activeDeepLink, }) {
|
|
84
|
+
return (_jsx(AppProvider, { definition: definition, definitionUrl: definitionUrl, options: options, activeItemId: activeItemId, activeSampleLanguage: activeSampleLanguage, activeDeepLink: activeDeepLink, children: _jsx(RedoclyOpenAPIDocs, { withCommonStyles: true }) }));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=RedoclyOpenAPIDocsStandalone.js.map
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { RedoclyOpenAPIDocs } from './RedoclyOpenAPIDocs.js';
|
|
2
|
+
export { StoreProvider } from './Providers.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { fixSpec, useDeepCompareMemoize, getMarkdownHeaderId } from './utils.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import{styled
|
|
1
|
+
import { styled } from '../../styled-components.js';
|
|
2
|
+
export const RedocWrap = styled.div `
|
|
2
3
|
display: flex;
|
|
3
4
|
position: relative;
|
|
4
5
|
text-align: left;
|
|
@@ -18,4 +19,5 @@ import{styled as t}from"../../styled-components.js";const e=t.div`
|
|
|
18
19
|
box-sizing: border-box;
|
|
19
20
|
-webkit-tap-highlight-color: rgba(255, 255, 255, 0);
|
|
20
21
|
}
|
|
21
|
-
`;
|
|
22
|
+
`;
|
|
23
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1,33 @@
|
|
|
1
|
-
import{useRef
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import isDeepEqual from 'fast-deep-equal';
|
|
3
|
+
import { safeSlugify } from '../../utils/string.js';
|
|
4
|
+
export function fixSpec(resolvedSpec) {
|
|
5
|
+
const schemas = (resolvedSpec.components && resolvedSpec.components.securitySchemes) || {};
|
|
6
|
+
for (const s of Object.keys(schemas)) {
|
|
7
|
+
const scheme = schemas[s];
|
|
8
|
+
if (scheme['x-type']) {
|
|
9
|
+
scheme.type = scheme['x-type'];
|
|
10
|
+
}
|
|
11
|
+
if (scheme['x-scheme']) {
|
|
12
|
+
scheme.scheme = scheme['x-scheme'];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function useDeepCompareMemoize(value) {
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const signalRef = useRef(0);
|
|
19
|
+
if (!isDeepEqual(value, ref.current)) {
|
|
20
|
+
ref.current = value;
|
|
21
|
+
signalRef.current += 1;
|
|
22
|
+
}
|
|
23
|
+
return [signalRef.current];
|
|
24
|
+
}
|
|
25
|
+
export function getMarkdownHeaderId(children) {
|
|
26
|
+
if (typeof children[0] === 'string') {
|
|
27
|
+
return `section/${safeSlugify(children[0])}`;
|
|
28
|
+
}
|
|
29
|
+
else if (children.children) {
|
|
30
|
+
return getMarkdownHeaderId(children[0]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function RenderHook(props) {
|
|
3
|
+
if (!props.Hook)
|
|
4
|
+
return null;
|
|
5
|
+
const hookResult = props.Hook(props.props);
|
|
6
|
+
const html = hookResult && hookResult.html;
|
|
7
|
+
if (html) {
|
|
8
|
+
return _jsx("span", { dangerouslySetInnerHTML: { __html: html } });
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return hookResult;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function getAccessModeLabelText(schema) {
|
|
15
|
+
return (schema.readOnly && 'read-only') || (schema.writeOnly && 'write-only') || null;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=RenderHook.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { RenderHook, getAccessModeLabelText } from './RenderHook.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,10 +1,48 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, lazy, memo, useEffect, useState } from 'react';
|
|
3
|
+
import { useAtomValue } from 'jotai';
|
|
4
|
+
import { globalOptionsAtom } from '../../jotai/store.js';
|
|
5
|
+
import { operationStore } from '../../jotai/operation.js';
|
|
6
|
+
import { appStore, environmentsAtom } from '../../jotai/app.js';
|
|
7
|
+
import { useTranslate } from '../../hooks/index.js';
|
|
8
|
+
import { convertOperationToReplayValue } from './utils.js';
|
|
9
|
+
import { getDefaultCollectorUrl } from '../../utils/telemetry.js';
|
|
10
|
+
import { styled } from '../../styled-components.js';
|
|
11
|
+
const EmbeddedReplayOrig = lazy(async () => import('@redocly/replay').then((module) => ({ default: module.EmbeddedReplay })));
|
|
12
|
+
function EmbeddedReplayComponent({ activeOperationId, corsProxyUrl, fullOpenApi, pointer, }) {
|
|
13
|
+
const translate = useTranslate();
|
|
14
|
+
const { mockServer } = useAtomValue(globalOptionsAtom);
|
|
15
|
+
const operationState = useAtomValue(operationStore(pointer));
|
|
16
|
+
const appState = useAtomValue(appStore);
|
|
17
|
+
const envs = useAtomValue(environmentsAtom);
|
|
18
|
+
// do not render on the server, it produces some SSR Suspense error
|
|
19
|
+
const [loaded, setLoaded] = useState(false);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
setLoaded(true);
|
|
22
|
+
}, []);
|
|
23
|
+
return (_jsx(CompactWrapper, { children: loaded ? (_jsx(Suspense, { fallback: _jsx(LoadingWrapper, { children: translate('openapi.loading', 'Loading...') }), children: _jsx(EmbeddedReplayOrig, { activeOperationId: activeOperationId, activeOperationPointer: pointer, api: fullOpenApi, settings: {
|
|
24
|
+
environment: appState.environment,
|
|
25
|
+
predefinedEnvValues: envs,
|
|
26
|
+
corsProxyUrl,
|
|
27
|
+
mockServer,
|
|
28
|
+
disableCollectionsTab: true,
|
|
29
|
+
telemetry: {
|
|
30
|
+
tracerName: 'replay-openapi',
|
|
31
|
+
collectorUrl: getDefaultCollectorUrl(),
|
|
32
|
+
},
|
|
33
|
+
convertOperationToReplayValue: (path, method, openAPI) => convertOperationToReplayValue(path, method, openAPI, undefined, operationState, appState),
|
|
34
|
+
} }) })) : (_jsx(LoadingWrapper, { children: translate('openapi.loading', 'Loading...') })) }));
|
|
35
|
+
}
|
|
36
|
+
export const EmbeddedReplay = memo(EmbeddedReplayComponent);
|
|
37
|
+
const LoadingWrapper = styled.div `
|
|
2
38
|
display: flex;
|
|
3
39
|
justify-content: center;
|
|
4
40
|
align-items: center;
|
|
5
41
|
min-height: 100px;
|
|
6
|
-
|
|
42
|
+
`;
|
|
43
|
+
const CompactWrapper = styled.div `
|
|
7
44
|
border: 1px solid var(--border-color-primary);
|
|
8
45
|
border-radius: var(--border-radius-lg);
|
|
9
46
|
padding: 0;
|
|
10
|
-
`;
|
|
47
|
+
`;
|
|
48
|
+
//# sourceMappingURL=EmbeddedReplay.js.map
|
|
@@ -1 +1,99 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { lazy, memo, Suspense, useCallback, useRef, useState } from 'react';
|
|
3
|
+
import { useAtom, useAtomValue } from 'jotai';
|
|
4
|
+
import merge from 'deepmerge';
|
|
5
|
+
const ReplayOverlay = lazy(async () => import('@redocly/replay').then((module) => ({ default: module.ReplayOverlay })));
|
|
6
|
+
import { Button } from '@redocly/theme/components/Button/Button';
|
|
7
|
+
import { useFocusTrap, useModalScrollLock } from '@redocly/theme/core/openapi';
|
|
8
|
+
import { RocketIcon } from '@redocly/theme/icons/RocketIcon/RocketIcon';
|
|
9
|
+
import { CircleDashIcon } from '@redocly/theme/icons/CircleDashIcon/CircleDashIcon';
|
|
10
|
+
import { Portal } from '@redocly/theme/components/Portal/Portal';
|
|
11
|
+
import { globalOptionsAtom, globalStoreAtom } from '../../jotai/store.js';
|
|
12
|
+
import { allOperationsAtom, replayStateAtom } from '../../jotai/replay.js';
|
|
13
|
+
import { allOperations, getDefaultOperationStore } from '../../jotai/operation.js';
|
|
14
|
+
import { LOADING_STATE } from '../../constants.js';
|
|
15
|
+
import { environmentAtom, userClaimsAtom } from '../../jotai/app.js';
|
|
16
|
+
import { convertOperationToReplayValueForRedoc } from './utils.js';
|
|
17
|
+
import { useTranslate, useTelemetry } from '../../hooks/index.js';
|
|
18
|
+
import { JsonPointer } from '../../utils/index.js';
|
|
19
|
+
import { getDefaultCollectorUrl } from '../../utils/telemetry.js';
|
|
20
|
+
import { createTryItOpenEvent, createTryItSentEvent } from '../../events/index.js';
|
|
21
|
+
function ReplayComponent({ operation, corsProxyUrl, fullOpenApi }) {
|
|
22
|
+
const translate = useTranslate();
|
|
23
|
+
const telemetry = useTelemetry();
|
|
24
|
+
const replayRef = useRef(null);
|
|
25
|
+
const { mockServer, oAuth2RedirectURI, routingBasePath } = useAtomValue(globalOptionsAtom);
|
|
26
|
+
const operations = useAtomValue(allOperationsAtom);
|
|
27
|
+
const { parser, options: { events }, } = useAtomValue(globalStoreAtom);
|
|
28
|
+
const userClaims = useAtomValue(userClaimsAtom);
|
|
29
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
30
|
+
const [replayState, setReplayState] = useAtom(replayStateAtom);
|
|
31
|
+
const [allOperationsData, setAllOperations] = useAtom(allOperations);
|
|
32
|
+
const [[, envName], setEnvironment] = useAtom(environmentAtom);
|
|
33
|
+
useFocusTrap(replayRef);
|
|
34
|
+
useModalScrollLock(isOpened);
|
|
35
|
+
const handleReplayParamChange = useCallback(({ operations, environment, environments }) => {
|
|
36
|
+
const changedOperations = operations.reduce((acc, op) => {
|
|
37
|
+
op.requestValues.body =
|
|
38
|
+
op.requestValues.body instanceof URLSearchParams
|
|
39
|
+
? Object.fromEntries(op.requestValues.body.entries())
|
|
40
|
+
: op.requestValues.body;
|
|
41
|
+
const { path, method } = op.apiPath;
|
|
42
|
+
const pointer = JsonPointer.compile(['paths', path, method]);
|
|
43
|
+
acc[pointer] = merge(getDefaultOperationStore(pointer), op);
|
|
44
|
+
return acc;
|
|
45
|
+
}, {});
|
|
46
|
+
setAllOperations({ ...allOperationsData, ...changedOperations });
|
|
47
|
+
setEnvironment({ environment, environments });
|
|
48
|
+
}, [allOperationsData, setAllOperations, setEnvironment]);
|
|
49
|
+
const handleToggle = () => {
|
|
50
|
+
if (replayState !== LOADING_STATE.LOADING) {
|
|
51
|
+
if (!isOpened) {
|
|
52
|
+
telemetry.send({ type: 'openapi_docs.try_it.opened' });
|
|
53
|
+
if (events?.tryItOpen && operation) {
|
|
54
|
+
const eventPayload = createTryItOpenEvent({
|
|
55
|
+
operation: operation,
|
|
56
|
+
});
|
|
57
|
+
events.tryItOpen(eventPayload);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
setIsOpened(!isOpened);
|
|
61
|
+
}
|
|
62
|
+
if (replayState === LOADING_STATE.NOT_LOADED) {
|
|
63
|
+
setReplayState(LOADING_STATE.LOADING);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const handleTryItSent = useCallback((isSuccess) => {
|
|
67
|
+
if (events?.tryItSent && operation) {
|
|
68
|
+
const eventPayload = createTryItSentEvent({ operation, isSuccess });
|
|
69
|
+
events.tryItSent(eventPayload);
|
|
70
|
+
}
|
|
71
|
+
}, [events, operation]);
|
|
72
|
+
const getOperationUrl = useCallback((operationId) => {
|
|
73
|
+
if (!operationId)
|
|
74
|
+
return;
|
|
75
|
+
const operation = operations.find((op) => op.operationId === operationId);
|
|
76
|
+
return routingBasePath + operation?.href;
|
|
77
|
+
}, [operations, routingBasePath]);
|
|
78
|
+
if (!fullOpenApi)
|
|
79
|
+
return null;
|
|
80
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: handleToggle, variant: "primary", iconPosition: "left", icon: replayState === LOADING_STATE.LOADING ? _jsx(CircleDashIcon, {}) : _jsx(RocketIcon, {}), children: replayState === LOADING_STATE.LOADING
|
|
81
|
+
? translate('openapi.loading', 'Loading...')
|
|
82
|
+
: translate('openapi.tryIt', 'Try it') }), isOpened && (_jsx(Suspense, { children: _jsx(Portal, { mountId: "api-content", children: _jsx("div", { ref: replayRef, children: _jsx(ReplayOverlay, { activeOperationId: operation.operationId || operation.pointer, api: fullOpenApi, onRequestChange: handleReplayParamChange, onClose: handleToggle, onLoad: () => setReplayState(LOADING_STATE.LOADED), settings: {
|
|
83
|
+
corsProxyUrl,
|
|
84
|
+
mockServer,
|
|
85
|
+
environment: envName,
|
|
86
|
+
apiId: parser?.definition.info?.['x-metadata']?.apiId,
|
|
87
|
+
oAuth2RedirectURI,
|
|
88
|
+
disableCollectionsTab: true,
|
|
89
|
+
storageKey: routingBasePath,
|
|
90
|
+
telemetry: {
|
|
91
|
+
tracerName: 'try-it',
|
|
92
|
+
collectorUrl: getDefaultCollectorUrl(),
|
|
93
|
+
},
|
|
94
|
+
convertOperationToReplayValue: (path, method, openAPI) => convertOperationToReplayValueForRedoc(userClaims)(path, method, openAPI),
|
|
95
|
+
getOperationUrl,
|
|
96
|
+
}, ...{ onRequestSent: handleTryItSent } }) }) }) }))] }));
|
|
97
|
+
}
|
|
98
|
+
export const Replay = memo(ReplayComponent);
|
|
99
|
+
//# sourceMappingURL=Replay.js.map
|