@redocly/openapi-docs 3.12.0 → 3.12.2
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 +753 -750
- 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 +16 -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.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 +40 -7
- 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.js +12 -6
- 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 +52 -29
- 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.js +252 -3
- 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.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.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 +4 -4
|
@@ -1 +1,321 @@
|
|
|
1
|
-
import{IS_BROWSER
|
|
1
|
+
import { IS_BROWSER, isObject, isString, isUndefined } from '@redocly/theme/core/openapi';
|
|
2
|
+
import { tryDecodeURIComponent, getDefinitionName } from '../utils/index.js';
|
|
3
|
+
import { JsonPointer } from '../utils/JsonPointer.js';
|
|
4
|
+
import { normalizeOptions } from './config-options/normalizeOptions.js';
|
|
5
|
+
/**
|
|
6
|
+
* Loads and keeps spec. Provides raw spec operations
|
|
7
|
+
*/
|
|
8
|
+
export function pushRef(stack, ref) {
|
|
9
|
+
return ref && stack[stack.length - 1] !== ref ? [...stack, ref] : stack;
|
|
10
|
+
}
|
|
11
|
+
export function concatRefStacks(base, stack) {
|
|
12
|
+
return stack ? base.concat(stack) : base;
|
|
13
|
+
}
|
|
14
|
+
export class OpenAPIParser {
|
|
15
|
+
options;
|
|
16
|
+
definitionUrl;
|
|
17
|
+
definition;
|
|
18
|
+
// private _refCounter: RefCounter = new RefCounter();
|
|
19
|
+
allowMergeRefs = false;
|
|
20
|
+
constructor(definition, definitionUrl, options = normalizeOptions({})) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.definition = Object.assign({}, definition);
|
|
23
|
+
this.validate(definition);
|
|
24
|
+
this.definition = definition;
|
|
25
|
+
this.allowMergeRefs = definition.openapi.startsWith('3.1');
|
|
26
|
+
const href = IS_BROWSER ? window.location.href : '';
|
|
27
|
+
if (isString(definitionUrl)) {
|
|
28
|
+
this.definitionUrl = new URL(definitionUrl, href).href;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
validate(spec) {
|
|
32
|
+
if (isUndefined(spec.openapi)) {
|
|
33
|
+
throw new Error('Document must be valid OpenAPI 3.0.0 definition');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* get spec part by JsonPointer ($ref)
|
|
38
|
+
*/
|
|
39
|
+
byRef = (ref) => {
|
|
40
|
+
let res;
|
|
41
|
+
if (!this.definition) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (ref.charAt(0) !== '#') {
|
|
45
|
+
ref = '#' + ref;
|
|
46
|
+
}
|
|
47
|
+
ref = tryDecodeURIComponent(ref);
|
|
48
|
+
try {
|
|
49
|
+
res = JsonPointer.get(this.definition, ref);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// do nothing
|
|
53
|
+
}
|
|
54
|
+
return res || {};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* checks if the object is OpenAPI reference (contains $ref property)
|
|
58
|
+
*/
|
|
59
|
+
isRef(obj) {
|
|
60
|
+
if (!obj) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
obj = obj;
|
|
64
|
+
return obj.$ref !== undefined && obj.$ref !== null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve given reference object or return as is if it is not a reference
|
|
68
|
+
* @param obj object to dereference
|
|
69
|
+
* @param baseRefsStack
|
|
70
|
+
* @param mergeAsAllOf
|
|
71
|
+
*/
|
|
72
|
+
deref(obj, baseRefsStack = [], mergeAsAllOf = false, level = 0) {
|
|
73
|
+
// this can be set by all of when it merges props from different sources
|
|
74
|
+
const objRefsStack = obj?.['x-refsStack'];
|
|
75
|
+
baseRefsStack = concatRefStacks(baseRefsStack, objRefsStack);
|
|
76
|
+
if (level > 5) {
|
|
77
|
+
return {
|
|
78
|
+
resolved: Object.assign({}, obj, { 'x-complex': true }),
|
|
79
|
+
refsStack: baseRefsStack,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (this.isRef(obj)) {
|
|
83
|
+
const schemaName = getDefinitionName(obj.$ref);
|
|
84
|
+
if (schemaName && this.options.ignoreNamedSchemas.has(schemaName)) {
|
|
85
|
+
return { resolved: { type: 'object', title: schemaName }, refsStack: baseRefsStack };
|
|
86
|
+
}
|
|
87
|
+
let resolved = this.byRef(obj.$ref);
|
|
88
|
+
if (!resolved) {
|
|
89
|
+
throw new Error(`Failed to resolve $ref "${obj.$ref}"`);
|
|
90
|
+
}
|
|
91
|
+
if (baseRefsStack.includes(obj.$ref)) {
|
|
92
|
+
resolved = Object.assign({}, resolved, { 'x-circular-ref': true });
|
|
93
|
+
}
|
|
94
|
+
else if (this.isRef(resolved)) {
|
|
95
|
+
const res = this.deref(resolved, baseRefsStack, mergeAsAllOf, level);
|
|
96
|
+
resolved = res.resolved;
|
|
97
|
+
}
|
|
98
|
+
if (this.allowMergeRefs) {
|
|
99
|
+
resolved = this.mergeRefs(obj, resolved, mergeAsAllOf);
|
|
100
|
+
}
|
|
101
|
+
return { resolved, refsStack: pushRef(baseRefsStack, obj.$ref) };
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
resolved: obj,
|
|
105
|
+
refsStack: concatRefStacks(baseRefsStack, objRefsStack),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
mergeRefs(ref, resolved, mergeAsAllOf) {
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
110
|
+
const { $ref, ...rest } = ref;
|
|
111
|
+
const keys = Object.keys(rest);
|
|
112
|
+
if (keys.length === 0) {
|
|
113
|
+
return resolved;
|
|
114
|
+
}
|
|
115
|
+
if (mergeAsAllOf &&
|
|
116
|
+
keys.some((k) => ![
|
|
117
|
+
'description',
|
|
118
|
+
'title',
|
|
119
|
+
'externalDocs',
|
|
120
|
+
'x-refsStack',
|
|
121
|
+
'x-parentRefs',
|
|
122
|
+
'readOnly',
|
|
123
|
+
'writeOnly',
|
|
124
|
+
'x-complex',
|
|
125
|
+
].includes(k))) {
|
|
126
|
+
const { description, title, readOnly, writeOnly, ...restSchema } = rest;
|
|
127
|
+
return {
|
|
128
|
+
allOf: [{ description, title, readOnly, writeOnly }, resolved, restSchema],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// small optimization
|
|
133
|
+
return {
|
|
134
|
+
...resolved,
|
|
135
|
+
...rest,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Merge allOf constraints.
|
|
141
|
+
* @param schema schema with allOF
|
|
142
|
+
* @param $ref pointer of the schema
|
|
143
|
+
* @param refsStack
|
|
144
|
+
* @param absolutePointer
|
|
145
|
+
*/
|
|
146
|
+
mergeAllOf(schema, $ref, refsStack, absolutePointer = '', level = 0) {
|
|
147
|
+
if (schema['x-circular-ref']) {
|
|
148
|
+
return schema;
|
|
149
|
+
}
|
|
150
|
+
schema = this.hoistOneOfs(schema);
|
|
151
|
+
if (schema.allOf === undefined) {
|
|
152
|
+
return { absolutePointer, ...schema };
|
|
153
|
+
}
|
|
154
|
+
let receiver = {
|
|
155
|
+
...schema,
|
|
156
|
+
'x-parentRefs': [],
|
|
157
|
+
absolutePointer: JsonPointer.join(absolutePointer, ['allOf']),
|
|
158
|
+
allOf: undefined,
|
|
159
|
+
title: level === 0 ? schema.title || getDefinitionName($ref) : schema.title,
|
|
160
|
+
};
|
|
161
|
+
// avoid mutating inner objects
|
|
162
|
+
if (!isUndefined(receiver.properties) && isObject(receiver.properties)) {
|
|
163
|
+
receiver.properties = { ...receiver.properties };
|
|
164
|
+
}
|
|
165
|
+
if (!isUndefined(receiver.items) && isObject(receiver.items)) {
|
|
166
|
+
receiver.items = { ...receiver.items };
|
|
167
|
+
}
|
|
168
|
+
const allOfSchemas = schema.allOf
|
|
169
|
+
.map((subSchema, index) => {
|
|
170
|
+
const { resolved, refsStack: subRefsStack } = this.deref(subSchema, refsStack, true, level);
|
|
171
|
+
const subRef = subSchema.$ref;
|
|
172
|
+
const subAbsolutePointer = subRef || JsonPointer.join(absolutePointer, [String(index)]);
|
|
173
|
+
if (resolved['x-complex']) {
|
|
174
|
+
return {
|
|
175
|
+
$ref: subRef,
|
|
176
|
+
refsStack: pushRef(subRefsStack, subRef),
|
|
177
|
+
schema: { 'x-complex': true },
|
|
178
|
+
absolutePointer: subAbsolutePointer,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const subMerged = this.mergeAllOf(resolved, subRef, subRefsStack, subAbsolutePointer, level + 1);
|
|
182
|
+
if (subMerged['x-circular-ref'] && subMerged.allOf) {
|
|
183
|
+
// if mergeAllOf is circular and still contains allOf, we should ignore it
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
if (subRef) {
|
|
187
|
+
// collect information for implicit descriminator lookup
|
|
188
|
+
receiver['x-parentRefs']?.push(...(subMerged['x-parentRefs'] || []), subRef);
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
$ref: subRef,
|
|
192
|
+
refsStack: pushRef(subRefsStack, subRef),
|
|
193
|
+
schema: subMerged,
|
|
194
|
+
absolutePointer: subAbsolutePointer,
|
|
195
|
+
};
|
|
196
|
+
})
|
|
197
|
+
.filter(Boolean);
|
|
198
|
+
for (const [index, { schema: subSchema, refsStack: subRefsStack, absolutePointer },] of allOfSchemas.entries()) {
|
|
199
|
+
const { type, enum: enumProperty, properties, items, required, title, description, readOnly, writeOnly, oneOf, anyOf, 'x-circular-ref': isCircular, 'x-complex': isComplex, ...otherConstraints } = subSchema || {};
|
|
200
|
+
if (receiver.type !== type && !isUndefined(receiver.type) && !isUndefined(type) && !level) {
|
|
201
|
+
// console.warn(`Incompatible types in allOf at "${$ref}": "${receiver.type}" and "${type}"`);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (!isUndefined(type)) {
|
|
205
|
+
if (Array.isArray(type) && Array.isArray(receiver.type)) {
|
|
206
|
+
receiver.type = [...type, ...receiver.type];
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
receiver.type = type;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
if (!isUndefined(enumProperty)) {
|
|
213
|
+
if (Array.isArray(enumProperty) && Array.isArray(receiver.enum)) {
|
|
214
|
+
receiver.enum = Array.from(new Set([...enumProperty, ...receiver.enum]));
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
receiver.enum = enumProperty;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (!isUndefined(properties) && isObject(properties)) {
|
|
221
|
+
receiver.properties = receiver.properties || {};
|
|
222
|
+
for (const prop in properties) {
|
|
223
|
+
const propRefsStack = concatRefStacks(subRefsStack, properties[prop]?.['x-refsStack']);
|
|
224
|
+
if (!receiver.properties[prop]) {
|
|
225
|
+
receiver.properties[prop] = {
|
|
226
|
+
...properties[prop],
|
|
227
|
+
absolutePointer: JsonPointer.join(absolutePointer, ['properties', prop]),
|
|
228
|
+
'x-refsStack': propRefsStack,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
else if (!isCircular) {
|
|
232
|
+
// merge inner properties
|
|
233
|
+
const mergedProp = this.mergeAllOf({
|
|
234
|
+
allOf: [receiver.properties[prop], properties[prop]],
|
|
235
|
+
'x-refsStack': propRefsStack,
|
|
236
|
+
}, $ref + '/properties/' + prop, propRefsStack, JsonPointer.join(absolutePointer, ['allOf', String(index), 'properties', prop]), level + 1);
|
|
237
|
+
receiver.properties[prop] = mergedProp;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (!isUndefined(items) && !isCircular && !isComplex) {
|
|
242
|
+
const receiverItems = typeof receiver.items === 'boolean'
|
|
243
|
+
? {}
|
|
244
|
+
: Object.assign({}, receiver.items);
|
|
245
|
+
const subSchemaItems = typeof subSchema.items === 'boolean'
|
|
246
|
+
? {}
|
|
247
|
+
: Object.assign({}, subSchema.items);
|
|
248
|
+
// merge inner properties
|
|
249
|
+
receiver.items = this.mergeAllOf({
|
|
250
|
+
allOf: [receiverItems, subSchemaItems],
|
|
251
|
+
}, $ref + '/items', subRefsStack, '', level + 1);
|
|
252
|
+
}
|
|
253
|
+
if (!isUndefined(oneOf)) {
|
|
254
|
+
receiver.oneOf = oneOf;
|
|
255
|
+
}
|
|
256
|
+
if (!isUndefined(anyOf)) {
|
|
257
|
+
receiver.anyOf = anyOf;
|
|
258
|
+
}
|
|
259
|
+
if (Array.isArray(required)) {
|
|
260
|
+
receiver.required = [...(receiver.required || []), ...required];
|
|
261
|
+
}
|
|
262
|
+
// merge rest of constraints
|
|
263
|
+
// TODO: do more intelligent merge
|
|
264
|
+
receiver = {
|
|
265
|
+
...receiver,
|
|
266
|
+
title: receiver.title || title,
|
|
267
|
+
description: receiver.description || description,
|
|
268
|
+
readOnly: !isUndefined(receiver.readOnly) ? receiver.readOnly : readOnly,
|
|
269
|
+
writeOnly: !isUndefined(receiver.writeOnly) ? receiver.writeOnly : writeOnly,
|
|
270
|
+
'x-circular-ref': receiver['x-circular-ref'] || isCircular,
|
|
271
|
+
'x-complex': receiver['x-complex'] || isComplex,
|
|
272
|
+
...otherConstraints,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return receiver;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Find all derived definitions among #/components/schemas from any of $refs
|
|
279
|
+
* returns map of definition pointer to definition name
|
|
280
|
+
* @param $refs array of references to find derived from
|
|
281
|
+
*/
|
|
282
|
+
findDerived($refs) {
|
|
283
|
+
const res = {};
|
|
284
|
+
const schemas = (this.definition.components && this.definition.components.schemas) || {};
|
|
285
|
+
for (const defName in schemas) {
|
|
286
|
+
const { resolved: def } = this.deref(schemas[defName]);
|
|
287
|
+
if (!isUndefined(def.allOf) &&
|
|
288
|
+
def.allOf.find((obj) => !isUndefined(obj.$ref) && $refs.indexOf(obj.$ref) > -1)) {
|
|
289
|
+
res['#/components/schemas/' + defName] = [def['x-discriminator-value'] || defName];
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return res;
|
|
293
|
+
}
|
|
294
|
+
hoistOneOfs(schema) {
|
|
295
|
+
if (isUndefined(schema.allOf)) {
|
|
296
|
+
return schema;
|
|
297
|
+
}
|
|
298
|
+
const { allOf, ...restSchema } = schema;
|
|
299
|
+
for (let i = 0; i < allOf.length; i++) {
|
|
300
|
+
const { oneOf, ...sub } = allOf[i];
|
|
301
|
+
if (!oneOf) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(oneOf)) {
|
|
305
|
+
const beforeAllOf = allOf.slice(0, i);
|
|
306
|
+
const afterAllOf = allOf.slice(i + 1);
|
|
307
|
+
const siblingValues = Object.keys(sub).length > 0 ? [sub] : [];
|
|
308
|
+
return {
|
|
309
|
+
...restSchema,
|
|
310
|
+
oneOf: oneOf.map((part) => {
|
|
311
|
+
return {
|
|
312
|
+
allOf: [...beforeAllOf, ...siblingValues, part, ...afterAllOf],
|
|
313
|
+
};
|
|
314
|
+
}),
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return schema;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=OpenAPIParser.js.map
|
package/lib/services/check.js
CHANGED
|
@@ -1 +1,104 @@
|
|
|
1
|
-
import{cryptoLib
|
|
1
|
+
import { cryptoLib } from './utils.js';
|
|
2
|
+
function promisifyIECryptoRes(res) {
|
|
3
|
+
if ('then' in res) {
|
|
4
|
+
return res;
|
|
5
|
+
}
|
|
6
|
+
else {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
res.oncomplete = (e) => {
|
|
9
|
+
resolve(e.target.result);
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function str2ab(str) {
|
|
15
|
+
const buf = new ArrayBuffer(str.length);
|
|
16
|
+
const bufView = new Uint8Array(buf);
|
|
17
|
+
for (let i = 0, strLen = str.length; i < strLen; i++) {
|
|
18
|
+
bufView[i] = str.charCodeAt(i);
|
|
19
|
+
}
|
|
20
|
+
return buf;
|
|
21
|
+
}
|
|
22
|
+
const getKey = () => {
|
|
23
|
+
const publickeyDer = str2ab(atob(typeof REDOCLY_PUBLIC_KEY !== 'undefined'
|
|
24
|
+
? REDOCLY_PUBLIC_KEY
|
|
25
|
+
: 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ=='));
|
|
26
|
+
return promisifyIECryptoRes(cryptoLib?.subtle.importKey('spki', publickeyDer, {
|
|
27
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
28
|
+
hash: 'SHA-256',
|
|
29
|
+
}, true, ['verify']));
|
|
30
|
+
};
|
|
31
|
+
function textEncode(str) {
|
|
32
|
+
if (window.TextEncoder) {
|
|
33
|
+
return new TextEncoder().encode(str);
|
|
34
|
+
}
|
|
35
|
+
const utf8 = unescape(encodeURIComponent(str));
|
|
36
|
+
const result = new Uint8Array(utf8.length);
|
|
37
|
+
for (let i = 0; i < utf8.length; i++) {
|
|
38
|
+
result[i] = utf8.charCodeAt(i);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
async function verify(message, signature) {
|
|
43
|
+
return promisifyIECryptoRes(cryptoLib?.subtle.verify({ name: 'RSASSA-PKCS1-v1_5', hash: 'SHA-256' }, await getKey(), str2ab(atob(signature)), textEncode(message)));
|
|
44
|
+
}
|
|
45
|
+
export function isHostAllowed(hostname, hosts) {
|
|
46
|
+
if (hosts === true)
|
|
47
|
+
return true;
|
|
48
|
+
if (Array.isArray(hosts) && typeof window !== 'undefined') {
|
|
49
|
+
if (hostname === 'localhost' ||
|
|
50
|
+
hostname === '127.0.0.1' ||
|
|
51
|
+
hostname.endsWith('.localhost') ||
|
|
52
|
+
!!hosts.find((h) => h === hostname || hostname.endsWith('.' + h))) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return !!hosts.find((h) => {
|
|
56
|
+
if (h.indexOf('*') !== h.lastIndexOf('*'))
|
|
57
|
+
return;
|
|
58
|
+
const [leftPart, rightPart] = h.split('*');
|
|
59
|
+
return (rightPart &&
|
|
60
|
+
hostname.startsWith(leftPart) &&
|
|
61
|
+
hostname.endsWith(rightPart) &&
|
|
62
|
+
rightPart.split('.').length > 2);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// TODO: add tests
|
|
68
|
+
export default async function parse(key) {
|
|
69
|
+
if (process.env.NODE_ENV === 'development') {
|
|
70
|
+
return {
|
|
71
|
+
valid: true,
|
|
72
|
+
allowed: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const hostname = window.location.hostname;
|
|
76
|
+
if (!key) {
|
|
77
|
+
if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.endsWith('.localhost')) {
|
|
78
|
+
return {
|
|
79
|
+
local: true,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const [token, signature] = key.split('.');
|
|
87
|
+
let info;
|
|
88
|
+
try {
|
|
89
|
+
if (!(await verify(atob(token), signature))) {
|
|
90
|
+
return { valid: false };
|
|
91
|
+
}
|
|
92
|
+
info = JSON.parse(atob(token));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return { valid: false, cryptoMissing: true };
|
|
96
|
+
}
|
|
97
|
+
info.valid = true;
|
|
98
|
+
if (!info.e || Date.now() / 1000 > info.e) {
|
|
99
|
+
info.expired = true;
|
|
100
|
+
}
|
|
101
|
+
info.allowed = isHostAllowed(hostname, info.h);
|
|
102
|
+
return info;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
const
|
|
1
|
+
export const Languages = {
|
|
2
|
+
curl: 'curl',
|
|
3
|
+
JavaScript: 'JavaScript',
|
|
4
|
+
NodeJs: 'Node.js',
|
|
5
|
+
Python: 'Python',
|
|
6
|
+
Java: 'Java',
|
|
7
|
+
// Java8: 'Java8+Apache',
|
|
8
|
+
CSharp: 'C#',
|
|
9
|
+
// CSharpNewtonsoft: 'C#+Newtonsoft',
|
|
10
|
+
PHP: 'PHP',
|
|
11
|
+
Go: 'Go',
|
|
12
|
+
Ruby: 'Ruby',
|
|
13
|
+
R: 'R',
|
|
14
|
+
Payload: 'Payload',
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=constants.js.map
|