@redocly/openapi-docs 3.12.0 → 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 +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 +3 -3
|
@@ -1 +1,111 @@
|
|
|
1
|
-
import{CodeBuilder
|
|
1
|
+
import { CodeBuilder } from '../../helpers/code-builder.js';
|
|
2
|
+
import { buildUrlExpression, printUrlVariablesDeclarations } from '../../helpers/code-helpers.js';
|
|
3
|
+
import { Lang } from '../../helpers/constants.js';
|
|
4
|
+
import { HTTPSnippet } from '../../index.js';
|
|
5
|
+
import { normalizeMimeType } from '../../../../utils.js';
|
|
6
|
+
import { MediaTypes } from '../../../../../constants.js';
|
|
7
|
+
import { postDataToRListBody, objectToRString } from './utils.js';
|
|
8
|
+
const indent = 1;
|
|
9
|
+
const handler = function (source, originalOptions, { target, client }) {
|
|
10
|
+
const options = Object.assign({ indent: ' ', showBoilerplate: true, printBody: true }, originalOptions);
|
|
11
|
+
const code = new CodeBuilder({
|
|
12
|
+
indentation: options.indent,
|
|
13
|
+
variablesPrefix: options.variablesPrefix,
|
|
14
|
+
lang: Lang.R,
|
|
15
|
+
});
|
|
16
|
+
const reqMethod = source.method.toUpperCase();
|
|
17
|
+
const securityOAuth2ExtraCalls = source.securityOAuth2ExtraCalls?.[0];
|
|
18
|
+
if (options.showBoilerplate) {
|
|
19
|
+
code.push('library(httr)').blank();
|
|
20
|
+
}
|
|
21
|
+
if (securityOAuth2ExtraCalls) {
|
|
22
|
+
const prefix = 'oauth2_';
|
|
23
|
+
const oAuth2PrefixCode = new HTTPSnippet(securityOAuth2ExtraCalls).convert(target, client, {
|
|
24
|
+
...options,
|
|
25
|
+
variablesPrefix: prefix,
|
|
26
|
+
showBoilerplate: false,
|
|
27
|
+
});
|
|
28
|
+
const responseVariable = `${prefix}data_req`;
|
|
29
|
+
code
|
|
30
|
+
.push(oAuth2PrefixCode)
|
|
31
|
+
.push(`access_token = content(${responseVariable}, "parsed")$access_token`)
|
|
32
|
+
.blank();
|
|
33
|
+
source.allHeaders.Authorization = `paste("Bearer", access_token)`;
|
|
34
|
+
}
|
|
35
|
+
// Print all the post data
|
|
36
|
+
let encode;
|
|
37
|
+
let bodyVariableName = '';
|
|
38
|
+
if (source?.postData) {
|
|
39
|
+
switch (normalizeMimeType(source?.postData?.mimeType)) {
|
|
40
|
+
case MediaTypes.URL_ENCODED: {
|
|
41
|
+
encode = 'form';
|
|
42
|
+
bodyVariableName = code.var('body');
|
|
43
|
+
const stringifiedPostData = postDataToRListBody(source.postData.params, options);
|
|
44
|
+
code.push(`${bodyVariableName} <- list(${stringifiedPostData})`).blank();
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case MediaTypes.JSON: {
|
|
48
|
+
encode = 'json';
|
|
49
|
+
bodyVariableName = code.var('body');
|
|
50
|
+
const stringifiedPostData = objectToRString(source.postData.jsonObj, options);
|
|
51
|
+
code.push(`${bodyVariableName} = '${stringifiedPostData}'`).blank();
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
case MediaTypes.MULTIPART: {
|
|
55
|
+
encode = 'multipart';
|
|
56
|
+
bodyVariableName = code.var('body');
|
|
57
|
+
const stringifiedPostData = postDataToRListBody(source.postData.params, options);
|
|
58
|
+
code.push(`${bodyVariableName} <- list(${stringifiedPostData})`).blank();
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
default:
|
|
62
|
+
if (source.postData?.text) {
|
|
63
|
+
bodyVariableName = code.var('body');
|
|
64
|
+
encode = 'raw';
|
|
65
|
+
code.push(`${bodyVariableName} = ${objectToRString(source.postData?.text)}`).blank();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// print option parameter
|
|
70
|
+
printUrlVariablesDeclarations(source, code);
|
|
71
|
+
if (Object.keys({ ...source.pathParameters, ...source.serverVariables }).length) {
|
|
72
|
+
code
|
|
73
|
+
.blank()
|
|
74
|
+
.push('# create you own operator')
|
|
75
|
+
.push('"%&%" <- function(x, y)paste0(x,y)')
|
|
76
|
+
.blank();
|
|
77
|
+
}
|
|
78
|
+
const url = buildUrlExpression(source, code);
|
|
79
|
+
code.push(`url = ${url}`).blank();
|
|
80
|
+
// make request
|
|
81
|
+
const requestVariableName = code.var('data_req');
|
|
82
|
+
code.push(`${requestVariableName} <- ${reqMethod}(`);
|
|
83
|
+
code.push(indent, 'url,');
|
|
84
|
+
if (source.basicAuth) {
|
|
85
|
+
const { username, password } = source.basicAuth;
|
|
86
|
+
code.push(indent, `authenticate("${username}", "${password}")`);
|
|
87
|
+
}
|
|
88
|
+
if (Object.keys(source.allHeaders).length) {
|
|
89
|
+
const headersCode = `${Object.keys(source.allHeaders)
|
|
90
|
+
.map((key) => `"${key}" = ${source.allHeaders[key].startsWith('paste')
|
|
91
|
+
? source.allHeaders[key]
|
|
92
|
+
: `"${source.allHeaders[key]}"`}`)
|
|
93
|
+
.join(', ')}`;
|
|
94
|
+
if (headersCode) {
|
|
95
|
+
code.push(indent, `add_headers(${headersCode}),`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (bodyVariableName) {
|
|
99
|
+
code.push(indent, `body = ${bodyVariableName},`);
|
|
100
|
+
code.push(indent, `encode = "${encode}",`);
|
|
101
|
+
}
|
|
102
|
+
code.push(indent, 'verbose()');
|
|
103
|
+
code.push(')');
|
|
104
|
+
// Print code that makes response
|
|
105
|
+
if (options.printBody) {
|
|
106
|
+
code.blank().push(`content(${requestVariableName}${encode === 'raw' ? ', "text"' : ''})`);
|
|
107
|
+
}
|
|
108
|
+
return code.join();
|
|
109
|
+
};
|
|
110
|
+
export default handler;
|
|
111
|
+
//# sourceMappingURL=httr.js.map
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import httr from './httr.js';
|
|
2
|
+
export default {
|
|
3
|
+
info: {
|
|
4
|
+
key: 'r',
|
|
5
|
+
title: 'R',
|
|
6
|
+
extname: '.r',
|
|
7
|
+
default: 'httr',
|
|
8
|
+
},
|
|
9
|
+
httr,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function objectToRString(input, options) {
|
|
2
|
+
if (!input)
|
|
3
|
+
return '';
|
|
4
|
+
if (typeof input === 'string')
|
|
5
|
+
return JSON.stringify(input);
|
|
6
|
+
return JSON.stringify(input, null, 1)
|
|
7
|
+
.split('\n')
|
|
8
|
+
.map((line, index, arr) => index === arr.length - 1 ? line : (options?.indent || ' ') + line)
|
|
9
|
+
.join('\n')
|
|
10
|
+
.trim();
|
|
11
|
+
}
|
|
12
|
+
export function postDataToRListBody(input, options) {
|
|
13
|
+
const body = input
|
|
14
|
+
.map(({ name, value }) => (options?.indent || '') + `${name} = "${value}"`)
|
|
15
|
+
.join(',\n');
|
|
16
|
+
return '\n' + body + '\n';
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import native from './native.js';
|
|
2
|
+
export default {
|
|
3
|
+
info: {
|
|
4
|
+
key: 'ruby',
|
|
5
|
+
title: 'Ruby',
|
|
6
|
+
extname: '.rb',
|
|
7
|
+
default: 'native',
|
|
8
|
+
},
|
|
9
|
+
native,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,169 @@
|
|
|
1
|
-
import
|
|
1
|
+
import stringifyObject from 'stringify-object';
|
|
2
|
+
import { CodeBuilder } from '../../helpers/code-builder.js';
|
|
3
|
+
import { HTTPSnippet } from '../../index.js';
|
|
4
|
+
import { Lang } from '../../helpers/constants.js';
|
|
5
|
+
import { buildUrlExpression, printUrlVariablesDeclarations } from '../../helpers/code-helpers.js';
|
|
6
|
+
import { normalizeMimeType } from '../../../../utils.js';
|
|
7
|
+
import { MediaTypes } from '../../../../../constants.js';
|
|
8
|
+
const indent = 1;
|
|
9
|
+
function hasMimeType(postData = {}, mimeType) {
|
|
10
|
+
return normalizeMimeType(postData.mimeType) === mimeType;
|
|
11
|
+
}
|
|
12
|
+
const handler = function (source, originalOptions, { target, client }) {
|
|
13
|
+
const reqMethod = source.method.toUpperCase();
|
|
14
|
+
const securityOAuth2ExtraCalls = source.securityOAuth2ExtraCalls?.[0];
|
|
15
|
+
const options = {
|
|
16
|
+
capitalize: true,
|
|
17
|
+
showBoilerplate: true,
|
|
18
|
+
indent: ' ',
|
|
19
|
+
...originalOptions,
|
|
20
|
+
};
|
|
21
|
+
const code = new CodeBuilder({
|
|
22
|
+
indentation: options.indent,
|
|
23
|
+
variablesPrefix: options.variablesPrefix,
|
|
24
|
+
capitalize: options.capitalize,
|
|
25
|
+
lang: Lang.RUBY,
|
|
26
|
+
});
|
|
27
|
+
// Print boilerplate with packages initialization:
|
|
28
|
+
if (options.showBoilerplate) {
|
|
29
|
+
code.push(`require 'uri'`).push(`require 'net/http'`);
|
|
30
|
+
if (source.uriObj.protocol === 'https:') {
|
|
31
|
+
code.push(`require 'openssl'`);
|
|
32
|
+
}
|
|
33
|
+
if (hasMimeType(source.postData, MediaTypes.JSON) || securityOAuth2ExtraCalls) {
|
|
34
|
+
code.unshift(`require 'json'`);
|
|
35
|
+
}
|
|
36
|
+
code.blank();
|
|
37
|
+
}
|
|
38
|
+
// Put headers values into quotation marks
|
|
39
|
+
if (Object.keys(source.allHeaders).length) {
|
|
40
|
+
Object.keys(source.allHeaders).forEach((key) => {
|
|
41
|
+
source.allHeaders[key] = `'${source.allHeaders[key]}'`;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// To support custom methods we check for the supported methods
|
|
45
|
+
// and if doesn't exist then we build a custom class for it
|
|
46
|
+
const methods = [
|
|
47
|
+
'GET',
|
|
48
|
+
'POST',
|
|
49
|
+
'HEAD',
|
|
50
|
+
'DELETE',
|
|
51
|
+
'PATCH',
|
|
52
|
+
'PUT',
|
|
53
|
+
'OPTIONS',
|
|
54
|
+
'COPY',
|
|
55
|
+
'LOCK',
|
|
56
|
+
'UNLOCK',
|
|
57
|
+
'MOVE',
|
|
58
|
+
'TRACE',
|
|
59
|
+
];
|
|
60
|
+
const capMethod = reqMethod.charAt(0) + reqMethod.substring(1).toLowerCase();
|
|
61
|
+
if (methods.indexOf(reqMethod) < 0) {
|
|
62
|
+
code
|
|
63
|
+
.push('class Net::HTTP::%s < Net::HTTPRequest', capMethod)
|
|
64
|
+
.push(" METHOD = '%s'", reqMethod.toUpperCase())
|
|
65
|
+
.push(" REQUEST_HAS_BODY = '%s'", source.postData?.text ? 'true' : 'false')
|
|
66
|
+
.push(' RESPONSE_HAS_BODY = true')
|
|
67
|
+
.push('end')
|
|
68
|
+
.blank();
|
|
69
|
+
}
|
|
70
|
+
// If we have extra OAuth calls - print code for that
|
|
71
|
+
if (securityOAuth2ExtraCalls) {
|
|
72
|
+
const prefix = 'oAuth2';
|
|
73
|
+
const oAuth2PrefixCode = new HTTPSnippet(securityOAuth2ExtraCalls).convert(target, client, {
|
|
74
|
+
...options,
|
|
75
|
+
variablesPrefix: prefix,
|
|
76
|
+
showBoilerplate: false,
|
|
77
|
+
});
|
|
78
|
+
const responseVariable = `${prefix}${options.capitalize ? 'Response' : 'response'}`;
|
|
79
|
+
code
|
|
80
|
+
.push(oAuth2PrefixCode)
|
|
81
|
+
.push(`access_token = JSON.parse(${responseVariable}.body)['access_token']`)
|
|
82
|
+
.blank();
|
|
83
|
+
source.allHeaders.Authorization = `"Bearer " + access_token`;
|
|
84
|
+
}
|
|
85
|
+
// Print the URL with path variables if present
|
|
86
|
+
printUrlVariablesDeclarations(source, code);
|
|
87
|
+
code.push(`${code.var('url')} = URI(${buildUrlExpression(source, code)})`);
|
|
88
|
+
// Print query variables if present
|
|
89
|
+
const hasQueryVariables = Object.getOwnPropertyNames(source.queryObj).length;
|
|
90
|
+
if (hasQueryVariables) {
|
|
91
|
+
code.push(`${code.var('params')} = ${stringifyObject(source.queryObj, {
|
|
92
|
+
indent: options.indent,
|
|
93
|
+
inlineCharacterLimit: 25,
|
|
94
|
+
})}`);
|
|
95
|
+
code.push(`${code.var('url')}.query = URI.encode_www_form(${code.var('params')})`);
|
|
96
|
+
}
|
|
97
|
+
// Print code with client initialization
|
|
98
|
+
code
|
|
99
|
+
.blank()
|
|
100
|
+
.push(`${code.var('http')} = Net::HTTP.new(${code.var('url')}.host, ${code.var('url')}.port)`);
|
|
101
|
+
if (source.uriObj.protocol === 'https:') {
|
|
102
|
+
code.push(`${code.var('http')}.use_ssl = true`);
|
|
103
|
+
}
|
|
104
|
+
code.blank().push(`${code.var('request')} = Net::HTTP::%s.new(${code.var('url')})`, capMethod);
|
|
105
|
+
// Print headers
|
|
106
|
+
if (Object.keys(source.allHeaders).length) {
|
|
107
|
+
Object.keys(source.allHeaders).forEach((key) => {
|
|
108
|
+
if (source.allHeaders[key] !== `'${MediaTypes.MULTIPART}'`) {
|
|
109
|
+
// we'll set multipart/form-data later
|
|
110
|
+
code.push(`${code.var('request')}['%s'] = %s`, key, source.allHeaders[key]);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
// Print all the post data
|
|
115
|
+
if (source?.postData) {
|
|
116
|
+
const paramsObj = {};
|
|
117
|
+
switch (normalizeMimeType(source?.postData?.mimeType)) {
|
|
118
|
+
case MediaTypes.URL_ENCODED:
|
|
119
|
+
source.postData.params.forEach((param) => {
|
|
120
|
+
paramsObj[param.name] = param.value;
|
|
121
|
+
});
|
|
122
|
+
code.push(`${code.var('request')}.body = URI.encode_www_form(${stringifyObject(paramsObj, {
|
|
123
|
+
indent: options.indent,
|
|
124
|
+
inlineCharacterLimit: 25,
|
|
125
|
+
})})`);
|
|
126
|
+
break;
|
|
127
|
+
case MediaTypes.JSON:
|
|
128
|
+
code.push(`${code.var('request')}.body = ${stringifyObject(source.postData.jsonObj, {
|
|
129
|
+
indent: options.indent,
|
|
130
|
+
inlineCharacterLimit: 25,
|
|
131
|
+
}).replace(/null/g, 'nil')}.to_json`);
|
|
132
|
+
break;
|
|
133
|
+
case MediaTypes.MULTIPART:
|
|
134
|
+
if (source.postData.params) {
|
|
135
|
+
code.push(`${code.var('form_data')} = [`);
|
|
136
|
+
source.postData.params.forEach((param) => {
|
|
137
|
+
code.push(indent, `['${param.name}', '${param.value}'],`);
|
|
138
|
+
});
|
|
139
|
+
code.push(']');
|
|
140
|
+
}
|
|
141
|
+
code.push(`${code.var('request')}.set_form(${code.var('form_data')}, '${MediaTypes.MULTIPART}')`);
|
|
142
|
+
break;
|
|
143
|
+
default:
|
|
144
|
+
if (source.postData?.text) {
|
|
145
|
+
code.push(`${code.var('request')}.body = ${JSON.stringify(source.postData?.text)}`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Print basic auth code if present
|
|
150
|
+
if (source.basicAuth) {
|
|
151
|
+
const { username, password } = source.basicAuth;
|
|
152
|
+
code.push(`${code.var('request')}.basic_auth('${username}', '${password}')`);
|
|
153
|
+
}
|
|
154
|
+
// Print code that makes response
|
|
155
|
+
code
|
|
156
|
+
.blank()
|
|
157
|
+
.push(`${code.var('response')} = ${code.var('http')}.request(${code.var('request')})`)
|
|
158
|
+
.push(`puts ${code.var('response')}.read_body`)
|
|
159
|
+
.blank();
|
|
160
|
+
return code.join();
|
|
161
|
+
};
|
|
162
|
+
export const info = {
|
|
163
|
+
key: 'native',
|
|
164
|
+
title: 'net::http',
|
|
165
|
+
link: 'http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html',
|
|
166
|
+
description: 'Ruby HTTP client',
|
|
167
|
+
};
|
|
168
|
+
export default handler;
|
|
169
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -1,6 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { format } from 'util';
|
|
2
|
+
import { CodeBuilder } from '../../helpers/code-builder.js';
|
|
3
|
+
import shellHelpers from '../../helpers/shell.js';
|
|
4
|
+
import { addIndentation, buildUrlExpression } from '../../helpers/code-helpers.js';
|
|
5
|
+
import { normalizeMimeType } from '../../../../utils.js';
|
|
6
|
+
import { HTTPSnippet } from '../../index.js';
|
|
7
|
+
import { MediaTypes } from '../../../../../constants.js';
|
|
8
|
+
const handler = function (source, originalOptions, { target, client }) {
|
|
9
|
+
const options = Object.assign({
|
|
10
|
+
indent: ' ',
|
|
11
|
+
short: false,
|
|
12
|
+
binary: false,
|
|
13
|
+
}, originalOptions);
|
|
14
|
+
const code = new CodeBuilder({
|
|
15
|
+
indentation: options.indent,
|
|
16
|
+
lineJoin: options.indent ? ' \\\n' + options.indent : ' ',
|
|
17
|
+
});
|
|
18
|
+
const oAuth2PrefixCode = source.securityOAuth2ExtraCalls?.length
|
|
19
|
+
? new HTTPSnippet(source.securityOAuth2ExtraCalls?.[0]).convert(target, client, {
|
|
20
|
+
...options,
|
|
21
|
+
withComments: false,
|
|
22
|
+
})
|
|
23
|
+
: '';
|
|
24
|
+
code.push(0, 'curl -i %s %s', options.short ? '-X' : '--request', source.method.toUpperCase());
|
|
25
|
+
if (source.basicAuth) {
|
|
26
|
+
code.push(format('-u %s:%s', source.basicAuth.username, source.basicAuth.password));
|
|
27
|
+
}
|
|
28
|
+
const URL = buildUrlExpression(source, code);
|
|
29
|
+
code.push(format('%s%s', options.short ? '' : '--url ', shellHelpers.quote(URL)));
|
|
30
|
+
if (source.httpVersion === 'HTTP/1.0') {
|
|
31
|
+
code.push(options.short ? '-0' : '--http1.0');
|
|
32
|
+
}
|
|
33
|
+
// construct headers
|
|
34
|
+
Object.keys(source.headersObj)
|
|
35
|
+
.sort()
|
|
36
|
+
.forEach(function (key) {
|
|
37
|
+
const header = format('%s: %s', key, source.headersObj[key]);
|
|
38
|
+
code.push('%s %s', options.short ? '-H' : '--header', shellHelpers.quote(header));
|
|
39
|
+
});
|
|
40
|
+
if (source.allHeaders.cookie) {
|
|
41
|
+
code.push('%s %s', options.short ? '-b' : '--cookie', shellHelpers.quote(source.allHeaders.cookie));
|
|
42
|
+
}
|
|
43
|
+
// construct post params
|
|
44
|
+
if (source.postData) {
|
|
45
|
+
switch (normalizeMimeType(source.postData.mimeType)) {
|
|
46
|
+
case MediaTypes.MULTIPART:
|
|
47
|
+
source.postData.params.map(function (param) {
|
|
48
|
+
let post;
|
|
49
|
+
if (param.fileName) {
|
|
50
|
+
post = format('%s=@%s', param.name, param.fileName);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
post = format('%s=%s', param.name, param.value);
|
|
54
|
+
}
|
|
55
|
+
code.push('%s %s', options.short ? '-F' : '--form', shellHelpers.quote(post));
|
|
56
|
+
});
|
|
57
|
+
break;
|
|
58
|
+
case MediaTypes.URL_ENCODED:
|
|
59
|
+
if (source.postData.params) {
|
|
60
|
+
source.postData.params.map(function (param) {
|
|
61
|
+
code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', shellHelpers.quote(format('%s=%s', param.name, param.value)));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', shellHelpers.quote(source.postData.text));
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case MediaTypes.JSON:
|
|
69
|
+
if (source.postData.jsonObj) {
|
|
70
|
+
code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', addIndentation(shellHelpers.quote(JSON.stringify(source.postData.jsonObj, null, options.indent)), { level: 1, indent: options.indent, firstLine: false }));
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
default:
|
|
74
|
+
// raw request body
|
|
75
|
+
if (source.postData.text) {
|
|
76
|
+
code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', addIndentation(shellHelpers.quote(source.postData.text), {
|
|
77
|
+
level: 1,
|
|
78
|
+
indent: options.indent,
|
|
79
|
+
firstLine: false,
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const commentPrefixCode = options.withComments ? '# Requires curl >= 7.2\n\n' : '';
|
|
85
|
+
return (commentPrefixCode + (oAuth2PrefixCode ? oAuth2PrefixCode + '\n\n' + code.join() : code.join()));
|
|
86
|
+
};
|
|
87
|
+
export const info = {
|
|
88
|
+
key: 'curl',
|
|
89
|
+
title: 'curl',
|
|
90
|
+
link: 'http://curl.haxx.se/',
|
|
91
|
+
description: 'cURL is a command line tool and library for transferring data with URL syntax',
|
|
92
|
+
};
|
|
93
|
+
export default handler;
|
|
94
|
+
//# sourceMappingURL=curl.js.map
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import curl from './curl.js';
|
|
2
|
+
export default {
|
|
3
|
+
info: {
|
|
4
|
+
key: 'shell',
|
|
5
|
+
title: 'Shell',
|
|
6
|
+
extname: '.sh',
|
|
7
|
+
default: 'curl',
|
|
8
|
+
},
|
|
9
|
+
curl,
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,49 @@
|
|
|
1
|
-
import{querySelector
|
|
1
|
+
import { querySelector } from '../../utils/dom.js';
|
|
2
|
+
import { isNumeric } from '../../utils/helpers.js';
|
|
3
|
+
export function normalizeShowExtensions(value) {
|
|
4
|
+
if (typeof value === 'undefined') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (value === '') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value !== 'string') {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
switch (value) {
|
|
14
|
+
case 'true':
|
|
15
|
+
return true;
|
|
16
|
+
case 'false':
|
|
17
|
+
return false;
|
|
18
|
+
default:
|
|
19
|
+
return value.split(',').map((ext) => ext.trim());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function normalizeScrollYOffset(value) {
|
|
23
|
+
// just number is not valid selector and leads to crash so checking if isNumeric here
|
|
24
|
+
if (typeof value === 'string' && !isNumeric(value)) {
|
|
25
|
+
const el = querySelector(value);
|
|
26
|
+
if (!el) {
|
|
27
|
+
console.warn('scrollYOffset value is a selector to non-existing element. Using offset 0 by default');
|
|
28
|
+
}
|
|
29
|
+
const bottom = (el && el.getBoundingClientRect().bottom) || 0;
|
|
30
|
+
return () => bottom;
|
|
31
|
+
}
|
|
32
|
+
else if (typeof value === 'number' || isNumeric(value)) {
|
|
33
|
+
return () => (typeof value === 'number' ? value : parseFloat(value));
|
|
34
|
+
}
|
|
35
|
+
else if (typeof value === 'function') {
|
|
36
|
+
return () => {
|
|
37
|
+
const res = value();
|
|
38
|
+
if (typeof res !== 'number') {
|
|
39
|
+
console.warn(`scrollYOffset should return number but returned value "${res}" of type ${typeof res}`);
|
|
40
|
+
}
|
|
41
|
+
return res;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else if (value !== undefined) {
|
|
45
|
+
console.warn('Wrong value for scrollYOffset ReDoc option: should be string, number or function');
|
|
46
|
+
}
|
|
47
|
+
return () => 0;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1,83 @@
|
|
|
1
|
-
import{LayoutVariant
|
|
1
|
+
import { LayoutVariant } from '@redocly/config';
|
|
2
|
+
import { isUndefined, addTrailingSlash } from '@redocly/theme/core/openapi';
|
|
3
|
+
import { WindowReferenceOptions } from '../../constants.js';
|
|
4
|
+
import { argValueToBoolean, argValueToExpandLevel, argValueToInt, argValueToNumber, getWindowReferenceOptions, normalizePath, } from '../../utils/index.js';
|
|
5
|
+
import { normalizeShowExtensions, normalizeScrollYOffset } from './helpers.js';
|
|
6
|
+
import { Languages } from '../code-samples/constants.js';
|
|
7
|
+
export function normalizeOptions(raw, defaultOptions) {
|
|
8
|
+
raw = {
|
|
9
|
+
...defaultOptions,
|
|
10
|
+
...raw,
|
|
11
|
+
markdocOptions: {
|
|
12
|
+
...raw?.markdocOptions,
|
|
13
|
+
components: {
|
|
14
|
+
...defaultOptions?.markdocOptions?.components,
|
|
15
|
+
...raw?.markdocOptions?.components,
|
|
16
|
+
},
|
|
17
|
+
tags: {
|
|
18
|
+
...defaultOptions?.markdocOptions?.tags,
|
|
19
|
+
...raw?.markdocOptions?.tags,
|
|
20
|
+
},
|
|
21
|
+
nodes: {
|
|
22
|
+
...defaultOptions?.markdocOptions?.nodes,
|
|
23
|
+
...raw?.markdocOptions?.nodes,
|
|
24
|
+
heading: (defaultOptions?.markdocOptions?.nodes?.heading ||
|
|
25
|
+
raw?.markdocOptions?.nodes.heading),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const ignoreNamedSchemas = Array.isArray(raw.ignoreNamedSchemas)
|
|
30
|
+
? raw.ignoreNamedSchemas
|
|
31
|
+
: raw.ignoreNamedSchemas?.split(',').map((s) => s.trim());
|
|
32
|
+
const normalizedOptions = {
|
|
33
|
+
downloadUrls: raw.downloadUrls,
|
|
34
|
+
schemaDefinitionsTagName: raw.schemaDefinitionsTagName,
|
|
35
|
+
// TODO: validate URL and error here
|
|
36
|
+
corsProxyUrl: raw.corsProxyUrl && addTrailingSlash(raw.corsProxyUrl),
|
|
37
|
+
hideSidebar: argValueToBoolean(raw.hideSidebar, false),
|
|
38
|
+
jsonSamplesExpandLevel: argValueToExpandLevel(raw.jsonSamplesExpandLevel, 2),
|
|
39
|
+
generatedSamplesMaxDepth: argValueToInt(raw.generatedSamplesMaxDepth, 8),
|
|
40
|
+
hideDownloadButtons: argValueToBoolean(raw.hideDownloadButtons, false),
|
|
41
|
+
hideInfoMetadata: argValueToBoolean(raw.hideInfoMetadata, false),
|
|
42
|
+
hideLoading: argValueToBoolean(raw.hideLoading, false),
|
|
43
|
+
hideSchemaTitles: argValueToBoolean(raw.hideSchemaTitles, false),
|
|
44
|
+
maxDisplayedEnumValues: argValueToNumber(raw.maxDisplayedEnumValues),
|
|
45
|
+
mockServer: raw.mockServer?.url
|
|
46
|
+
? {
|
|
47
|
+
url: raw.mockServer.url,
|
|
48
|
+
position: raw.mockServer.position || 'first',
|
|
49
|
+
description: raw.mockServer.description || 'Mock server',
|
|
50
|
+
}
|
|
51
|
+
: undefined,
|
|
52
|
+
hideReplay: argValueToBoolean(raw.hideReplay, false),
|
|
53
|
+
oAuth2RedirectURI: raw.oAuth2RedirectURI || null,
|
|
54
|
+
onlyRequiredInSamples: argValueToBoolean(raw.onlyRequiredInSamples, false),
|
|
55
|
+
onDeepLinkClick: raw.onDeepLinkClick || getWindowReferenceOptions(WindowReferenceOptions.ON_DEEP_LINK_CLICK),
|
|
56
|
+
requestInterceptor: raw.requestInterceptor ||
|
|
57
|
+
getWindowReferenceOptions(WindowReferenceOptions.REQUEST_INTERCEPTOR),
|
|
58
|
+
routingBasePath: isUndefined(raw.disableRouter)
|
|
59
|
+
? ''
|
|
60
|
+
: (raw.routingBasePath && normalizePath(raw.routingBasePath)) || '',
|
|
61
|
+
schemasExpansionLevel: argValueToExpandLevel(raw.schemasExpansionLevel),
|
|
62
|
+
feedback: raw.feedback || { hide: false },
|
|
63
|
+
sortRequiredPropsFirst: argValueToBoolean(raw.sortRequiredPropsFirst, false),
|
|
64
|
+
scrollYOffset: normalizeScrollYOffset(raw.scrollYOffset),
|
|
65
|
+
showExtensions: normalizeShowExtensions(raw.showExtensions),
|
|
66
|
+
sanitize: argValueToBoolean(raw.sanitize, false),
|
|
67
|
+
skipBundle: argValueToBoolean(raw.skipBundle, false),
|
|
68
|
+
ignoreNamedSchemas: new Set(ignoreNamedSchemas),
|
|
69
|
+
markdocOptions: raw?.markdocOptions,
|
|
70
|
+
codeSamples: raw.codeSamples || {
|
|
71
|
+
languages: Object.values(Languages).map((lang) => ({ lang })),
|
|
72
|
+
},
|
|
73
|
+
layout: raw.layout || LayoutVariant.THREE_PANEL,
|
|
74
|
+
events: raw.events || {},
|
|
75
|
+
unstable_hooks: raw.unstable_hooks || getWindowReferenceOptions(WindowReferenceOptions.HOOKS) || {},
|
|
76
|
+
unstable_skipSamples: argValueToBoolean(raw.unstable_skipSamples, false),
|
|
77
|
+
unstable_externalCodeSamples: raw.unstable_externalCodeSamples || [],
|
|
78
|
+
// New options
|
|
79
|
+
hidePropertiesPrefix: argValueToBoolean(raw?.hidePropertiesPrefix, false),
|
|
80
|
+
};
|
|
81
|
+
return normalizedOptions;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=normalizeOptions.js.map
|