@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,63 @@
|
|
|
1
|
-
import{encodeBackSlashes
|
|
1
|
+
import { encodeBackSlashes, queryString } from '../../utils/index.js';
|
|
2
|
+
import { getActiveMediaType } from '../../models/mediaContent.js';
|
|
3
|
+
export function isSameHash(a, b) {
|
|
4
|
+
return a === b || '#' + a === b || a === '#' + b;
|
|
5
|
+
}
|
|
6
|
+
// TODO: Add tests
|
|
7
|
+
function getContentTypeName(field, activeMimeName) {
|
|
8
|
+
// param in "query" | "header" | "path" | "cookie" - no need for content type in link
|
|
9
|
+
if (field.in) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
// Use content type from requestBody
|
|
13
|
+
if (field.deps.type === 'request') {
|
|
14
|
+
if (field.deps.operation?.requestBody?.content?.mediaTypes) {
|
|
15
|
+
return field.deps.operation?.requestBody?.content?.mediaTypes.length > 1
|
|
16
|
+
? field.deps.operation?.requestBody?.content &&
|
|
17
|
+
getActiveMediaType(field.deps.operation.requestBody.content, activeMimeName).name
|
|
18
|
+
: undefined; // if only one content type present - also no need for content type in link
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
// Use content type from response
|
|
22
|
+
if (field.deps.type === 'response') {
|
|
23
|
+
if (field.deps.response?.content?.mediaTypes) {
|
|
24
|
+
return field.deps.response?.content?.mediaTypes.length > 1
|
|
25
|
+
? field.deps.response?.content &&
|
|
26
|
+
getActiveMediaType(field.deps.response.content, activeMimeName).name
|
|
27
|
+
: undefined; // if only one content type present - also no need for content type in link
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// TODO: Add tests
|
|
33
|
+
export function constructFieldDeepFragment(field, activeMimeName) {
|
|
34
|
+
if (!field) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
const linkParams = {
|
|
38
|
+
t: field.deps.type, // "request" | "response"
|
|
39
|
+
in: field.in || field.deps.in, // "query" | "header" | "path" | "cookie" // TODO: remove 'in' from deps
|
|
40
|
+
c: field.deps.type === 'response' ? field.deps.response?.code : undefined, // response code: 200 | 201 | 400 | etc
|
|
41
|
+
cb: field.deps.operation?.isCallback ? field.deps.operation.callbackId : undefined, // Callback
|
|
42
|
+
ct: getContentTypeName(field, activeMimeName),
|
|
43
|
+
path: field.fieldFullPath, // Field deep path
|
|
44
|
+
};
|
|
45
|
+
return queryString.stringify(linkParams, { encode: false, sort: false });
|
|
46
|
+
}
|
|
47
|
+
export function joinWithSeparator(base = '', path = '', sep = '/') {
|
|
48
|
+
if (base.endsWith(sep)) {
|
|
49
|
+
base = base.slice(0, -sep.length);
|
|
50
|
+
}
|
|
51
|
+
if (path.startsWith(sep)) {
|
|
52
|
+
path = path.slice(sep.length);
|
|
53
|
+
}
|
|
54
|
+
if (!base || !path) {
|
|
55
|
+
return base + path;
|
|
56
|
+
}
|
|
57
|
+
return base + sep + path;
|
|
58
|
+
}
|
|
59
|
+
export function makeDeepLink(operationId, suffix) {
|
|
60
|
+
operationId = encodeBackSlashes(operationId);
|
|
61
|
+
return (`/${operationId}#` + joinWithSeparator(operationId, suffix)).toLowerCase();
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export*from
|
|
1
|
+
export * from './helpers.js'; // TODO: move or remove
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
package/lib/services/index.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export*
|
|
1
|
+
export * from './history/index.js';
|
|
2
|
+
export * from './code-samples/index.js';
|
|
3
|
+
export * from './types.js';
|
|
4
|
+
export { OpenAPIParser } from './OpenAPIParser.js';
|
|
5
|
+
export { buildContentItems } from './menu/index.js';
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export * from './config-options/index.js';
|
|
8
|
+
export { deepClone } from './utils.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,47 @@
|
|
|
1
|
-
import{getTagGroupsItems
|
|
1
|
+
import { getTagGroupsItems, getTagsItems, getTagsWithOperations } from './tags.js';
|
|
2
|
+
import { addMarkdownItems } from './markdown.js';
|
|
3
|
+
import { flattenByProp, getValueFromMdParsedExtension } from '../../utils/index.js';
|
|
4
|
+
import { DEFAULT_WEBHOOKS_TAG_NAME } from '../../constants.js';
|
|
5
|
+
export function buildMenuStructure(parser, options) {
|
|
6
|
+
const { definition } = parser;
|
|
7
|
+
const { schemaDefinitionsTagName } = options;
|
|
8
|
+
const items = [
|
|
9
|
+
{
|
|
10
|
+
id: '',
|
|
11
|
+
name: definition?.info?.['x-seo']?.title || definition?.info?.title || 'Overview',
|
|
12
|
+
href: '/',
|
|
13
|
+
depth: 1, // special case for root item,
|
|
14
|
+
level: 1,
|
|
15
|
+
type: 'section',
|
|
16
|
+
infoDefinition: definition.info,
|
|
17
|
+
items: [],
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
const tags = [...(definition.tags || [])];
|
|
21
|
+
if (!tags.some((tag) => tag.name === DEFAULT_WEBHOOKS_TAG_NAME)) {
|
|
22
|
+
tags.push({ name: DEFAULT_WEBHOOKS_TAG_NAME });
|
|
23
|
+
}
|
|
24
|
+
const hasAutogenerated = tags.find((tag) => tag?.name === schemaDefinitionsTagName);
|
|
25
|
+
if (!hasAutogenerated && schemaDefinitionsTagName) {
|
|
26
|
+
tags.push({ name: schemaDefinitionsTagName });
|
|
27
|
+
}
|
|
28
|
+
const tagsMap = getTagsWithOperations(parser, tags);
|
|
29
|
+
const xTagGroups = definition['x-tagGroups'];
|
|
30
|
+
items.push(...addMarkdownItems(getValueFromMdParsedExtension(definition.info, 'description') || '', undefined, 1));
|
|
31
|
+
if (xTagGroups && xTagGroups.length > 0) {
|
|
32
|
+
items.push(...getTagGroupsItems(parser, undefined, xTagGroups, tagsMap, options));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
items.push(...getTagsItems(parser, tagsMap, undefined, undefined, options));
|
|
36
|
+
}
|
|
37
|
+
return items;
|
|
38
|
+
}
|
|
39
|
+
export function buildContentItems(parser, options) {
|
|
40
|
+
const contentItems = buildMenuStructure(parser, options);
|
|
41
|
+
const flatItems = flattenByProp(contentItems || [], 'items');
|
|
42
|
+
return {
|
|
43
|
+
contentItems,
|
|
44
|
+
flatItems,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { buildContentItems } from './builder.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,93 @@
|
|
|
1
|
-
import
|
|
1
|
+
import markdoc from '@markdoc/markdoc';
|
|
2
|
+
import { isString } from '@redocly/theme/core/openapi';
|
|
3
|
+
import { getTagOrGroup } from '../../models/index.js';
|
|
4
|
+
import { safeSlugify, unescapeHTMLChars } from '../../utils/index.js';
|
|
5
|
+
import { simplifyAstStructure } from '../../utils/simplifyAstStructure.js';
|
|
6
|
+
/**
|
|
7
|
+
* extracts items from markdown description
|
|
8
|
+
* @param description - markdown source
|
|
9
|
+
* @param parent
|
|
10
|
+
* @param initialDepth - number of items depth
|
|
11
|
+
*/
|
|
12
|
+
export function addMarkdownItems(description, parent, initialDepth) {
|
|
13
|
+
const ast = isString(description)
|
|
14
|
+
? simplifyAstStructure(markdoc.parse(description))
|
|
15
|
+
: markdoc.Ast.fromJSON(JSON.stringify(description?.result));
|
|
16
|
+
const items = [];
|
|
17
|
+
let currentTopHeading;
|
|
18
|
+
const saveHeading = (name, level, container = items, node, parentId) => {
|
|
19
|
+
name = unescapeHTMLChars(name);
|
|
20
|
+
// use custom id or generate id
|
|
21
|
+
let id;
|
|
22
|
+
if (node.attributes.id) {
|
|
23
|
+
id = node.attributes.id;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
id = parentId ? `${parentId}/${safeSlugify(name)}` : `section/${safeSlugify(name)}`;
|
|
27
|
+
node.attributes.id = id;
|
|
28
|
+
}
|
|
29
|
+
const item = {
|
|
30
|
+
id: id.toLowerCase(),
|
|
31
|
+
name,
|
|
32
|
+
level,
|
|
33
|
+
items: [],
|
|
34
|
+
ast: [node],
|
|
35
|
+
};
|
|
36
|
+
container.push(item);
|
|
37
|
+
return item;
|
|
38
|
+
};
|
|
39
|
+
const saveContent = (container, node) => {
|
|
40
|
+
container[container.length - 1]?.ast?.push(node);
|
|
41
|
+
};
|
|
42
|
+
const processAst = (node) => {
|
|
43
|
+
const name = getMarkdownContent(node) || '';
|
|
44
|
+
// use tag id as prefix instead of just "section" to avoid identical header ids in different tags
|
|
45
|
+
const isTagContext = parent && parent.type === 'tag';
|
|
46
|
+
const parentId = isTagContext ? parent.id : undefined;
|
|
47
|
+
if (node.type === 'heading' && node.attributes.level === 1) {
|
|
48
|
+
// h1
|
|
49
|
+
currentTopHeading = saveHeading(name, node.attributes.level, undefined, node, parentId);
|
|
50
|
+
}
|
|
51
|
+
else if (node.attributes.level) {
|
|
52
|
+
// h2, h3, h4 etc
|
|
53
|
+
saveHeading(name, node.attributes.level, currentTopHeading?.items, node, currentTopHeading?.id ?? parentId);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// text, p, etc
|
|
57
|
+
if (currentTopHeading?.items?.length) {
|
|
58
|
+
saveContent(currentTopHeading?.items, node);
|
|
59
|
+
}
|
|
60
|
+
else if (items?.length) {
|
|
61
|
+
saveContent(items, node);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (Array.isArray(ast)) {
|
|
66
|
+
for (const node of ast) {
|
|
67
|
+
processAst(node);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
processAst(ast);
|
|
72
|
+
}
|
|
73
|
+
return mapHeadingsDeep(parent, items, initialDepth);
|
|
74
|
+
}
|
|
75
|
+
function mapHeadingsDeep(parent, items, depth = 1) {
|
|
76
|
+
return items.map((heading) => {
|
|
77
|
+
const group = getTagOrGroup('section', heading, parent);
|
|
78
|
+
group.depth = depth;
|
|
79
|
+
if (heading.items) {
|
|
80
|
+
group.items = mapHeadingsDeep(group, heading.items, depth + 1);
|
|
81
|
+
}
|
|
82
|
+
return group;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function getMarkdownContent(node) {
|
|
86
|
+
if (typeof node?.attributes?.content === 'string') {
|
|
87
|
+
return node.attributes?.content;
|
|
88
|
+
}
|
|
89
|
+
if (node?.children) {
|
|
90
|
+
return getMarkdownContent(node.children[0]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
import{REDOCLY_TEAMS_RBAC
|
|
1
|
+
import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
|
|
2
|
+
import { encodeBackSlashes, getOperationId, getOperationName } from '../../utils/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns array of Operation items for the tag
|
|
5
|
+
* @param parent parent OperationsGroup
|
|
6
|
+
* @param tag tag info returned from `getTagsWithOperations`
|
|
7
|
+
* @param depth items depth
|
|
8
|
+
*/
|
|
9
|
+
export function getOperationsItems(parent, tag, depth) {
|
|
10
|
+
if (tag.operations.length === 0) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const operations = [];
|
|
14
|
+
const webhooks = [];
|
|
15
|
+
for (const operationDefinition of tag.operations) {
|
|
16
|
+
const id = getOperationId(operationDefinition, parent);
|
|
17
|
+
const type = 'operation';
|
|
18
|
+
const item = {
|
|
19
|
+
id,
|
|
20
|
+
type,
|
|
21
|
+
parent,
|
|
22
|
+
operationDefinition,
|
|
23
|
+
depth,
|
|
24
|
+
name: getOperationName(operationDefinition),
|
|
25
|
+
httpVerb: operationDefinition.httpVerb,
|
|
26
|
+
path: operationDefinition.pathName,
|
|
27
|
+
items: [],
|
|
28
|
+
isWebhook: operationDefinition.isWebhook,
|
|
29
|
+
operationId: operationDefinition.operationId,
|
|
30
|
+
badges: operationDefinition['x-badges'] || [],
|
|
31
|
+
href: getHref({ id }),
|
|
32
|
+
deprecated: !!operationDefinition.deprecated,
|
|
33
|
+
[REDOCLY_TEAMS_RBAC]: operationDefinition[REDOCLY_TEAMS_RBAC] || parent?.[REDOCLY_TEAMS_RBAC],
|
|
34
|
+
};
|
|
35
|
+
if (operationDefinition.isWebhook) {
|
|
36
|
+
webhooks.push(item);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
operations.push(item);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return [
|
|
43
|
+
...operations.sort((a, b) => Number(a.deprecated) - Number(b.deprecated)),
|
|
44
|
+
...webhooks.sort((a, b) => Number(a.deprecated) - Number(b.deprecated)), // webhooks must be in the end for adding separator
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
export function getHref({ id }) {
|
|
48
|
+
return encodeBackSlashes(`/${id}`.toLowerCase());
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -1 +1,166 @@
|
|
|
1
|
-
import{getTagOrGroup
|
|
1
|
+
import { getTagOrGroup } from '../../models/group.js';
|
|
2
|
+
import { DEFAULT_WEBHOOKS_TAG_NAME, GROUP_DEPTH } from '../../constants.js';
|
|
3
|
+
import { getValueFromMdParsedExtension, isOperationName, JsonPointer } from '../../utils/index.js';
|
|
4
|
+
import { getOperationsItems } from './operation.js';
|
|
5
|
+
import { addMarkdownItems } from './markdown.js';
|
|
6
|
+
/**
|
|
7
|
+
* Returns array of OperationsGroup items for the tags of the group or for all tags
|
|
8
|
+
* @param parser
|
|
9
|
+
* @param tagsMap tags info returned from `getTagsWithOperations`
|
|
10
|
+
* @param parent parent item
|
|
11
|
+
* @param group group which this tag belongs to. if not provided gets all tags
|
|
12
|
+
* @param options - normalized options
|
|
13
|
+
*/
|
|
14
|
+
export function getTagsItems(parser, tagsMap, parent, group, options) {
|
|
15
|
+
let tagNames;
|
|
16
|
+
if (group === undefined) {
|
|
17
|
+
tagNames = Object.keys(tagsMap);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
tagNames = group.tags;
|
|
21
|
+
}
|
|
22
|
+
if (!Array.isArray(tagNames)) {
|
|
23
|
+
console.warn('Unexpected values of tags. Check tags or x-tagGroups in your definition.');
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const tags = tagNames.map((tagName) => {
|
|
27
|
+
if (!tagsMap[tagName]) {
|
|
28
|
+
console.warn(`Non-existing tag "${tagName}" is added to the group "${group?.name}"`);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
tagsMap[tagName].used = true;
|
|
32
|
+
return tagsMap[tagName];
|
|
33
|
+
});
|
|
34
|
+
const res = [];
|
|
35
|
+
for (const tag of tags) {
|
|
36
|
+
if (!tag)
|
|
37
|
+
continue;
|
|
38
|
+
const item = getTagOrGroup('tag', tag, parent);
|
|
39
|
+
item.depth = GROUP_DEPTH + 1;
|
|
40
|
+
// don't put empty tag into content, instead put its operations
|
|
41
|
+
if (tag.name === '') {
|
|
42
|
+
const items = [
|
|
43
|
+
...addMarkdownItems(getValueFromMdParsedExtension(tag, 'description') || '', item, item.depth + 1),
|
|
44
|
+
...getOperationsItems(undefined, tag, item.depth + 1),
|
|
45
|
+
];
|
|
46
|
+
res.push(...items);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const relatedSchemas = getTagRelatedSchema({
|
|
50
|
+
definition: parser.definition,
|
|
51
|
+
tag,
|
|
52
|
+
parent: item,
|
|
53
|
+
schemaDefinitionsTagName: options.schemaDefinitionsTagName,
|
|
54
|
+
});
|
|
55
|
+
item.items = [
|
|
56
|
+
...relatedSchemas,
|
|
57
|
+
...addMarkdownItems(getValueFromMdParsedExtension(tag, 'description') || '', item, item.depth + 1),
|
|
58
|
+
...getOperationsItems(item, tag, item.depth + 1),
|
|
59
|
+
];
|
|
60
|
+
res.push(item);
|
|
61
|
+
}
|
|
62
|
+
return res.filter(({ name, items }) => name !== DEFAULT_WEBHOOKS_TAG_NAME || items.length > 0);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns array of OperationsGroup items for the tag groups (x-tagGroups vendor extension)
|
|
66
|
+
* @param parser
|
|
67
|
+
* @param parent
|
|
68
|
+
* @param groups
|
|
69
|
+
* @param tags value of `x-tagGroups` vendor extension
|
|
70
|
+
* @param options - normalized options
|
|
71
|
+
*/
|
|
72
|
+
export function getTagGroupsItems(parser, parent, groups, tags, options) {
|
|
73
|
+
const res = [];
|
|
74
|
+
for (const group of groups) {
|
|
75
|
+
const item = getTagOrGroup('group', group, parent);
|
|
76
|
+
item.depth = GROUP_DEPTH;
|
|
77
|
+
item.items = getTagsItems(parser, tags, item, group, options);
|
|
78
|
+
res.push(item);
|
|
79
|
+
}
|
|
80
|
+
return res;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns array of schemas with reference to tag, or schemas with reference to schemaDefinitionsTagName tag
|
|
84
|
+
* @param tagsMap all tags
|
|
85
|
+
* @param tag tag to find reference of schema
|
|
86
|
+
* @param schemaDefinitionsTagName config
|
|
87
|
+
*/
|
|
88
|
+
function getTagRelatedSchema({ definition, tag, parent, schemaDefinitionsTagName, }) {
|
|
89
|
+
const defaultTags = schemaDefinitionsTagName ? [schemaDefinitionsTagName] : [];
|
|
90
|
+
return Object.entries(definition.components?.schemas || {})
|
|
91
|
+
.map(([schemaName, schema]) => {
|
|
92
|
+
const schemaTags = schema['x-tags'] || defaultTags;
|
|
93
|
+
if (!schemaTags.includes(tag.name))
|
|
94
|
+
return null;
|
|
95
|
+
const item = getTagOrGroup('schema', {
|
|
96
|
+
name: schemaName,
|
|
97
|
+
'x-displayName': `${schema.title || schemaName}`,
|
|
98
|
+
description: `{% schemaDefinition showWriteOnly="true" schemaRef="#/components/schemas/${schemaName}" /%}`,
|
|
99
|
+
isSchema: true,
|
|
100
|
+
level: 2,
|
|
101
|
+
}, parent);
|
|
102
|
+
item.depth = parent.depth + 1;
|
|
103
|
+
return item;
|
|
104
|
+
})
|
|
105
|
+
.filter(Boolean);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* collects tags and maps each tag to list of operations belonging to this tag
|
|
109
|
+
*/
|
|
110
|
+
export function getTagsWithOperations(parser, explicitTags) {
|
|
111
|
+
const { definition } = parser;
|
|
112
|
+
const tags = {};
|
|
113
|
+
const webhooks = definition['x-webhooks'] || definition.webhooks;
|
|
114
|
+
for (const tag of explicitTags || []) {
|
|
115
|
+
tags[tag.name] = { ...tag, operations: [] };
|
|
116
|
+
}
|
|
117
|
+
if (definition.paths) {
|
|
118
|
+
getTags(parser, definition.paths, tags);
|
|
119
|
+
}
|
|
120
|
+
if (webhooks) {
|
|
121
|
+
getTags(parser, webhooks, tags, true);
|
|
122
|
+
}
|
|
123
|
+
return tags;
|
|
124
|
+
}
|
|
125
|
+
function getTags(parser, paths, tags, isWebhook) {
|
|
126
|
+
for (const pathName of Object.keys(paths || {})) {
|
|
127
|
+
const path = paths[pathName];
|
|
128
|
+
const operations = Object.keys(path).filter(isOperationName);
|
|
129
|
+
for (const operationName of operations) {
|
|
130
|
+
const operationInfo = path[operationName];
|
|
131
|
+
if (path.$ref) {
|
|
132
|
+
const { resolved: resolvedPaths } = parser.deref(path);
|
|
133
|
+
getTags(parser, { [pathName]: resolvedPaths }, tags, isWebhook);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
let operationTags = operationInfo?.tags;
|
|
137
|
+
if (!operationTags || !operationTags.length) {
|
|
138
|
+
// empty tag for operations and default tag for webhooks
|
|
139
|
+
operationTags = isWebhook ? [DEFAULT_WEBHOOKS_TAG_NAME] : [''];
|
|
140
|
+
}
|
|
141
|
+
for (const tagName of operationTags) {
|
|
142
|
+
let tag = tags[tagName];
|
|
143
|
+
if (tag === undefined) {
|
|
144
|
+
tag = {
|
|
145
|
+
name: tagName,
|
|
146
|
+
operations: [],
|
|
147
|
+
};
|
|
148
|
+
tags[tagName] = tag;
|
|
149
|
+
}
|
|
150
|
+
if (tag['x-traitTag']) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
tag.operations.push({
|
|
154
|
+
...operationInfo,
|
|
155
|
+
pathName,
|
|
156
|
+
pointer: JsonPointer.compile(['paths', pathName, operationName]),
|
|
157
|
+
httpVerb: operationName,
|
|
158
|
+
pathParameters: path.parameters || [],
|
|
159
|
+
pathServers: path.servers,
|
|
160
|
+
isWebhook: !!isWebhook,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=tags.js.map
|
package/lib/services/types.d.ts
CHANGED
package/lib/services/types.js
CHANGED
package/lib/services/utils.js
CHANGED
|
@@ -1 +1,83 @@
|
|
|
1
|
-
import
|
|
1
|
+
import merge from 'deepmerge';
|
|
2
|
+
import { isObject } from '@redocly/theme/core/openapi';
|
|
3
|
+
import { isMergeableObject } from '../utils/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Compare mime-types ignoring charset or other params (application/json;charset=UTF-8)
|
|
6
|
+
* @param a
|
|
7
|
+
* @param b
|
|
8
|
+
*/
|
|
9
|
+
export function isSameMime(a, b) {
|
|
10
|
+
if (!a || !b)
|
|
11
|
+
return false;
|
|
12
|
+
return normalizeMimeType(a) === normalizeMimeType(b);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Removes the mime-types params e.g. charset (application/json;charset=UTF-8))
|
|
16
|
+
* Removes any prefixes, e.g. application/hal+json => application/json
|
|
17
|
+
* Spec is type/subtype;param1=value or type/semantic+format;param1=value
|
|
18
|
+
* @param mimeType mime type string or undefined
|
|
19
|
+
*/
|
|
20
|
+
export function normalizeMimeType(mimeType) {
|
|
21
|
+
if (!mimeType)
|
|
22
|
+
return undefined;
|
|
23
|
+
const mime = mimeType.split(';')[0].toLowerCase(); // get rid of parameters part
|
|
24
|
+
const [type, subtype] = mime.split('/');
|
|
25
|
+
if (subtype === undefined) {
|
|
26
|
+
return type; // some wrong format, return as is
|
|
27
|
+
}
|
|
28
|
+
const subtypeParts = subtype.split('+');
|
|
29
|
+
const syntax = subtypeParts.pop();
|
|
30
|
+
return `${type}/${syntax}`;
|
|
31
|
+
}
|
|
32
|
+
export function unescapeServerVariables(str) {
|
|
33
|
+
// Brackets are escaped in the curl code samples #88
|
|
34
|
+
// ex.: http://localhost:7700/code-samples-playground?versions#operation/Case-11_1
|
|
35
|
+
const bracketsOpenReg = new RegExp('%7B', 'g'); // {
|
|
36
|
+
const bracketsCloseReg = new RegExp('%7D', 'g'); // }
|
|
37
|
+
return str
|
|
38
|
+
.replace(bracketsOpenReg, '{')
|
|
39
|
+
.replace(bracketsCloseReg, '}')
|
|
40
|
+
.replace('///', '//')
|
|
41
|
+
.replace('./', '.');
|
|
42
|
+
}
|
|
43
|
+
export function arrayMergeStrategy(target, source) {
|
|
44
|
+
if (!(target.length && hasObjectOrArray(target))) {
|
|
45
|
+
return source;
|
|
46
|
+
}
|
|
47
|
+
const destination = target.filter((item) => Object.keys(item).length > 0);
|
|
48
|
+
source.forEach(function (item, index) {
|
|
49
|
+
if (isMergeableObject(item)) {
|
|
50
|
+
destination[index] = merge(target[index], item, { arrayMerge: arrayMergeStrategy });
|
|
51
|
+
}
|
|
52
|
+
else if (Array.isArray(item)) {
|
|
53
|
+
destination.push(item);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
destination[index] = item;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return destination;
|
|
60
|
+
}
|
|
61
|
+
const hasObjectOrArray = (array) => {
|
|
62
|
+
return array.some((item) => isObject(item) && Object.keys(item).length > 0);
|
|
63
|
+
};
|
|
64
|
+
export function isEmptyObject(obj) {
|
|
65
|
+
return !!obj && Object.keys(obj).length === 0;
|
|
66
|
+
}
|
|
67
|
+
export const cryptoLib = (typeof window !== 'undefined' &&
|
|
68
|
+
(window.crypto || window.msCrypto)) ||
|
|
69
|
+
undefined;
|
|
70
|
+
export function deepClone(inObject) {
|
|
71
|
+
if (typeof inObject !== 'object' || inObject === null) {
|
|
72
|
+
return inObject; // Return the value if inObject is not an object
|
|
73
|
+
}
|
|
74
|
+
// Create an array or object to hold the values
|
|
75
|
+
const outObject = Array.isArray(inObject) ? [] : {};
|
|
76
|
+
for (const key in inObject) {
|
|
77
|
+
const value = inObject[key];
|
|
78
|
+
// Recursively (deep) copy for nested objects, including arrays
|
|
79
|
+
outObject[key] = deepClone(value);
|
|
80
|
+
}
|
|
81
|
+
return outObject;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/standalone.js
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { createRoot, hydrateRoot } from 'react-dom/client';
|
|
4
|
+
import { querySelector } from './utils/dom.js';
|
|
5
|
+
import { RedoclyOpenAPIDocs } from './components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js';
|
|
6
|
+
import { RedoclyOpenAPIDocsStandalone } from './components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js';
|
|
7
|
+
export { setSecurityDetails, setSecurityDetailsVariants } from './utils/security-details.js';
|
|
8
|
+
export { setParameterValue } from './utils/parameters.js';
|
|
9
|
+
function attributesMap(element) {
|
|
10
|
+
const res = {};
|
|
11
|
+
const elAttrs = element.attributes;
|
|
12
|
+
// tslint:disable-next-line
|
|
13
|
+
for (let i = 0; i < elAttrs.length; i++) {
|
|
14
|
+
const attrib = elAttrs[i];
|
|
15
|
+
res[attrib.name] = attrib.value;
|
|
16
|
+
}
|
|
17
|
+
return res;
|
|
18
|
+
}
|
|
19
|
+
function parseOptionsFromElement(element) {
|
|
20
|
+
const attrMap = attributesMap(element);
|
|
21
|
+
const res = {};
|
|
22
|
+
for (const attrName in attrMap) {
|
|
23
|
+
const optionName = attrName.replace(/-(.)/g, (_, $1) => $1.toUpperCase());
|
|
24
|
+
res[optionName] = attrMap[attrName];
|
|
25
|
+
// TODO: normalize options
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
export function hydrate(store, element = document.querySelector('redoc')) {
|
|
30
|
+
// const store = ProStore.fromJS(state);
|
|
31
|
+
hydrateRoot(element, _jsx(RedoclyOpenAPIDocs, { store: store }));
|
|
32
|
+
}
|
|
33
|
+
export function init(definitionOrDefinitionUrl, options = {}, element = querySelector('redoc')) {
|
|
34
|
+
if (element === null) {
|
|
35
|
+
throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');
|
|
36
|
+
}
|
|
37
|
+
let definitionUrl;
|
|
38
|
+
let definition;
|
|
39
|
+
if (typeof definitionOrDefinitionUrl === 'string') {
|
|
40
|
+
definitionUrl = definitionOrDefinitionUrl;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof definitionOrDefinitionUrl === 'object') {
|
|
43
|
+
definition = definitionOrDefinitionUrl;
|
|
44
|
+
}
|
|
45
|
+
const root = createRoot(element);
|
|
46
|
+
root.render(createElement(RedoclyOpenAPIDocsStandalone, {
|
|
47
|
+
definition,
|
|
48
|
+
definitionUrl,
|
|
49
|
+
options: { ...options, ...parseOptionsFromElement(element) },
|
|
50
|
+
}, ['Loading...']));
|
|
51
|
+
}
|
|
52
|
+
export const version = __REDOCLY_API_REFERENCE_VERSION__;
|
|
53
|
+
export const revision = __REDOCLY_API_REFERENCE_REVISION__;
|
|
54
|
+
/**
|
|
55
|
+
* autoinit ReDoc if <redoc> tag is found on the page with "spec-url" attr
|
|
56
|
+
*/
|
|
57
|
+
function autoInit() {
|
|
58
|
+
const element = querySelector('redoc');
|
|
59
|
+
if (!element) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const specUrl = element.getAttribute('spec-url');
|
|
63
|
+
if (specUrl) {
|
|
64
|
+
init(specUrl, {}, element);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
autoInit();
|
|
68
|
+
//# sourceMappingURL=standalone.js.map
|
package/lib/styled-components.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _styled from 'styled-components';
|
|
2
|
+
// https://github.com/styled-components/styled-components/issues/3601#issue-1023120934
|
|
3
|
+
export const styled =
|
|
4
|
+
// @ts-expect-error incompatibility between styled-components and @types/styled-components
|
|
5
|
+
typeof _styled === 'function' ? _styled : _styled.default;
|
|
6
|
+
//# sourceMappingURL=styled-components.js.map
|
package/lib/types/app.js
CHANGED
package/lib/types/index.js
CHANGED
package/lib/types/open-api.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ export interface OpenAPIOperation extends ParsedDescriptionWithSummary {
|
|
|
105
105
|
'x-codeSamples'?: OpenAPIXCodeSample[];
|
|
106
106
|
'x-badges'?: OpenAPIXBadges[];
|
|
107
107
|
'x-hideReplay'?: boolean;
|
|
108
|
+
'x-owner-key'?: string;
|
|
108
109
|
}
|
|
109
110
|
export interface OpenAPIParameter extends ParsedDescription {
|
|
110
111
|
name: string;
|