@redocly/openapi-docs 3.4.0-rc.4 → 3.4.0
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 +1565 -1367
- package/lib/components/ApiInfo/ApiInfo.js +1 -1
- package/lib/components/ApiInfo/Metadata.d.ts +3 -1
- package/lib/components/ApiInfo/Metadata.js +1 -1
- package/lib/components/CallbackSamples/CallbackSamples.d.ts +2 -1
- package/lib/components/CallbackSamples/CallbackSamples.js +1 -1
- package/lib/components/Callbacks/CallbackDetails.d.ts +2 -1
- package/lib/components/Callbacks/CallbackDetails.js +1 -1
- package/lib/components/Callbacks/CallbackOperation.js +1 -1
- package/lib/components/Callbacks/CallbackSummary.d.ts +3 -2
- package/lib/components/Callbacks/CallbackSummary.js +1 -1
- package/lib/components/Callbacks/CallbacksList.d.ts +0 -1
- package/lib/components/Callbacks/styled.d.ts +1 -1
- package/lib/components/Content/Content.d.ts +0 -1
- package/lib/components/Content/useAutoScroll.js +1 -1
- package/lib/components/ContentItem/ContentItem.d.ts +0 -1
- package/lib/components/ContentItem/useIsExpanded.js +1 -1
- package/lib/components/ContentItems/ContentItems.d.ts +0 -1
- package/lib/components/ContentItems/helpers.js +1 -1
- package/lib/components/Discriminator/Discriminator.d.ts +2 -1
- package/lib/components/Discriminator/Discriminator.js +1 -1
- package/lib/components/ExpandAllButton/ExpandAllButton.js +1 -1
- package/lib/components/ExpandAllButton/getAllNestedSchema.d.ts +4 -4
- package/lib/components/ExpandAllButton/useUpdateExpandedFields.js +1 -1
- package/lib/components/ExternalDocumentation/ExternalDocumentation.d.ts +0 -1
- package/lib/components/Language/LanguageList.d.ts +0 -1
- package/lib/components/Language/styled.d.ts +12 -13
- package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +1 -1
- package/lib/components/OperationItem/Description.js +1 -1
- package/lib/components/OperationItem/OperationItem.d.ts +0 -1
- package/lib/components/OperationItem/OperationItem.js +2 -2
- package/lib/components/Overview/Overview.d.ts +8 -3
- package/lib/components/Overview/Overview.js +1 -1
- package/lib/components/PageFooter/PageFooter.d.ts +0 -1
- package/lib/components/PageFooter/PageFooter.js +1 -1
- package/lib/components/PanelItem/styled.d.ts +5 -6
- package/lib/components/PayloadSamples/Example.js +1 -1
- package/lib/components/PayloadSamples/ExampleValue.d.ts +0 -1
- package/lib/components/PayloadSamples/ExampleValue.js +1 -1
- package/lib/components/PayloadSamples/ExternalExample.js +1 -1
- package/lib/components/PayloadSamples/MediaTypeSamples.d.ts +0 -1
- package/lib/components/PayloadSamples/MediaTypeSamples.js +1 -1
- package/lib/components/PayloadSamples/PayloadSamples.d.ts +0 -1
- package/lib/components/PayloadSamples/PayloadSamples.js +1 -1
- package/lib/components/PayloadSamples/useExternalExample.js +1 -1
- package/lib/components/PropertyDetails/DescriptionEnums.d.ts +1 -1
- package/lib/components/PropertyDetails/DescriptionEnums.js +2 -2
- package/lib/components/PropertyDetails/EnumValues.d.ts +0 -1
- package/lib/components/PropertyDetails/EnumValues.js +1 -1
- package/lib/components/PropertyDetails/Examples.js +1 -1
- package/lib/components/PropertyDetails/Extensions.d.ts +0 -1
- package/lib/components/PropertyDetails/FieldDetail.d.ts +1 -1
- package/lib/components/PropertyDetails/FieldDetail.js +1 -1
- package/lib/components/PropertyDetails/FieldDetails.d.ts +0 -1
- package/lib/components/PropertyDetails/FieldDetails.js +4 -3
- package/lib/components/PropertyDetails/Pattern.js +1 -1
- package/lib/components/PropertyDetails/PlusCircleIcon.js +1 -1
- package/lib/components/PropertyDetails/PropertyDetails.d.ts +0 -1
- package/lib/components/PropertyDetails/SchemaTypeInfo.js +1 -1
- package/lib/components/PropertyDetails/SimpleEnums.d.ts +1 -1
- package/lib/components/PropertyDetails/SimpleEnums.js +1 -1
- package/lib/components/PropertyDetails/styled.d.ts +1 -10
- package/lib/components/PropertyDetails/types.d.ts +3 -0
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +1 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +1 -1
- package/lib/components/RedoclyOpenAPIDocs/styled.d.ts +0 -4
- package/lib/components/RedoclyOpenAPIDocs/styled.js +1 -30
- package/lib/components/RedoclyOpenAPIDocs/types.d.ts +0 -3
- package/lib/components/RedoclyOpenAPIDocs/utils.js +1 -1
- package/lib/components/RenderHook/RenderHook.js +1 -1
- package/lib/components/Replay/EmbeddedReplay.d.ts +0 -1
- package/lib/components/Replay/EmbeddedReplay.js +1 -1
- package/lib/components/Replay/Replay.d.ts +0 -1
- package/lib/components/Replay/Replay.js +2 -9
- package/lib/components/Replay/utils.js +1 -1
- package/lib/components/Request/RequestDetails.d.ts +0 -1
- package/lib/components/Request/RequestDetails.js +1 -1
- package/lib/components/Request/types.d.ts +2 -0
- package/lib/components/RequestParameters/Body.d.ts +0 -1
- package/lib/components/RequestParameters/ParametersGroup.d.ts +0 -1
- package/lib/components/RequestParameters/RequestParameters.js +1 -1
- package/lib/components/RequestSamples/CodeSample.d.ts +0 -1
- package/lib/components/RequestSamples/RequestSamples.d.ts +0 -1
- package/lib/components/RequestSamples/useCodeSamples.js +1 -1
- package/lib/components/ResponseSamples/Summary.js +1 -1
- package/lib/components/Responses/OperationResponseList.js +1 -1
- package/lib/components/Responses/ResponseDetails.d.ts +0 -1
- package/lib/components/Responses/ResponseHeaders.d.ts +0 -1
- package/lib/components/Responses/ResponseHeaders.js +1 -1
- package/lib/components/Responses/styled.d.ts +1 -2
- package/lib/components/RightPanel/RightPanel.js +1 -1
- package/lib/components/Samples/use-example-key.js +1 -1
- package/lib/components/Schema/ArraySchema.d.ts +0 -1
- package/lib/components/Schema/ObjectSchema.d.ts +0 -1
- package/lib/components/Schema/ObjectSchema.js +1 -1
- package/lib/components/Schema/OneOfSchema.d.ts +0 -1
- package/lib/components/Schema/OneOfSchema.js +1 -1
- package/lib/components/Schema/RecursiveSchema.d.ts +0 -1
- package/lib/components/Schema/RecursiveSchema.js +1 -1
- package/lib/components/Schema/Schema.d.ts +0 -1
- package/lib/components/Schema/SubSchema.js +1 -1
- package/lib/components/Schema/helpers.d.ts +1 -1
- package/lib/components/Schema/helpers.js +1 -1
- package/lib/components/Schema/useOneOfLocationIdx.js +1 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.d.ts +0 -1
- package/lib/components/SectionContent/SectionContent.js +1 -1
- package/lib/components/SectionItem/SectionItem.d.ts +0 -1
- package/lib/components/Security/Divider.js +1 -1
- package/lib/components/Security/OAuthFlow.js +1 -1
- package/lib/components/Security/Security.js +1 -1
- package/lib/components/Security/SecurityButton.js +1 -1
- package/lib/components/Security/SecurityFlow.js +1 -1
- package/lib/components/Security/SecurityModal.js +1 -1
- package/lib/components/Security/SecuritySchemeItem.js +1 -1
- package/lib/components/Security/helper.js +1 -1
- package/lib/components/SelectOrLabel/SelectOrLabel.js +2 -2
- package/lib/components/ServerList/ServerList.d.ts +1 -1
- package/lib/components/ServerList/ServerList.js +1 -1
- package/lib/components/ServerList/types.d.ts +4 -1
- package/lib/components/ServerListDropdown/ServerListDropdown.js +1 -1
- package/lib/components/ServerListDropdown/styled.d.ts +0 -1
- package/lib/components/SideMenu/SideMenu.d.ts +0 -1
- package/lib/components/SideMenu/hooks/useMenuItems.js +1 -1
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/Tabs/useTabsState.js +1 -1
- package/lib/components/TagItem/OperationNavigationItems.d.ts +9 -0
- package/lib/components/TagItem/OperationNavigationItems.js +37 -0
- package/lib/components/TagItem/OperationsNavigation.d.ts +1 -7
- package/lib/components/TagItem/OperationsNavigation.js +1 -40
- package/lib/components/TagItem/TagItem.js +1 -1
- package/lib/components/TagItem/styled.d.ts +1 -0
- package/lib/components/TagItem/styled.js +6 -0
- package/lib/components/TagItem/types.d.ts +5 -0
- package/lib/components/TagItem/types.js +2 -0
- package/lib/components/common/Badges.d.ts +2 -2
- package/lib/components/common/BodyContent/BodyContent.d.ts +0 -1
- package/lib/components/common/BodyContent/BodyContent.js +1 -1
- package/lib/components/common/ClearButton/ClearButton.d.ts +0 -1
- package/lib/components/common/ClearButton/styled.d.ts +0 -1
- package/lib/components/common/ConstraintsView.d.ts +0 -1
- package/lib/components/common/ExpandableExample/ExpandableExample.js +1 -1
- package/lib/components/common/Extensions.d.ts +0 -1
- package/lib/components/common/Fields/fields-layout.d.ts +3 -3
- package/lib/components/common/Fields/fields.d.ts +1 -2
- package/lib/components/common/LinkToField.js +1 -1
- package/lib/components/common/Select/Select.d.ts +0 -1
- package/lib/components/common/Select/styled.d.ts +11 -12
- package/lib/components/common/Skeleton/Skeleton.d.ts +1 -1
- package/lib/components/common/Skeleton/Skeleton.js +2 -2
- package/lib/components/common/linkify.js +2 -2
- package/lib/components/common/panels.d.ts +7 -7
- package/lib/components/common/panels.js +2 -2
- package/lib/components/pluggable/styled.components.d.ts +3 -3
- package/lib/events/creator.js +1 -1
- package/lib/hoc/utils.js +1 -1
- package/lib/hoc/withRouter.js +1 -1
- package/lib/hoc/withStore.js +1 -1
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +1 -1
- package/lib/hooks/useActivateExample.js +1 -1
- package/lib/hooks/useActiveWithFallback.js +1 -1
- package/lib/hooks/useDimensions.js +1 -1
- package/lib/hooks/useLicense.js +1 -1
- package/lib/hooks/usePrevious.js +1 -1
- package/lib/hooks/useRouter.d.ts +1 -1
- package/lib/hooks/useTranslate.d.ts +2 -0
- package/lib/hooks/useTranslate.js +2 -0
- package/lib/hooks/useUppercase2LowercaseRedirect.js +1 -1
- package/lib/index.js +1 -1
- package/lib/jotai/app.d.ts +2 -4
- package/lib/jotai/app.js +1 -1
- package/lib/jotai/operation.js +1 -1
- package/lib/models/callback.js +1 -1
- package/lib/models/example.js +1 -1
- package/lib/models/field.js +1 -1
- package/lib/models/group.js +1 -1
- package/lib/models/mediaContent.js +1 -1
- package/lib/models/mediaType.js +1 -1
- package/lib/models/operation.js +1 -1
- package/lib/models/request.js +1 -1
- package/lib/models/response.js +1 -1
- package/lib/models/schema.js +1 -1
- package/lib/models/security.js +1 -1
- package/lib/models/tab.d.ts +1 -1
- package/lib/services/OpenAPIParser.js +1 -1
- package/lib/services/check.js +1 -1
- package/lib/services/code-samples/generator.d.ts +3 -1
- package/lib/services/code-samples/generator.js +1 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/index.d.ts +2 -2
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/index.d.ts +1 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/r/utils.js +1 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/index.d.ts +1 -1
- package/lib/services/config-options/helpers.js +1 -1
- package/lib/services/config-options/normalizeOptions.js +1 -1
- package/lib/services/history/helpers.js +1 -1
- package/lib/services/menu/builder.js +1 -1
- package/lib/services/menu/markdown.js +1 -1
- package/lib/services/menu/operation.js +1 -1
- package/lib/services/menu/tags.js +1 -1
- package/lib/services/utils.js +1 -1
- package/lib/standalone.js +1 -1
- package/lib/utils/areArraysEqual.js +1 -1
- package/lib/utils/argValuesHelpers.js +1 -1
- package/lib/utils/compose.d.ts +1 -1
- package/lib/utils/convertExamplesFormat.d.ts +2 -0
- package/lib/utils/convertExamplesFormat.js +2 -0
- package/lib/utils/cookies.js +1 -1
- package/lib/utils/createParsedDocument.js +1 -1
- package/lib/utils/debounce.js +1 -1
- package/lib/utils/debug.js +1 -1
- package/lib/utils/dom.js +1 -1
- package/lib/utils/environments.js +1 -1
- package/lib/utils/helpers.d.ts +2 -2
- package/lib/utils/helpers.js +1 -1
- package/lib/utils/highlight.js +1 -1
- package/lib/utils/isMobile.js +1 -1
- package/lib/utils/loadAndBundleSpec.js +1 -1
- package/lib/utils/local-storage.js +1 -1
- package/lib/utils/object.js +1 -1
- package/lib/utils/openapi.d.ts +2 -1
- package/lib/utils/openapi.js +1 -1
- package/lib/utils/parameters.js +1 -1
- package/lib/utils/path.js +1 -1
- package/lib/utils/replaceVariables.js +1 -1
- package/lib/utils/saveTextBeforeHeading.js +1 -1
- package/lib/utils/security-details.js +1 -1
- package/lib/utils/session-storage.js +1 -1
- package/lib/utils/sort.js +1 -1
- package/lib/utils/string.js +1 -1
- package/lib/utils/test-utils.js +1 -1
- package/lib/utils/theme-helpers.js +2 -2
- package/lib-esm/components/ApiInfo/ApiInfo.js +1 -1
- package/lib-esm/components/ApiInfo/Metadata.d.ts +3 -1
- package/lib-esm/components/ApiInfo/Metadata.js +1 -1
- package/lib-esm/components/CallbackSamples/CallbackSamples.d.ts +2 -1
- package/lib-esm/components/CallbackSamples/CallbackSamples.js +1 -1
- package/lib-esm/components/Callbacks/CallbackDetails.d.ts +2 -1
- package/lib-esm/components/Callbacks/CallbackDetails.js +1 -1
- package/lib-esm/components/Callbacks/CallbackOperation.js +1 -1
- package/lib-esm/components/Callbacks/CallbackSummary.d.ts +3 -2
- package/lib-esm/components/Callbacks/CallbackSummary.js +1 -1
- package/lib-esm/components/Callbacks/CallbacksList.d.ts +0 -1
- package/lib-esm/components/Callbacks/styled.d.ts +1 -1
- package/lib-esm/components/Content/Content.d.ts +0 -1
- package/lib-esm/components/ContentItem/ContentItem.d.ts +0 -1
- package/lib-esm/components/ContentItems/ContentItems.d.ts +0 -1
- package/lib-esm/components/Discriminator/Discriminator.d.ts +2 -1
- package/lib-esm/components/Discriminator/Discriminator.js +1 -1
- package/lib-esm/components/ExpandAllButton/ExpandAllButton.js +1 -1
- package/lib-esm/components/ExpandAllButton/getAllNestedSchema.d.ts +4 -4
- package/lib-esm/components/ExternalDocumentation/ExternalDocumentation.d.ts +0 -1
- package/lib-esm/components/Language/LanguageList.d.ts +0 -1
- package/lib-esm/components/Language/styled.d.ts +12 -13
- package/lib-esm/components/MediaTypeSwitch/MediaTypesSwitch.js +1 -1
- package/lib-esm/components/OperationItem/OperationItem.d.ts +0 -1
- package/lib-esm/components/OperationItem/OperationItem.js +2 -2
- package/lib-esm/components/Overview/Overview.d.ts +8 -3
- package/lib-esm/components/Overview/Overview.js +1 -1
- package/lib-esm/components/PageFooter/PageFooter.d.ts +0 -1
- package/lib-esm/components/PanelItem/styled.d.ts +5 -6
- package/lib-esm/components/PayloadSamples/Example.js +1 -1
- package/lib-esm/components/PayloadSamples/ExampleValue.d.ts +0 -1
- package/lib-esm/components/PayloadSamples/MediaTypeSamples.d.ts +0 -1
- package/lib-esm/components/PayloadSamples/MediaTypeSamples.js +1 -1
- package/lib-esm/components/PayloadSamples/PayloadSamples.d.ts +0 -1
- package/lib-esm/components/PayloadSamples/PayloadSamples.js +1 -1
- package/lib-esm/components/PropertyDetails/DescriptionEnums.d.ts +1 -1
- package/lib-esm/components/PropertyDetails/DescriptionEnums.js +1 -1
- package/lib-esm/components/PropertyDetails/EnumValues.d.ts +0 -1
- package/lib-esm/components/PropertyDetails/EnumValues.js +1 -1
- package/lib-esm/components/PropertyDetails/Examples.js +1 -1
- package/lib-esm/components/PropertyDetails/Extensions.d.ts +0 -1
- package/lib-esm/components/PropertyDetails/FieldDetail.d.ts +1 -1
- package/lib-esm/components/PropertyDetails/FieldDetail.js +1 -1
- package/lib-esm/components/PropertyDetails/FieldDetails.d.ts +0 -1
- package/lib-esm/components/PropertyDetails/FieldDetails.js +4 -3
- package/lib-esm/components/PropertyDetails/Pattern.js +1 -1
- package/lib-esm/components/PropertyDetails/PropertyDetails.d.ts +0 -1
- package/lib-esm/components/PropertyDetails/SimpleEnums.d.ts +1 -1
- package/lib-esm/components/PropertyDetails/SimpleEnums.js +1 -1
- package/lib-esm/components/PropertyDetails/styled.d.ts +1 -10
- package/lib-esm/components/PropertyDetails/types.d.ts +3 -0
- package/lib-esm/components/RedoclyOpenAPIDocs/Providers.js +1 -1
- package/lib-esm/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +1 -1
- package/lib-esm/components/RedoclyOpenAPIDocs/styled.d.ts +0 -4
- package/lib-esm/components/RedoclyOpenAPIDocs/styled.js +1 -30
- package/lib-esm/components/RedoclyOpenAPIDocs/types.d.ts +0 -3
- package/lib-esm/components/Replay/EmbeddedReplay.d.ts +0 -1
- package/lib-esm/components/Replay/EmbeddedReplay.js +1 -1
- package/lib-esm/components/Replay/Replay.d.ts +0 -1
- package/lib-esm/components/Replay/Replay.js +2 -9
- package/lib-esm/components/Request/RequestDetails.d.ts +0 -1
- package/lib-esm/components/Request/RequestDetails.js +1 -1
- package/lib-esm/components/Request/types.d.ts +2 -0
- package/lib-esm/components/RequestParameters/Body.d.ts +0 -1
- package/lib-esm/components/RequestParameters/ParametersGroup.d.ts +0 -1
- package/lib-esm/components/RequestParameters/RequestParameters.js +1 -1
- package/lib-esm/components/RequestSamples/CodeSample.d.ts +0 -1
- package/lib-esm/components/RequestSamples/RequestSamples.d.ts +0 -1
- package/lib-esm/components/RequestSamples/useCodeSamples.js +1 -1
- package/lib-esm/components/ResponseSamples/Summary.js +1 -1
- package/lib-esm/components/Responses/OperationResponseList.js +1 -1
- package/lib-esm/components/Responses/ResponseDetails.d.ts +0 -1
- package/lib-esm/components/Responses/ResponseHeaders.d.ts +0 -1
- package/lib-esm/components/Responses/ResponseHeaders.js +1 -1
- package/lib-esm/components/Responses/styled.d.ts +1 -2
- package/lib-esm/components/RightPanel/RightPanel.js +1 -1
- package/lib-esm/components/Schema/ArraySchema.d.ts +0 -1
- package/lib-esm/components/Schema/ObjectSchema.d.ts +0 -1
- package/lib-esm/components/Schema/ObjectSchema.js +1 -1
- package/lib-esm/components/Schema/OneOfSchema.d.ts +0 -1
- package/lib-esm/components/Schema/OneOfSchema.js +1 -1
- package/lib-esm/components/Schema/RecursiveSchema.d.ts +0 -1
- package/lib-esm/components/Schema/RecursiveSchema.js +1 -1
- package/lib-esm/components/Schema/Schema.d.ts +0 -1
- package/lib-esm/components/Schema/SubSchema.js +1 -1
- package/lib-esm/components/Schema/helpers.d.ts +1 -1
- package/lib-esm/components/Schema/helpers.js +1 -1
- package/lib-esm/components/SchemaDefinition/SchemaDefinition.d.ts +0 -1
- package/lib-esm/components/SectionItem/SectionItem.d.ts +0 -1
- package/lib-esm/components/Security/OAuthFlow.js +1 -1
- package/lib-esm/components/Security/SecurityFlow.js +1 -1
- package/lib-esm/components/Security/SecurityModal.js +1 -1
- package/lib-esm/components/ServerList/ServerList.d.ts +1 -1
- package/lib-esm/components/ServerList/ServerList.js +1 -1
- package/lib-esm/components/ServerList/types.d.ts +4 -1
- package/lib-esm/components/ServerListDropdown/ServerListDropdown.js +1 -1
- package/lib-esm/components/ServerListDropdown/styled.d.ts +0 -1
- package/lib-esm/components/SideMenu/SideMenu.d.ts +0 -1
- package/lib-esm/components/TagItem/OperationNavigationItems.d.ts +9 -0
- package/lib-esm/components/TagItem/OperationNavigationItems.js +37 -0
- package/lib-esm/components/TagItem/OperationsNavigation.d.ts +1 -7
- package/lib-esm/components/TagItem/OperationsNavigation.js +1 -40
- package/lib-esm/components/TagItem/TagItem.js +2 -2
- package/lib-esm/components/TagItem/styled.d.ts +1 -0
- package/lib-esm/components/TagItem/styled.js +6 -0
- package/lib-esm/components/TagItem/types.d.ts +5 -0
- package/lib-esm/components/TagItem/types.js +2 -0
- package/lib-esm/components/common/Badges.d.ts +2 -2
- package/lib-esm/components/common/BodyContent/BodyContent.d.ts +0 -1
- package/lib-esm/components/common/BodyContent/BodyContent.js +1 -1
- package/lib-esm/components/common/ClearButton/ClearButton.d.ts +0 -1
- package/lib-esm/components/common/ClearButton/styled.d.ts +0 -1
- package/lib-esm/components/common/ConstraintsView.d.ts +0 -1
- package/lib-esm/components/common/ExpandableExample/ExpandableExample.js +1 -1
- package/lib-esm/components/common/Extensions.d.ts +0 -1
- package/lib-esm/components/common/Fields/fields-layout.d.ts +3 -3
- package/lib-esm/components/common/Fields/fields.d.ts +1 -2
- package/lib-esm/components/common/Select/Select.d.ts +0 -1
- package/lib-esm/components/common/Select/styled.d.ts +11 -12
- package/lib-esm/components/common/Skeleton/Skeleton.d.ts +1 -1
- package/lib-esm/components/common/panels.d.ts +7 -7
- package/lib-esm/components/common/panels.js +2 -2
- package/lib-esm/components/pluggable/styled.components.d.ts +3 -3
- package/lib-esm/hooks/index.d.ts +1 -0
- package/lib-esm/hooks/index.js +1 -1
- package/lib-esm/hooks/useRouter.d.ts +1 -1
- package/lib-esm/hooks/useTranslate.d.ts +2 -0
- package/lib-esm/hooks/useTranslate.js +2 -0
- package/lib-esm/jotai/app.d.ts +2 -4
- package/lib-esm/jotai/app.js +1 -1
- package/lib-esm/models/mediaType.js +1 -1
- package/lib-esm/models/tab.d.ts +1 -1
- package/lib-esm/services/code-samples/generator.d.ts +3 -1
- package/lib-esm/services/code-samples/generator.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/index.d.ts +2 -2
- package/lib-esm/services/code-samples/httpsnippet/targets/java/httpclient.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/java8/apachehttp.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/javascript/fetch.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/javascript/index.d.ts +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/node/fetch.js +1 -1
- package/lib-esm/services/code-samples/httpsnippet/targets/shell/index.d.ts +1 -1
- package/lib-esm/utils/compose.d.ts +1 -1
- package/lib-esm/utils/convertExamplesFormat.d.ts +2 -0
- package/lib-esm/utils/convertExamplesFormat.js +2 -0
- package/lib-esm/utils/helpers.d.ts +2 -2
- package/lib-esm/utils/openapi.d.ts +2 -1
- package/lib-esm/utils/openapi.js +1 -1
- package/package.json +15 -14
- package/lib/components/UnsupportedFeatureScreen/UnsupportedFeatureScreen.d.ts +0 -1
- package/lib/components/UnsupportedFeatureScreen/UnsupportedFeatureScreen.js +0 -18
- package/lib/components/UnsupportedFeatureScreen/index.d.ts +0 -1
- package/lib/components/UnsupportedFeatureScreen/index.js +0 -2
- package/lib/setupTests.d.ts +0 -2
- package/lib/setupTests.js +0 -2
- package/lib/testProviders.d.ts +0 -3
- package/lib/testProviders.js +0 -2
- package/lib-esm/components/UnsupportedFeatureScreen/UnsupportedFeatureScreen.d.ts +0 -1
- package/lib-esm/components/UnsupportedFeatureScreen/UnsupportedFeatureScreen.js +0 -18
- package/lib-esm/components/UnsupportedFeatureScreen/index.d.ts +0 -1
- package/lib-esm/components/UnsupportedFeatureScreen/index.js +0 -2
- package/lib-esm/setupTests.d.ts +0 -2
- package/lib-esm/setupTests.js +0 -2
- package/lib-esm/testProviders.d.ts +0 -3
- package/lib-esm/testProviders.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __rest=this&&this.__rest||function(e,t){var
|
|
1
|
+
"use strict";var __rest=this&&this.__rest||function(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(i[r[n]]=e[r[n]])}return i};Object.defineProperty(exports,"__esModule",{value:!0}),exports.OpenAPIParser=void 0,exports.pushRef=pushRef,exports.concatRefStacks=concatRefStacks;const theme_1=require("@redocly/theme"),utils_1=require("../utils"),JsonPointer_1=require("../utils/JsonPointer"),normalizeOptions_1=require("./config-options/normalizeOptions");function pushRef(e,t){return t&&e[e.length-1]!==t?[...e,t]:e}function concatRefStacks(e,t){return t?e.concat(t):e}class OpenAPIParser{constructor(e,t,i=(0,normalizeOptions_1.normalizeOptions)({})){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"definitionUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"definition",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"allowMergeRefs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"byRef",{enumerable:!0,configurable:!0,writable:!0,value:e=>{let t;if(this.definition){"#"!==e.charAt(0)&&(e="#"+e),e=decodeURIComponent(e);try{t=JsonPointer_1.JsonPointer.get(this.definition,e)}catch(e){}return t||{}}}}),this.definition=Object.assign({},e),this.validate(e),this.definition=e,this.allowMergeRefs=e.openapi.startsWith("3.1");const r=theme_1.IS_BROWSER?window.location.href:"";(0,theme_1.isString)(t)&&(this.definitionUrl=new URL(t,r).href)}validate(e){if((0,theme_1.isUndefined)(e.openapi))throw new Error("Document must be valid OpenAPI 3.0.0 definition")}isRef(e){return!!e&&(void 0!==e.$ref&&null!==e.$ref)}deref(e,t=[],i=!1){const r=null==e?void 0:e["x-refsStack"];if(t=concatRefStacks(t,r),this.isRef(e)){const r=(0,utils_1.getDefinitionName)(e.$ref);if(r&&this.options.ignoreNamedSchemas.has(r))return{resolved:{type:"object",title:r},refsStack:t};let n=this.byRef(e.$ref);if(!n)throw new Error(`Failed to resolve $ref "${e.$ref}"`);if(t.includes(e.$ref))n=Object.assign({},n,{"x-circular-ref":!0});else if(this.isRef(n)){n=this.deref(n,t,i).resolved}return this.allowMergeRefs&&(n=this.mergeRefs(e,n,i)),{resolved:n,refsStack:pushRef(t,e.$ref)}}return{resolved:e,refsStack:concatRefStacks(t,r)}}mergeRefs(e,t,i){const{$ref:r}=e,n=__rest(e,["$ref"]),s=Object.keys(n);if(0===s.length)return t;if(i&&s.some((e=>!["description","title","externalDocs","x-refsStack","x-parentRefs","readOnly","writeOnly"].includes(e)))){const e=n,{description:i,title:r,readOnly:s,writeOnly:o}=e;return{allOf:[{description:i,title:r,readOnly:s,writeOnly:o},t,__rest(e,["description","title","readOnly","writeOnly"])]}}return Object.assign(Object.assign({},t),n)}mergeAllOf(e,t,i,r=""){var n;if(e["x-circular-ref"])return e;if(void 0===(e=this.hoistOneOfs(e)).allOf)return Object.assign({absolutePointer:r},e);let s=Object.assign(Object.assign({},e),{"x-parentRefs":[],absolutePointer:JsonPointer_1.JsonPointer.join(r,["allOf"]),allOf:void 0,title:e.title||(0,utils_1.getDefinitionName)(t)});!(0,theme_1.isUndefined)(s.properties)&&(0,theme_1.isObject)(s.properties)&&(s.properties=Object.assign({},s.properties)),!(0,theme_1.isUndefined)(s.items)&&(0,theme_1.isObject)(s.items)&&(s.items=Object.assign({},s.items));const o=e.allOf.map(((e,t)=>{var n;const{resolved:o,refsStack:f}=this.deref(e,i,!0),l=e.$ref,a=l||JsonPointer_1.JsonPointer.join(r,[String(t)]),c=this.mergeAllOf(o,l,f,a);if(!c["x-circular-ref"]||!c.allOf)return l&&(null===(n=s["x-parentRefs"])||void 0===n||n.push(...c["x-parentRefs"]||[],l)),{$ref:l,refsStack:pushRef(f,l),schema:c,absolutePointer:a}})).filter(Boolean);for(const[e,{schema:i,refsStack:r,absolutePointer:f}]of o.entries()){const{type:o,enum:l,properties:a,items:c,required:d,title:p,description:O,readOnly:u,writeOnly:h,oneOf:m,anyOf:y,"x-circular-ref":b}=i,_=__rest(i,["type","enum","properties","items","required","title","description","readOnly","writeOnly","oneOf","anyOf","x-circular-ref"]);if(s.type===o||(0,theme_1.isUndefined)(s.type)||(0,theme_1.isUndefined)(o)){if((0,theme_1.isUndefined)(o)||(Array.isArray(o)&&Array.isArray(s.type)?s.type=[...o,...s.type]:s.type=o),(0,theme_1.isUndefined)(l)||(Array.isArray(l)&&Array.isArray(s.enum)?s.enum=Array.from(new Set([...l,...s.enum])):s.enum=l),!(0,theme_1.isUndefined)(a)&&(0,theme_1.isObject)(a)){s.properties=s.properties||{};for(const i in a){const o=concatRefStacks(r,null===(n=a[i])||void 0===n?void 0:n["x-refsStack"]);if(s.properties[i]){if(!b){const r=this.mergeAllOf({allOf:[s.properties[i],a[i]],"x-refsStack":o},t+"/properties/"+i,o,JsonPointer_1.JsonPointer.join(f,["allOf",String(e),"properties",i]));s.properties[i]=r}}else s.properties[i]=Object.assign(Object.assign({},a[i]),{absolutePointer:JsonPointer_1.JsonPointer.join(f,["properties",i]),"x-refsStack":o})}}if(!(0,theme_1.isUndefined)(c)&&!b){const e="boolean"==typeof s.items?{}:Object.assign({},s.items),n="boolean"==typeof i.items?{}:Object.assign({},i.items);s.items=this.mergeAllOf({allOf:[e,n]},t+"/items",r)}(0,theme_1.isUndefined)(m)||(s.oneOf=m),(0,theme_1.isUndefined)(y)||(s.anyOf=y),Array.isArray(d)&&(s.required=[...s.required||[],...d]),s=Object.assign(Object.assign(Object.assign({},s),{title:s.title||p,description:s.description||O,readOnly:(0,theme_1.isUndefined)(s.readOnly)?u:s.readOnly,writeOnly:(0,theme_1.isUndefined)(s.writeOnly)?h:s.writeOnly,"x-circular-ref":s["x-circular-ref"]||b}),_)}}return s}findDerived(e){const t={},i=this.definition.components&&this.definition.components.schemas||{};for(const r in i){const{resolved:n}=this.deref(i[r]);!(0,theme_1.isUndefined)(n.allOf)&&n.allOf.find((t=>!(0,theme_1.isUndefined)(t.$ref)&&e.indexOf(t.$ref)>-1))&&(t["#/components/schemas/"+r]=[n["x-discriminator-value"]||r])}return t}hoistOneOfs(e){if((0,theme_1.isUndefined)(e.allOf))return e;const t=e.allOf;for(let e=0;e<t.length;e++){const i=t[e],{oneOf:r}=i,n=__rest(i,["oneOf"]);if(r&&Array.isArray(r)){const i=t.slice(0,e),s=t.slice(e+1),o=Object.keys(n).length>0?[n]:[];return{oneOf:r.map((e=>({allOf:[...i,...o,e,...s]})))}}}return e}}exports.OpenAPIParser=OpenAPIParser;
|
|
2
2
|
//# sourceMappingURL=OpenAPIParser.js.map
|
package/lib/services/check.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isHostAllowed=
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,r){function s(t){try{a(o.next(t))}catch(t){r(t)}}function l(t){try{a(o.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,l)}a((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.isHostAllowed=isHostAllowed,exports.default=parse;const utils_1=require("./utils");function promisifyIECryptoRes(t){return"then"in t?t:new Promise((e=>{t.oncomplete=t=>{e(t.target.result)}}))}function str2ab(t){const e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let e=0,o=t.length;e<o;e++)n[e]=t.charCodeAt(e);return e}const getKey=()=>{const t=str2ab(atob("undefined"!=typeof REDOCLY_PUBLIC_KEY?REDOCLY_PUBLIC_KEY:"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ=="));return promisifyIECryptoRes(null===utils_1.cryptoLib||void 0===utils_1.cryptoLib?void 0:utils_1.cryptoLib.subtle.importKey("spki",t,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"]))};function textEncode(t){if(window.TextEncoder)return(new TextEncoder).encode(t);const e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}function verify(t,e){return __awaiter(this,void 0,void 0,(function*(){return promisifyIECryptoRes(null===utils_1.cryptoLib||void 0===utils_1.cryptoLib?void 0:utils_1.cryptoLib.subtle.verify({name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},yield getKey(),str2ab(atob(e)),textEncode(t)))}))}function isHostAllowed(t,e){return!0===e||!(!Array.isArray(e)||"undefined"==typeof window)&&(!("localhost"!==t&&"127.0.0.1"!==t&&!t.endsWith(".localhost")&&!e.find((e=>e===t||t.endsWith("."+e))))||!!e.find((e=>{if(e.indexOf("*")!==e.lastIndexOf("*"))return;const[n,o]=e.split("*");return o&&t.startsWith(n)&&t.endsWith(o)&&o.split(".").length>2})))}function parse(t){return __awaiter(this,void 0,void 0,(function*(){if("development"===process.env.NODE_ENV)return{valid:!0,allowed:!0};const e=window.location.hostname;if(!t)return"localhost"===e||"127.0.0.1"===e||e.endsWith(".localhost")?{local:!0}:{};const[n,o]=t.split(".");let i;try{if(!(yield verify(atob(n),o)))return{valid:!1};i=JSON.parse(atob(n))}catch(t){return{valid:!1,cryptoMissing:!0}}return i.valid=!0,(!i.e||Date.now()/1e3>i.e)&&(i.expired=!0),i.allowed=isHostAllowed(e,i.h),i}))}
|
|
2
2
|
//# sourceMappingURL=check.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OperationModel } from '../../models';
|
|
2
2
|
import type * as HAR from './har';
|
|
3
3
|
import type { Languages } from './types';
|
|
4
|
+
import type { TFunction } from '@redocly/theme';
|
|
4
5
|
export type CustomHAR = HAR.Request & {
|
|
5
6
|
securityOAuth2ExtraCalls?: HAR.Request[];
|
|
6
7
|
basicAuth?: {
|
|
@@ -13,7 +14,7 @@ export type CustomHAR = HAR.Request & {
|
|
|
13
14
|
serverVariables?: Record<string, string>;
|
|
14
15
|
allResponseCodes?: string[];
|
|
15
16
|
};
|
|
16
|
-
export declare function getCodeSample({ lang, operation, exampleName, pathParams, properties, options, environment, }: {
|
|
17
|
+
export declare function getCodeSample({ lang, operation, exampleName, pathParams, properties, options, environment, translate, }: {
|
|
17
18
|
lang: Languages;
|
|
18
19
|
operation: OperationModel;
|
|
19
20
|
exampleName?: string;
|
|
@@ -21,6 +22,7 @@ export declare function getCodeSample({ lang, operation, exampleName, pathParams
|
|
|
21
22
|
properties?: GenericObject;
|
|
22
23
|
options?: GenericObject;
|
|
23
24
|
environment: Record<string, string>;
|
|
25
|
+
translate: TFunction;
|
|
24
26
|
}): string;
|
|
25
27
|
export declare function isDefined<T>(arg?: T): arg is T;
|
|
26
28
|
export declare function capitalizeFirst(str: string): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,s)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.capitalizeFirst=exports.isDefined=exports.getCodeSample=void 0;const Sampler=__importStar(require("openapi-sampler")),deepmerge_1=__importDefault(require("deepmerge")),utils_1=require("../../utils"),utils_2=require("../utils"),constants_1=require("../../constants"),httpsnippet_1=require("./httpsnippet"),mediaContent_1=require("../../models/mediaContent"),string_utility_1=__importDefault(require("./httpsnippet/helpers/string-utility"));function getSelectedSecurityScheme(e,t){return e.find((e=>{const a=e.schemes.map((e=>e.id));return(0,utils_1.areArraysEqual)(a,t||[])}))}function mapOperationToHAR(e,{exampleName:t="",skipOptionalParameters:a=!1,withOAuth2Call:r=!1,spec:s,generatedPayloadSamplesMaxDepth:i=8,pathParams:n={},properties:o={}},{environment:l,requestValues:u,activeSecuritySchemeIds:c}){var p,d,m;const f=l.server,h=e.servers.find((e=>e.url===f))||e.servers[0],_=getSelectedSecurityScheme(e.security,c),{securityHeaders:y,securityCookies:v,securityQueries:g,securityOAuth2ExtraCalls:O,basicAuth:S}=getSecurityData(_||(null===(p=e.security)||void 0===p?void 0:p[0]),r,l),T=(null===(d=null==e?void 0:e.requestBody)||void 0===d?void 0:d.content)&&(0,mediaContent_1.getActiveMediaType)(e.requestBody.content),C={skipNonRequired:a,skipReadOnly:!0,maxSampleDepth:i,quiet:!0},b=u;let D=!1;const E=e.parameters.filter((e=>"header"===e.in)).filter((e=>!(a&&!e.required))).map((e=>{var t;return{name:e.name,value:(null===(t=b.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))}})).map((e=>((null==T?void 0:T.name)&&"content-type"===e.name.toLowerCase()&&(D=!0,e.value=T.name),e))).concat(y);!D&&(null==T?void 0:T.name)&&E.unshift({name:"Content-Type",value:null==T?void 0:T.name});const j=e.parameters.filter((e=>"cookie"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))))).reduce(((e,t)=>{var a;for(const[r,s]of Object.entries(t))e.push({name:r,value:String((null===(a=b.cookie)||void 0===a?void 0:a[r])||s)});return e}),[]).concat(v),P=e.parameters.filter((e=>"query"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))))).reduce(((e,t)=>{var a,r,s;for(const[i,n]of Object.entries(t))e.push({name:i,value:(0,utils_1.isArrayOfObjects)(null===(a=b.query)||void 0===a?void 0:a[i])&&JSON.stringify((0,utils_1.deleteEmptyArrayItem)(null===(r=b.query)||void 0===r?void 0:r[i]))||String((null===(s=b.query)||void 0===s?void 0:s[i])||n)});return e}),[]).concat(g),w=`${null==h?void 0:h.url.replace(/\/$/,"")}/${e.path.replace(/^\//,"")}`,k=e.parameters.filter((e=>"path"===e.in)).reduce(((e,t)=>{var a;const{in:r,name:s}=t;return e[s]=(null===(a=b.path)||void 0===a?void 0:a[s])||n[s]||(0,utils_1.getParameterValue)(r,s),e}),{}),q=null===(m=null==T?void 0:T.examples)||void 0===m?void 0:m[t],A=(null==T?void 0:T.examples)||{},[R]=Object.values(A),M=(null==b?void 0:b.body)||(null==q?void 0:q.value)||(null==R?void 0:R.value)||(null==T?void 0:T.schema)&&Sampler.sample(null==T?void 0:T.schema.rawSchema,C,s),x=null==T?void 0:T.name.toLowerCase();let N="",H=[];switch((0,utils_2.normalizeMimeType)(x)){case constants_1.MediaTypes.JSON:case constants_1.MediaTypes.XML:N=JSON.stringify(getDataRequest(M,o));break;case constants_1.MediaTypes.URL_ENCODED:case constants_1.MediaTypes.MULTIPART:N=utils_1.queryString.stringify(getDataRequest(M,o)),H=objectToHarParams(getDataRequest(M,o));break;default:N=String(M||"")}const z=N?{mimeType:(null==T?void 0:T.name)||constants_1.MediaTypes.OCTET_STREAM,text:N,params:H}:void 0,U=e.responses.map((e=>e.code));return{method:e.httpVerb,url:w,httpVersion:"HTTP/1.1",cookies:j,headers:E,queryString:P,postData:z,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:O,basicAuth:S,pathParameters:k,serverVariables:l,allResponseCodes:U}}const defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:Object.assign(Object.assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:Object.assign(Object.assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:Object.assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:Object.assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:Object.assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:Object.assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:Object.assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:Object.assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:Object.assign({},defaultOptions)}};function getCodeSample({lang:e,operation:t,exampleName:a,pathParams:r,properties:s,options:i={},environment:n}){try{const{skipOptionalParameters:o,withOAuth2Call:l,spec:u,generatedPayloadSamplesMaxDepth:c,store:p}=i,d=mapOperationToHAR(t,{exampleName:a,pathParams:r,properties:s,skipOptionalParameters:o,withOAuth2Call:l,spec:u,generatedPayloadSamplesMaxDepth:c},{environment:n,requestValues:p.requestValues,activeSecuritySchemeIds:p.activeSecuritySchemeIds}),m=new httpsnippet_1.HTTPSnippet(d);return langToSnippetConfig[e]?m.convert(langToSnippetConfig[e].code,langToSnippetConfig[e].defaultTarget,Object.assign(Object.assign({},langToSnippetConfig[e].defaultOptions),i)):"Language is not supported."}catch(e){return console.error(e),"Failed to generate code sample."}}function getSecurityData(e,t,a){var r,s,i,n,o;const l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0};for(const u of(null==e?void 0:e.schemes)||[]){const e=(0,utils_1.getSecurityDetails)(u.id,a);switch(u.type){case"openIdConnect":null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const a=e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,e)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,e)),null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:a});break}case"apiKey":{const t=e.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:t})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:t}),"query"===u.in&&l.securityQueries.push({name:u.name,value:t});break}case"http":if("basic"===u.scheme)l.basicAuth={username:e.username||`<${string_utility_1.default.toSnakeCase("Username")}>`,password:e.password||`<${string_utility_1.default.toSnakeCase("Password")}>`};else{const t=(null===(n=e.token)||void 0===n?void 0:n.access_token)||`<YOUR_${u.bearerFormat||"TOKEN"}_HERE>`;null===(o=l.securityHeaders)||void 0===o||o.push({name:"Authorization",value:`${capitalizeFirst(u.scheme||"bearer")} ${t}`})}}}return l}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return(0,deepmerge_1.default)(e,t,{arrayMerge:utils_2.arrayMergeStrategy});try{return(0,deepmerge_1.default)(JSON.parse(e),t,{arrayMerge:utils_2.arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e,t=""){const a=[];for(const[r,s]of Object.entries(e)){const e=t?`${t}[${r}]`:r;"object"==typeof s&&null!==s?a.push(...objectToHarParams(s,e)):a.push({name:e,value:String(s)})}return a}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}exports.getCodeSample=getCodeSample,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var s=Object.getOwnPropertyDescriptor(t,a);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,s)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var a in e)"default"!==a&&Object.prototype.hasOwnProperty.call(e,a)&&__createBinding(t,e,a);return __setModuleDefault(t,e),t},__importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getCodeSample=getCodeSample,exports.isDefined=isDefined,exports.capitalizeFirst=capitalizeFirst;const Sampler=__importStar(require("openapi-sampler")),deepmerge_1=__importDefault(require("deepmerge")),jstoxml_1=require("jstoxml"),utils_1=require("../../utils"),utils_2=require("../utils"),constants_1=require("../../constants"),httpsnippet_1=require("./httpsnippet"),mediaContent_1=require("../../models/mediaContent"),string_utility_1=__importDefault(require("./httpsnippet/helpers/string-utility"));function getSelectedSecurityScheme(e,t){return e.find((e=>{const a=e.schemes.map((e=>e.id));return(0,utils_1.areArraysEqual)(a,t||[])}))}function mapOperationToHAR(e,{exampleName:t="",skipOptionalParameters:a=!1,withOAuth2Call:r=!1,spec:s,generatedPayloadSamplesMaxDepth:i=8,pathParams:n={},properties:o={}},{environment:l,requestValues:u,activeSecuritySchemeIds:c}){var p,d,m;const f=l.server,h=e.servers.find((e=>e.url===f))||e.servers[0],_=getSelectedSecurityScheme(e.security,c),{securityHeaders:y,securityCookies:g,securityQueries:v,securityOAuth2ExtraCalls:O,basicAuth:S}=getSecurityData(_||(null===(p=e.security)||void 0===p?void 0:p[0]),r,l),T=(null===(d=null==e?void 0:e.requestBody)||void 0===d?void 0:d.content)&&(0,mediaContent_1.getActiveMediaType)(e.requestBody.content),C={skipNonRequired:a,skipReadOnly:!0,maxSampleDepth:i,quiet:!0},b=u;let j=!1;const D=e.parameters.filter((e=>"header"===e.in)).filter((e=>!(a&&!e.required))).map((e=>{var t;return{name:e.name,value:(null===(t=b.header)||void 0===t?void 0:t[e.name])||(0,utils_1.getParameterValue)("header",e.name)||(0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))}})).map((e=>((null==T?void 0:T.name)&&"content-type"===e.name.toLowerCase()&&(j=!0,e.value=T.name),e))).concat(y);!j&&(null==T?void 0:T.name)&&D.unshift({name:"Content-Type",value:null==T?void 0:T.name});const E=e.parameters.filter((e=>"cookie"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))))).reduce(((e,t)=>{var a;for(const[r,s]of Object.entries(t))e.push({name:r,value:String((null===(a=b.cookie)||void 0===a?void 0:a[r])||s)});return e}),[]).concat(g),q=e.parameters.filter((e=>"query"===e.in)).filter((e=>!(a&&!e.required))).map((e=>utils_1.queryString.parse((0,utils_1.serializeParameterValue)(e,Sampler.sample(e.schema.rawSchema,C,s))))).reduce(((e,t)=>{var a,r,s;for(const[i,n]of Object.entries(t))e.push({name:i,value:(0,utils_1.isArrayOfObjects)(null===(a=b.query)||void 0===a?void 0:a[i])&&JSON.stringify((0,utils_1.deleteEmptyArrayItem)(null===(r=b.query)||void 0===r?void 0:r[i]))||String((null===(s=b.query)||void 0===s?void 0:s[i])||n)});return e}),[]).concat(v),P=`${null==h?void 0:h.url.replace(/\/$/,"")}/${e.path.replace(/^\//,"")}`,k=e.parameters.filter((e=>"path"===e.in)).reduce(((e,t)=>{var a;const{in:r,name:s}=t;return e[s]=(null===(a=b.path)||void 0===a?void 0:a[s])||n[s]||(0,utils_1.getParameterValue)(r,s),e}),{}),w=null===(m=null==T?void 0:T.examples)||void 0===m?void 0:m[t],A=(null==T?void 0:T.examples)||{},[R]=Object.values(A),M=(null==b?void 0:b.body)||(null==w?void 0:w.value)||(null==R?void 0:R.value)||(null==T?void 0:T.schema)&&Sampler.sample(null==T?void 0:T.schema.rawSchema,C,s),x=null==T?void 0:T.name.toLowerCase();let N="",H=[];switch((0,utils_2.normalizeMimeType)(x)){case constants_1.MediaTypes.JSON:N=JSON.stringify(getDataRequest(M,o));break;case constants_1.MediaTypes.XML:N="object"==typeof M?(0,jstoxml_1.toXML)(getDataRequest(M,o),{indent:" "}):M;break;case constants_1.MediaTypes.URL_ENCODED:case constants_1.MediaTypes.MULTIPART:N=utils_1.queryString.stringify(getDataRequest(M,o)),H=objectToHarParams(getDataRequest(M,o));break;default:N=String(M||"")}const U=N?{mimeType:(null==T?void 0:T.name)||constants_1.MediaTypes.OCTET_STREAM,text:N,params:H}:void 0,z=e.responses.map((e=>e.code));return{method:e.httpVerb,url:P,httpVersion:"HTTP/1.1",cookies:E,headers:D,queryString:q,postData:U,headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:O,basicAuth:S,pathParameters:k,serverVariables:l,allResponseCodes:z}}const defaultOptions={withImports:!0,withComments:!1},langToSnippetConfig={curl:{code:"shell",defaultTarget:"curl",defaultOptions:Object.assign(Object.assign({},defaultOptions),{short:!0})},JavaScript:{code:"javascript",defaultTarget:"fetch",defaultOptions:Object.assign(Object.assign({},defaultOptions),{withImports:!1})},"Node.js":{code:"node",defaultTarget:"fetch",defaultOptions:Object.assign({},defaultOptions)},Python:{code:"python",defaultTarget:"requests",defaultOptions:Object.assign({},defaultOptions)},"Java8+Apache":{code:"java8",defaultTarget:"apachehttp",defaultOptions:Object.assign({},defaultOptions)},Java:{code:"java",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#":{code:"csharp",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},"C#+Newtonsoft":{code:"csharpNewtonsoft",defaultTarget:"httpclient",defaultOptions:Object.assign({},defaultOptions)},Go:{code:"go",defaultTarget:"http.DefaultClient",defaultOptions:Object.assign({},defaultOptions)},PHP:{code:"php",defaultTarget:"curl",defaultOptions:Object.assign({},defaultOptions)},Ruby:{code:"ruby",defaultTarget:"net::http",defaultOptions:Object.assign({},defaultOptions)},R:{code:"r",defaultTarget:"httr",defaultOptions:Object.assign({},defaultOptions)}};function getCodeSample({lang:e,operation:t,exampleName:a,pathParams:r,properties:s,options:i={},environment:n,translate:o}){try{const{skipOptionalParameters:l,withOAuth2Call:u,spec:c,generatedPayloadSamplesMaxDepth:p,store:d}=i,m=mapOperationToHAR(t,{exampleName:a,pathParams:r,properties:s,skipOptionalParameters:l,withOAuth2Call:u,spec:c,generatedPayloadSamplesMaxDepth:p},{environment:n,requestValues:d.requestValues,activeSecuritySchemeIds:d.activeSecuritySchemeIds}),f=new httpsnippet_1.HTTPSnippet(m);return langToSnippetConfig[e]?f.convert(langToSnippetConfig[e].code,langToSnippetConfig[e].defaultTarget,Object.assign(Object.assign({},langToSnippetConfig[e].defaultOptions),i)):o("openapi.unsupportedLanguage","Language is not supported.")}catch(e){return console.error(e),o("openapi.failedToGenerateCodeSample","Failed to generate code sample.")}}function getSecurityData(e,t,a){var r,s,i,n,o;const l={securityHeaders:[],securityCookies:[],securityQueries:[],securityOAuth2ExtraCalls:[],basicAuth:void 0};for(const u of(null==e?void 0:e.schemes)||[]){const e=(0,utils_1.getSecurityDetails)(u.id,a);switch(u.type){case"openIdConnect":null===(r=l.securityHeaders)||void 0===r||r.push({name:"Authorization",value:e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>"});break;case"oauth2":{const a=e.token?`${e.token.token_type||"Bearer"} ${e.token.access_token}`:"Bearer <YOUR_TOKEN_HERE>";u.flows.clientCredentials&&t?l.securityOAuth2ExtraCalls.push(getOAuth2ClientCredsCallHar(u.flows.clientCredentials,u.scopes,e)):u.flows.password&&t&&l.securityOAuth2ExtraCalls.push(getOAuth2PasswordCallHar(u.flows.password,u.scopes,e)),null===(s=l.securityHeaders)||void 0===s||s.push({name:"Authorization",value:a});break}case"apiKey":{const t=e.raw||"YOUR_API_KEY_HERE";"header"===u.in&&(null===(i=l.securityHeaders)||void 0===i||i.push({name:u.name,value:t})),"cookie"===u.in&&l.securityCookies.push({name:u.name,value:t}),"query"===u.in&&l.securityQueries.push({name:u.name,value:t});break}case"http":if("basic"===u.scheme)l.basicAuth={username:e.username||`<${string_utility_1.default.toSnakeCase("Username")}>`,password:e.password||`<${string_utility_1.default.toSnakeCase("Password")}>`};else{const t=(null===(n=e.token)||void 0===n?void 0:n.access_token)||`<YOUR_${u.bearerFormat||"TOKEN"}_HERE>`;null===(o=l.securityHeaders)||void 0===o||o.push({name:"Authorization",value:`${capitalizeFirst(u.scheme||"bearer")} ${t}`})}}}return l}function getOAuth2PasswordCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"password"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},{name:"username",value:a.username||"<username>"},{name:"password",value:a.password||"<password>"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getOAuth2ClientCredsCallHar(e,t,a){return{method:"POST",url:e.tokenUrl,httpVersion:"HTTP/1.1",headers:[{name:"Content-Type",value:constants_1.MediaTypes.URL_ENCODED},{name:"Accept",value:constants_1.MediaTypes.JSON}],queryString:[],postData:{mimeType:constants_1.MediaTypes.URL_ENCODED,text:"",params:[{name:"grant_type",value:"client_credentials"},{name:"client_id",value:a.client_id||"YOUR_CLIENT_ID"},{name:"client_secret",value:a.client_secret||"YOUR_CLIENT_SECRET"},t.length?{name:"scope",value:t.join(" ")}:void 0].filter(isDefined)},cookies:[],headersSize:-1,bodySize:-1,securityOAuth2ExtraCalls:[]}}function getDataRequest(e,t){if(e){if("object"==typeof e)return(0,deepmerge_1.default)(e,t,{arrayMerge:utils_2.arrayMergeStrategy});try{return(0,deepmerge_1.default)(JSON.parse(e),t,{arrayMerge:utils_2.arrayMergeStrategy})}catch(e){return!1}}return!1}function objectToHarParams(e,t=""){const a=[];for(const[r,s]of Object.entries(e)){const e=t?`${t}[${r}]`:r;"object"==typeof s&&null!==s?a.push(...objectToHarParams(s,e)):a.push({name:e,value:String(s)})}return a}function isDefined(e){return void 0!==e}function capitalizeFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}
|
|
2
2
|
//# sourceMappingURL=generator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPreserveTransformer=getPreserveTransformer,exports.addIndentation=addIndentation,exports.parseUrlIntoOperands=parseUrlIntoOperands,exports.buildUrlExpression=buildUrlExpression,exports.printUrlVariablesDeclarations=printUrlVariablesDeclarations;const constants_1=require("./constants");function getPreserveTransformer({body:e,authorizationHeader:r}){return function(n,t,a){return e&&"body"===t&&"string"==typeof n.body?n.body:r&&"Authorization"===t&&"string"==typeof n.Authorization?n.Authorization:a}}function addIndentation(e,{level:r=0,indent:n=" ",firstLine:t=!0}={}){const a=n.repeat(r),s=e.replace(/(\r\n|\n|\r)/gm,`\n${a}`);return t?a.concat(s):s}function parseUrlIntoOperands(e,r){const n=Object.keys(r).map((r=>({name:r,idx:e.indexOf(`{${r}}`)}))).filter((({idx:e})=>e>-1)).sort(((e,r)=>e.idx-r.idx)),t=[];let a=0;for(const{name:r,idx:s}of n)s>a&&t.push({type:"string",value:e.substring(a,s)}),t.push({type:"variable",name:r}),a=s+r.length+2;return a<e.length&&t.push({type:"string",value:e.substring(a)}),t}function buildUrlExpression(e,r){const{joinSymbol:n,variableWrapperFn:t,stringLiteral:a,urlFieldName:s,rawName:i}=r.langOptions,{pathParameters:o={},serverVariables:l={}}=e,p=Object.assign(Object.assign({},o),l);return parseUrlIntoOperands(e[s]||"",p).map((e=>{if("variable"===e.type){const n=p[e.name],a=i?e.name:r.var(e.name,constants_1.VariableType.PATH);return t(a,n)}return a(e.value)})).join(n)}function printUrlVariablesDeclarations({pathParameters:e={},serverVariables:r={}},n,t){Object.entries(Object.assign(Object.assign({},e),r)).forEach((([e,r])=>{if("server"===e)return;const a=r||`YOUR_${e}_PARAMETER`,s=n.var(e,constants_1.VariableType.PATH);void 0!==t?n.push(t,n.langOptions.variableDeclaration(s),a):n.push(n.langOptions.variableDeclaration(s),a)}))}
|
|
2
2
|
//# sourceMappingURL=code-helpers.js.map
|
|
@@ -7,7 +7,7 @@ declare const targets: {
|
|
|
7
7
|
default: string;
|
|
8
8
|
};
|
|
9
9
|
fetch: import("..").LanguageHandler<(import("../..").BasicLanguageOptions & {
|
|
10
|
-
credentials?: "
|
|
10
|
+
credentials?: "omit" | "same-origin" | "include";
|
|
11
11
|
}) | undefined>;
|
|
12
12
|
};
|
|
13
13
|
node: {
|
|
@@ -36,7 +36,7 @@ declare const targets: {
|
|
|
36
36
|
default: string;
|
|
37
37
|
};
|
|
38
38
|
curl: import("..").LanguageHandler<(import("../..").BasicLanguageOptions & {
|
|
39
|
-
binary?: boolean
|
|
39
|
+
binary?: boolean;
|
|
40
40
|
}) | undefined>;
|
|
41
41
|
};
|
|
42
42
|
java8: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),constants_2=require("../../../../../constants"),hasQueryParams=e=>!(!e.uriObj.query||!Object.keys(e.uriObj.query).length),getBody=e=>e.postData&&e.postData.mimeType===constants_2.MediaTypes.URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":e.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(e.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':"",handler=function(e,t,{target:s,client:a}){var r,n,o;const i=Object.assign({indent:" ",withWrapper:!0},t),p=new code_builder_1.CodeBuilder({indentation:i.indent,variablesPrefix:i.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA});let l=!1;if(i.withComments&&addComments(p,e),i.withImports&&addImports(p,e),i.withWrapper&&(p.push("public class App {"),p.push(1,"public static void main(String[] args) throws Exception {"),p.push(2,"var httpClient = HttpClient.newBuilder().build();"),p.blank()),null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length){const t=new __1.HTTPSnippet(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0]).convert(s,a,Object.assign(Object.assign({},i),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));p.push(t),p.blank(),p.push(2,"var oauth2Response = httpClient.send(oauth2Request, HttpResponse.BodyHandlers.ofString());"),p.push(2,'var accessToken = new JSONObject(oauth2Response.body()).getString("access_token");'),p.blank()}if(e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case constants_2.MediaTypes.URL_ENCODED:e.postData.params&&(p.push(2,"HashMap<String, String> params = new HashMap<>();"),e.postData.params.forEach((e=>{p.push(2,'params.put("%s", "%s");',e.name,e.value)})),p.blank(),p.push(2,"var form = params.keySet().stream()"),p.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),p.push(3,'.collect(Collectors.joining("&"));'),p.blank());break;case constants_2.MediaTypes.JSON:e.postData.jsonObj&&(p.push(2,`var payload = String.join("\\n"\n ${(0,code_helpers_1.addIndentation)(JSON.stringify(e.postData.jsonObj,null,1).replace(/"/g,'\\"').replace(/^/gm,', "').replace(/$/gm,'"'),{level:3,indent:i.indent,firstLine:!1})}`),p.push(2,");"),p.blank());break;case constants_2.MediaTypes.XML:e.postData.text&&(p.push(2,'var payload = String.join("\\n"'),e.postData.text.trim().split("\n").forEach((e=>{const t=e.replace(/"/g,'\\"');p.push(3
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const code_builder_1=require("../../helpers/code-builder"),__1=require("../.."),utils_1=require("../../../../utils"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),constants_2=require("../../../../../constants"),hasQueryParams=e=>!(!e.uriObj.query||!Object.keys(e.uriObj.query).length),getBody=e=>e.postData&&e.postData.mimeType===constants_2.MediaTypes.URL_ENCODED?"HttpRequest.BodyPublishers.ofString(form)":e.postData?"HttpRequest.BodyPublishers.ofString(payload)":["POST","PUT","PATCH"].includes(e.method.toUpperCase())?'HttpRequest.BodyPublishers.ofString("some body text")':"",handler=function(e,t,{target:s,client:a}){var r,n,o;const i=Object.assign({indent:" ",withWrapper:!0},t),p=new code_builder_1.CodeBuilder({indentation:i.indent,variablesPrefix:i.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA});let l=!1;if(i.withComments&&addComments(p,e),i.withImports&&addImports(p,e),i.withWrapper&&(p.push("public class App {"),p.push(1,"public static void main(String[] args) throws Exception {"),p.push(2,"var httpClient = HttpClient.newBuilder().build();"),p.blank()),null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length){const t=new __1.HTTPSnippet(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n[0]).convert(s,a,Object.assign(Object.assign({},i),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));p.push(t),p.blank(),p.push(2,"var oauth2Response = httpClient.send(oauth2Request, HttpResponse.BodyHandlers.ofString());"),p.push(2,'var accessToken = new JSONObject(oauth2Response.body()).getString("access_token");'),p.blank()}if(e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case constants_2.MediaTypes.URL_ENCODED:e.postData.params&&(p.push(2,"HashMap<String, String> params = new HashMap<>();"),e.postData.params.forEach((e=>{p.push(2,'params.put("%s", "%s");',e.name,e.value)})),p.blank(),p.push(2,"var form = params.keySet().stream()"),p.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),p.push(3,'.collect(Collectors.joining("&"));'),p.blank());break;case constants_2.MediaTypes.JSON:e.postData.jsonObj&&(p.push(2,`var payload = String.join("\\n"\n ${(0,code_helpers_1.addIndentation)(JSON.stringify(e.postData.jsonObj,null,1).replace(/"/g,'\\"').replace(/^/gm,', "').replace(/$/gm,'"'),{level:3,indent:i.indent,firstLine:!1})}`),p.push(2,");"),p.blank());break;case constants_2.MediaTypes.XML:e.postData.text&&(p.push(2,'var payload = String.join("\\n"'),e.postData.text.trim().split("\n").forEach((e=>{const t=e.replace(/"/g,'\\"');p.push(3,`"${t}", `)})),p.push(2,");"),p.blank());break;case constants_2.MediaTypes.MULTIPART:l=!0,p.unshift("# multipart/form-data is not supported yet\n")}if(hasQueryParams(e)){p.push(2,"HashMap<String, String> params = new HashMap<>();");for(const[t,s]of Object.entries(e.uriObj.query))p.push(2,'params.put("%s", "%s");',t,s);p.blank(),p.push(2,"var query = params.keySet().stream()"),p.push(3,'.map(key -> key + "=" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))'),p.push(3,'.collect(Collectors.joining("&"));'),p.blank()}p.push(2,`var ${p.var("host")} = "%s";`,e.uriObj.protocol+"//"+e.uriObj.host),(0,code_helpers_1.printUrlVariablesDeclarations)(e,p,2);const u=Object.assign(Object.assign({},e),{pathname:e.uriObj.pathname});p.push(2,`var ${p.var("pathname")} = %s;`,(0,code_helpers_1.buildUrlExpression)(u,p)),p.push(2,`var ${p.var("request")} = HttpRequest.newBuilder()`),"PATCH"===e.method.toUpperCase()?p.push(3,'.method("PATCH", %s)',getBody(e)):p.push(3,".%s(%s)",e.method.toUpperCase(),getBody(e)),p.push(3,`.uri(URI.create(${p.var("host")} + ${p.var("pathname")} %s))`,hasQueryParams(e)?"+ '?' + query":""),(null===(o=e.securityOAuth2ExtraCalls)||void 0===o?void 0:o.length)&&(e.allHeaders.Authorization='"Bearer " + accessToken');const h=Object.keys(e.allHeaders);if(h.length&&h.forEach((t=>{var s;p.push(3,'.header("%s", %s)',t,"Authorization"===t&&(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)?e.allHeaders[t]:`"${e.allHeaders[t]}"`)})),e.basicAuth){const{username:t,password:s}=e.basicAuth;p.push(3,`.header("Authorization", "Basic " + Base64.getEncoder().encodeToString(("${t}:${s}").getBytes()))`)}return p.push(3,".build();"),i.withWrapper&&(p.blank(),p.push(2,"var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());"),p.blank(),p.push(2,"System.out.println(response.body());"),p.push(1,"}"),p.push("}")),l&&p.clean(),p.join()};function addComments(e,t){var s;e.push("/**"),e.push(" * Requires JDK >= 11"),(null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)&&(e.push(" *"),e.push(' * Requires package "org.json" >= 20201115'),e.push(" * See here for installation details:"),e.push(" * https://search.maven.org/artifact/org.json/json")),e.push(" */"),e.blank()}function addImports(e,t){var s,a,r,n;e.push("import java.net.*;"),e.push("import java.net.http.*;"),e.push("import java.util.*;"),((0,utils_1.normalizeMimeType)(null===(s=t.postData)||void 0===s?void 0:s.mimeType)===constants_2.MediaTypes.URL_ENCODED&&(null===(a=t.postData)||void 0===a?void 0:a.params)||(null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length)||hasQueryParams(t))&&(e.push("import java.nio.charset.StandardCharsets;"),e.push("import java.util.stream.Collectors;")),(null===(n=t.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length)&&e.push("import org.json.JSONObject;"),e.blank()}exports.info={key:"httpclient",title:"HttpClient",link:"https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html",description:"HttpClient (Java SE 11 & JDK 11 )"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=httpclient.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const code_builder_1=require("../../helpers/code-builder"),index_1=require("../../index"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),constants_2=require("../../../../../constants"),handler=function(t,e,{target:s,client:a}){var r,i;const n=Object.assign({indent:" ",withWrapper:!0},e),p=new code_builder_1.CodeBuilder({indentation:n.indent,variablesPrefix:n.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA8}),o=formatHttpMethod(t.method);if(n.withComments&&addComments(p),n.withImports&&addImports(p,t),n.withWrapper&&(p.push("public class App {"),p.push(1,"public static void main(String[] args ) throws java.io.IOException {"),p.push(2,"HttpClient httpClient = HttpClientBuilder.create().build();"),p.blank()),null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length){const e=new index_1.HTTPSnippet(null===(i=t.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0]).convert(s,a,Object.assign(Object.assign({},n),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));p.push(e),p.push(2,"JSONObject %s = new JSONObject(EntityUtils.toString(httpClient.execute(%s).getEntity()));","oauth2Response","oauth2Request"),p.push(2,'String accessToken = %s.getString("access_token");',"oauth2Response"),p.blank()}(0,code_helpers_1.printUrlVariablesDeclarations)(t,p,2);const u=(0,code_helpers_1.buildUrlExpression)(t,p);p.push(2,`%s ${p.var("request")} = new %s(%s);`,o,o,u);const h=Object.keys(t.allHeaders);if(!h.length||t.postData&&t.postData.mimeType==constants_2.MediaTypes.MULTIPART||h.forEach((e=>{var s;p.push(2,'%s.setHeader("%s", %s);',p.var("request"),e,(null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)?'"Bearer " + accessToken':`"${t.allHeaders[e]}"`)})),t.basicAuth){const{username:e,password:s}=t.basicAuth;p.push(2,`String encodedString = Base64.getEncoder().encodeToString("${e}:${s}".getBytes());`),p.push(2,'%s.setHeader("%s", "%s"+encodedString);',p.var("request"),"Authorization","Basic ")}if(t.postData)switch((0,utils_1.normalizeMimeType)(t.postData.mimeType)){case constants_2.MediaTypes.URL_ENCODED:t.postData.params&&(p.blank(),p.push(2,"List<NameValuePair> params = new ArrayList<NameValuePair>();"),t.postData.params.forEach((t=>{p.push(2,'params.add(new BasicNameValuePair("%s", "%s"));',t.name,t.value)})),p.push(2,"%s.setEntity(new UrlEncodedFormEntity(params));",p.var("request")),p.blank());break;case constants_2.MediaTypes.MULTIPART:t.postData.params&&(p.push(2,"MultipartEntity reqEntity = new MultipartEntity();"),t.postData.params.forEach((t=>{p.push(2,'reqEntity.addPart("%s", %s);',t.name,isString(t.value)?`new StringBody("${t.value}")`:t.value)})),p.push(2,"%s.setEntity(reqEntity);",p.var("request")));break;case constants_2.MediaTypes.JSON:if(t.postData.jsonObj){p.push(2,"JSONObject payload = new JSONObject();");for(const[e,s]of Object.entries(t.postData.jsonObj))Array.isArray(s)?(p.push(2,'payload.put("%s", new JSONArray()',e),s.forEach((t=>{isObject(t)?(p.push(3,".put(new JSONObject()"),c(t,4),p.push(3,")")):p.push(3,".put(%s)",formatValue(t))})),p.push(2,");")):isObject(s)?(p.push(2,'payload.put("%s", new JSONObject()%s',e,(0,utils_1.isEmptyObject)(s)?");":""),c(s,3),(0,utils_1.isEmptyObject)(s)||p.push(2,");")):p.push(2,'payload.put("%s", %s);',e,formatValue(s));p.push(2,"%s.setEntity(new StringEntity(payload.toString()));",p.var("request"))}break;case constants_2.MediaTypes.XML:t.postData.text&&(p.push(2,'String payload = String.join("\\n"'),t.postData.text.trim().split("\n").forEach((t=>{const e=t.replace(/"/g,'\\"');p.push(3
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const code_builder_1=require("../../helpers/code-builder"),index_1=require("../../index"),utils_1=require("../../../../utils"),generator_1=require("../../../generator"),constants_1=require("../../helpers/constants"),code_helpers_1=require("../../helpers/code-helpers"),constants_2=require("../../../../../constants"),handler=function(t,e,{target:s,client:a}){var r,i;const n=Object.assign({indent:" ",withWrapper:!0},e),p=new code_builder_1.CodeBuilder({indentation:n.indent,variablesPrefix:n.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVA8}),o=formatHttpMethod(t.method);if(n.withComments&&addComments(p),n.withImports&&addImports(p,t),n.withWrapper&&(p.push("public class App {"),p.push(1,"public static void main(String[] args ) throws java.io.IOException {"),p.push(2,"HttpClient httpClient = HttpClientBuilder.create().build();"),p.blank()),null===(r=t.securityOAuth2ExtraCalls)||void 0===r?void 0:r.length){const e=new index_1.HTTPSnippet(null===(i=t.securityOAuth2ExtraCalls)||void 0===i?void 0:i[0]).convert(s,a,Object.assign(Object.assign({},n),{withImports:!1,withWrapper:!1,withComments:!1,variablesPrefix:"oauth2"}));p.push(e),p.push(2,"JSONObject %s = new JSONObject(EntityUtils.toString(httpClient.execute(%s).getEntity()));","oauth2Response","oauth2Request"),p.push(2,'String accessToken = %s.getString("access_token");',"oauth2Response"),p.blank()}(0,code_helpers_1.printUrlVariablesDeclarations)(t,p,2);const u=(0,code_helpers_1.buildUrlExpression)(t,p);p.push(2,`%s ${p.var("request")} = new %s(%s);`,o,o,u);const h=Object.keys(t.allHeaders);if(!h.length||t.postData&&t.postData.mimeType==constants_2.MediaTypes.MULTIPART||h.forEach((e=>{var s;p.push(2,'%s.setHeader("%s", %s);',p.var("request"),e,(null===(s=t.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)?'"Bearer " + accessToken':`"${t.allHeaders[e]}"`)})),t.basicAuth){const{username:e,password:s}=t.basicAuth;p.push(2,`String encodedString = Base64.getEncoder().encodeToString("${e}:${s}".getBytes());`),p.push(2,'%s.setHeader("%s", "%s"+encodedString);',p.var("request"),"Authorization","Basic ")}if(t.postData)switch((0,utils_1.normalizeMimeType)(t.postData.mimeType)){case constants_2.MediaTypes.URL_ENCODED:t.postData.params&&(p.blank(),p.push(2,"List<NameValuePair> params = new ArrayList<NameValuePair>();"),t.postData.params.forEach((t=>{p.push(2,'params.add(new BasicNameValuePair("%s", "%s"));',t.name,t.value)})),p.push(2,"%s.setEntity(new UrlEncodedFormEntity(params));",p.var("request")),p.blank());break;case constants_2.MediaTypes.MULTIPART:t.postData.params&&(p.push(2,"MultipartEntity reqEntity = new MultipartEntity();"),t.postData.params.forEach((t=>{p.push(2,'reqEntity.addPart("%s", %s);',t.name,isString(t.value)?`new StringBody("${t.value}")`:t.value)})),p.push(2,"%s.setEntity(reqEntity);",p.var("request")));break;case constants_2.MediaTypes.JSON:if(t.postData.jsonObj){p.push(2,"JSONObject payload = new JSONObject();");for(const[e,s]of Object.entries(t.postData.jsonObj))Array.isArray(s)?(p.push(2,'payload.put("%s", new JSONArray()',e),s.forEach((t=>{isObject(t)?(p.push(3,".put(new JSONObject()"),c(t,4),p.push(3,")")):p.push(3,".put(%s)",formatValue(t))})),p.push(2,");")):isObject(s)?(p.push(2,'payload.put("%s", new JSONObject()%s',e,(0,utils_1.isEmptyObject)(s)?");":""),c(s,3),(0,utils_1.isEmptyObject)(s)||p.push(2,");")):p.push(2,'payload.put("%s", %s);',e,formatValue(s));p.push(2,"%s.setEntity(new StringEntity(payload.toString()));",p.var("request"))}break;case constants_2.MediaTypes.XML:t.postData.text&&(p.push(2,'String payload = String.join("\\n"'),t.postData.text.trim().split("\n").forEach((t=>{const e=t.replace(/"/g,'\\"');p.push(3,`"${e}", `)})),p.push(2,");"),p.push(2,"%s.setEntity(new StringEntity(payload));",p.var("request")))}return n.withWrapper&&(p.push(2,`String ${p.var("response")} = EntityUtils.toString(httpClient.execute(request).getEntity());`),p.blank(),p.push(2,"System.out.println(response);"),p.push(1,"}"),p.push("}")),p.join();function c(t,e){for(const[s,a]of Object.entries(t))isObject(a)?(p.push(e,'.put("%s", new JSONObject()',s),c(a,e+1),p.push(e,")")):p.push(e,'.put("%s", %s)',s,formatValue(a))}};function addComments(t){t.push("/**"),t.push(" * Requires JDK >= 8"),t.push(" *"),t.push(" * Requires Apache HttpComponents Client >= 4.3.5"),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.apache.httpcomponents/httpcomponents-client"),t.push(" *"),t.push(' * Requires package "junit4"'),t.push(" * See here for installation details:"),t.push(" * https://junit.org/junit4"),t.push(" *"),t.push(' * Requires package "org.json" >= 20180130'),t.push(" * See here for installation details:"),t.push(" * https://search.maven.org/artifact/org.json/json"),t.push(" */"),t.blank()}function addImports(t,e){var s,a,r;t.push("import org.apache.http.util.EntityUtils;"),t.push("import org.apache.http.NameValuePair;"),t.push("import org.apache.http.client.HttpClient;"),t.push("import org.apache.http.client.entity.UrlEncodedFormEntity;"),e.method&&addHttpMethodImport(t,e.method),(null===(s=e.securityOAuth2ExtraCalls)||void 0===s?void 0:s.length)&&(null===(a=e.securityOAuth2ExtraCalls)||void 0===a?void 0:a[0].method.toLowerCase())!==e.method.toLowerCase()&&addHttpMethodImport(t,null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0].method),t.push("import org.apache.http.impl.client.HttpClientBuilder;"),t.push("import org.apache.http.message.BasicNameValuePair;"),t.push("import org.apache.http.entity.StringEntity;"),t.push("import org.json.JSONObject;"),t.push("import org.json.JSONArray;"),t.push("import java.util.ArrayList;"),t.push("import java.util.List;"),t.push("import org.apache.http.entity.mime.MultipartEntity;"),t.push("import org.apache.http.entity.mime.content.StringBody;"),e.basicAuth&&t.push("import java.util.Base64;"),t.blank()}function addHttpMethodImport(t,e){const s=formatHttpMethod(e);t.push(`import org.apache.http.client.methods.${s};`)}function formatHttpMethod(t){return"Http"+(0,generator_1.capitalizeFirst)(t.toLowerCase())}function isString(t){return"[object String]"===Object.prototype.toString.call(t)}function isObject(t){const e=typeof t;return"function"===e||"object"===e&&!!t}function formatValue(t){return isString(t)?JSON.stringify(t):null==t?"JSONObject.NULL":t}exports.info={key:"apachehttp",title:"Apache http",link:"https://hc.apache.org/httpcomponents-client-4.5.x/",description:"Apache HttpClient"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=apachehttp.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const stringify_object_1=__importDefault(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),__1=require("../.."),constants_1=require("../../helpers/constants"),constants_2=require("../../../../../constants"),handler=function(e,t,{target:s,client:a}){var n,r,i,o,
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const stringify_object_1=__importDefault(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),utils_1=require("../../../../utils"),__1=require("../.."),constants_1=require("../../helpers/constants"),constants_2=require("../../../../../constants"),handler=function(e,t,{target:s,client:a}){var n,r,i,o,l;const d=Object.assign({indent:" ",credentials:null},t),c=new code_builder_1.CodeBuilder({indentation:d.indent,variablesPrefix:d.variablesPrefix,capitalize:!0,lang:constants_1.Lang.JAVASCRIPT}),p={method:e.method.toUpperCase()};Object.keys(e.headersObj).length&&(p.headers=e.headersObj);let u=!1;if(d.withComments&&addComments(c),null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length){const t=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(s,a,Object.assign(Object.assign({},d),{withImports:!1,withComments:!1,variablesPrefix:"oAuth2"}));c.push(t),c.blank(),p.headers=p.headers||{},p.headers.Authorization="'Bearer ' + oAuth2Data.access_token",u=!0}null!==d.credentials&&(p.credentials=d.credentials);const h=Object.getOwnPropertyNames(e.queryObj).length;if(h&&c.push(`const ${c.var("query")} = new URLSearchParams(${(0,stringify_object_1.default)(e.queryObj,{indent:d.indent,inlineCharacterLimit:25})}).toString();`).blank(),e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case constants_2.MediaTypes.URL_ENCODED:p.body=e.postData.paramsObj?`new URLSearchParams(${c.var("formData")}).toString()`:e.postData.text,e.postData.paramsObj&&c.push(`const ${c.var("formData")} = ${(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.paramsObj,{indent:d.indent,inlineCharacterLimit:25}),{level:0,firstLine:!1})};`).blank();break;case constants_2.MediaTypes.JSON:e.postData.jsonObj&&(p.body=`JSON.stringify(${(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.jsonObj,{indent:d.indent,inlineCharacterLimit:25}),{level:1,firstLine:!1})})`);break;case constants_2.MediaTypes.MULTIPART:c.push(`const ${c.var("form")} = new FormData();`),null===(i=null==p?void 0:p.headers)||void 0===i||delete i["Content-Type"],e.postData.params.forEach((function(e){c.push(`${c.var("form")}.append(%s, %s);`,JSON.stringify(e.name),JSON.stringify(e.value||e.fileName||""))})),p.body=c.var("form"),c.blank();break;default:e.postData.text&&(p.body=`\`${(0,code_helpers_1.addIndentation)(e.postData.text,{level:2,indent:d.indent,firstLine:!1}).trim()}\``)}const _=p.headers&&p.headers.Accept&&(0,utils_1.normalizeMimeType)(p.headers.Accept)===constants_2.MediaTypes.JSON||(0,utils_1.normalizeMimeType)(null===(o=e.postData)||void 0===o?void 0:o.mimeType)===constants_2.MediaTypes.JSON;if(e.basicAuth){const{username:t,password:s}=e.basicAuth;p.headers=p.headers||{},p.headers.Authorization=`'Basic ' + btoa('${t}:${s}')`,u=!0}(0,code_helpers_1.printUrlVariablesDeclarations)(e,c);const m=(0,code_helpers_1.buildUrlExpression)(e,c);return c.push(`const ${c.var("resp")} = await fetch(`).push(1,"`"+m+(h?"?${"+c.var("query")+"}":"")+"`,").push((0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(p,{indent:d.indent,inlineCharacterLimit:25,transform:(0,code_helpers_1.getPreserveTransformer)({body:!0,authorizationHeader:u})}),{level:1,indent:d.indent})).push(");").blank(),(null===(l=e.allResponseCodes)||void 0===l?void 0:l.includes("204"))?(c.push("if (resp.status === 204) {").push(1,"console.log('success');").push("} else {"),c.push(1,`const ${c.var("data")} = await ${c.var("resp")}.${_?"json()":"text()"};`).push(1,`console.log(${c.var("data")});`).push("}")):c.push(`const ${c.var("data")} = await ${c.var("resp")}.${_?"json()":"text()"};`).push(`console.log(${c.var("data")});`),c.join()};function addComments(e){e.push("/**"),e.push(" * Requires ES8-compatible browser: https://caniuse.com/async-functions"),e.push(" */"),e.blank()}exports.info={key:"fetch",title:"fetch",link:"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch",description:"Perform asynchronous HTTP requests with the Fetch API"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -6,7 +6,7 @@ declare const _default: {
|
|
|
6
6
|
default: string;
|
|
7
7
|
};
|
|
8
8
|
fetch: import("../..").LanguageHandler<(import("../../..").BasicLanguageOptions & {
|
|
9
|
-
credentials?: "
|
|
9
|
+
credentials?: "omit" | "same-origin" | "include";
|
|
10
10
|
}) | undefined>;
|
|
11
11
|
};
|
|
12
12
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const stringify_object_1=__importDefault(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),utils_1=require("../../../../utils"),__1=require("../.."),constants_2=require("../../../../../constants"),handler=function(e,t,{target:a,client:s}){var n,r,i,o,l
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.info=void 0;const stringify_object_1=__importDefault(require("stringify-object")),code_builder_1=require("../../helpers/code-builder"),code_helpers_1=require("../../helpers/code-helpers"),constants_1=require("../../helpers/constants"),utils_1=require("../../../../utils"),__1=require("../.."),constants_2=require("../../../../../constants"),handler=function(e,t,{target:a,client:s}){var n,r,i,o,l;const d=Object.assign({indent:" ",showBoilerplate:!0,level:1},t),{level:p}=d;let c=!1;const h=new code_builder_1.CodeBuilder({indentation:d.indent,variablesPrefix:d.variablesPrefix,capitalize:!0,lang:constants_1.Lang.NODEJS});d.withComments&&addComments(h),d.withImports&&(h.push("import fetch from 'node-fetch';"),h.blank()),d.showBoilerplate&&h.push("async function run() {");const u={method:e.method.toUpperCase()};Object.keys(e.headersObj).length&&(u.headers=e.headersObj);let m=!1;if(null===(n=e.securityOAuth2ExtraCalls)||void 0===n?void 0:n.length){const t=new __1.HTTPSnippet(null===(r=e.securityOAuth2ExtraCalls)||void 0===r?void 0:r[0]).convert(a,s,Object.assign(Object.assign({},d),{withImports:!1,withComments:!1,variablesPrefix:"oAuth2",showBoilerplate:!1,level:1}));h.push(t),h.blank(),u.headers=u.headers||{},u.headers.Authorization="'Bearer ' + oAuth2Data.access_token",m=!0}const f=Object.getOwnPropertyNames(e.queryObj).length;if(f&&h.push(p,`const ${h.var("query")} = new URLSearchParams(${(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.queryObj,{indent:d.indent,inlineCharacterLimit:25}),{level:p,indent:d.indent,firstLine:!1})}).toString();`).blank(),e.postData)switch((0,utils_1.normalizeMimeType)(e.postData.mimeType)){case constants_2.MediaTypes.URL_ENCODED:u.body=e.postData.paramsObj?`new URLSearchParams(${h.var("formData")}).toString()`:e.postData.text,e.postData.paramsObj&&h.push(p,`const ${h.var("formData")} = ${(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.paramsObj,{indent:d.indent,inlineCharacterLimit:25}),{level:p,firstLine:!1})};`).blank();break;case constants_2.MediaTypes.JSON:e.postData.jsonObj&&(u.body=`JSON.stringify(${(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(e.postData.jsonObj,{indent:d.indent,inlineCharacterLimit:25}),{level:p,firstLine:!1})})`);break;case constants_2.MediaTypes.MULTIPART:null===(i=null==u?void 0:u.headers)||void 0===i||delete i["Content-Type"],d.withImports&&h.unshift("import FormData from 'form-data';"),h.push(p,`const ${h.var("form")} = new FormData();`),e.postData.params.forEach((function(e){e.fileName||e.fileName||e.contentType?e.fileName&&(c=!0,h.blank(),h.push(p,`${h.var("form")}.append('" + param.name + "', fs.createReadStream('" + param.fileName + "'));`)):h.push(p,"form.append('"+e.name+"','"+e.value+"');")})),u.body=h.var("form"),h.blank();break;default:e.postData.text&&(u.body=`\`${(0,code_helpers_1.addIndentation)(e.postData.text,{level:p+1,indent:d.indent,firstLine:!1}).trim()}\``)}if(e.cookies.length){let t="";e.cookies.forEach((function(e){t=t+encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)+"; "})),t=t.trim(),u.headers||(u.headers={}),u.headers.cookie=t}if(e.basicAuth){const{username:t,password:a}=e.basicAuth;u.headers=u.headers||{},u.headers.Authorization=`'Basic ' + Buffer.from('${t}:${a}').toString('base64')`,m=!0}c&&d.withImports&&h.unshift("import fs from 'fs';");const _=u.headers&&u.headers.Accept&&(0,utils_1.normalizeMimeType)(u.headers.Accept)===constants_2.MediaTypes.JSON||(0,utils_1.normalizeMimeType)(null===(o=e.postData)||void 0===o?void 0:o.mimeType)===constants_2.MediaTypes.JSON;(0,code_helpers_1.printUrlVariablesDeclarations)(e,h,p);const b=(0,code_helpers_1.buildUrlExpression)(e,h);return h.push(p,`const ${h.var("resp")} = await fetch(`).push(p+1,"`"+b+(f?"?${"+h.var("query")+"}":"")+"`,").push(p+1,(0,code_helpers_1.addIndentation)((0,stringify_object_1.default)(u,{indent:d.indent,inlineCharacterLimit:25,transform:(0,code_helpers_1.getPreserveTransformer)({body:!0,authorizationHeader:m})}),{level:p+1,indent:d.indent,firstLine:!1})).push(p,");").blank(),(null===(l=e.allResponseCodes)||void 0===l?void 0:l.includes("204"))?(h.push(p,"if (resp.status === 204) {").push(p+1,"console.log('success');").push(p,"} else {"),h.push(p+1,`const ${h.var("data")} = await ${h.var("resp")}.${_?"json()":"text()"};`).push(p+1,`console.log(${h.var("data")});`).push(p,"}")):h.push(p,`const ${h.var("data")} = await ${h.var("resp")}.${_?"json()":"text()"};`).push(p,`console.log(${h.var("data")});`),d.showBoilerplate&&h.push("}").blank().push("run();"),h.join().replace(/"fs\.createReadStream\(\\"(.+)\\"\)"/,'fs.createReadStream("$1")')};function addComments(e){e.push("/**"),e.push(" * Requires Node.js >= 14"),e.push(" *"),e.push(' * Requires module "node-fetch" >= 2.6.1'),e.push(" * See here for installation details:"),e.push(" * https://www.npmjs.com/package/node-fetch"),e.push(" */"),e.blank()}exports.info={key:"fetch",title:"Fetch",link:"https://github.com/bitinn/node-fetch",description:"Simplified HTTP node-fetch client"},exports.default=handler;
|
|
2
2
|
//# sourceMappingURL=fetch.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectToPhpArray=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectToPhpArray=objectToPhpArray;const simpleTypes=["number","boolean","function","symbol"];function isRegexp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function isObject(e){const n=typeof e;return null!==e&&("object"===n||"function"===n)}function objectToPhpArray(e,n,r=""){const t=[];return function e(n,r={},i=""){r.indent=r.indent||"\t";const a={newLine:"\n",newLineOrSpace:"\n",pad:i,indent:i+r.indent},o=e=>{if(void 0===r.inlineCharacterLimit)return e;const n=e.replace(new RegExp(a.newLine,"g"),"").replace(new RegExp(a.newLineOrSpace,"g")," ").replace(new RegExp(a.pad+"|"+a.indent,"g"),"");return n.length<=r.inlineCharacterLimit?n:e.replace(new RegExp(a.newLine+"|"+a.newLineOrSpace,"g"),"\n").replace(new RegExp(a.pad,"g"),i).replace(new RegExp(a.indent,"g"),i+r.indent)};if(-1!==t.indexOf(n))return'"Circular"';if(null===n)return"NULL";if(void 0===n||simpleTypes.includes(typeof n)||isRegexp(n))return String(n);if(n instanceof Date)return`date('${n.toISOString()}')`;if(Array.isArray(n)){if(0===n.length)return"array()";t.push(n);const p="array("+a.newLine+n.map(((t,o)=>{const p=n.length-1===o?a.newLine:","+a.newLineOrSpace;let c=e(t,r,i+r.indent);return r.transform&&(c=r.transform(n,o,c)),a.indent+c+p})).join("")+a.pad+")";return t.pop(),o(p)}if(isObject(n)){let p=Object.keys(n);if(r.filter&&(p=p.filter((e=>{var t;return null===(t=r.filter)||void 0===t?void 0:t.call(r,n,e)}))),0===p.length)return Array.isArray(n)?"array()":"(object)[]";t.push(n);const c="array("+a.newLine+p.map(((t,o)=>{const c=p.length-1===o?a.newLine:","+a.newLineOrSpace,l="symbol"==typeof t,s=!l&&/^[a-z$_][a-z$_0-9]*$/i.test(t),u=l||s?t:e(t,r);let g=e(n[t],r,i+r.indent);return r.transform&&(g=r.transform(n,t,g)),`${a.indent}"${String(u)}" => ${g}${c}`})).join("")+a.pad+")";return t.pop(),o(c)}return n=String(n).replace(/[\r\n]/g,(e=>"\n"===e?"\\n":"\\r")),!1===r.singleQuotes?`"${n=n.replace(/"/g,'\\"')}"`:`"${n=n.replace(/\\?'/g,"\\'")}"`}(e,n,r)}
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function objectToRString(t,
|
|
1
|
+
"use strict";function objectToRString(t,n){return t?"string"==typeof t?JSON.stringify(t):JSON.stringify(t,null,1).split("\n").map(((t,o,i)=>o===i.length-1?t:((null==n?void 0:n.indent)||" ")+t)).join("\n").trim():""}function postDataToRListBody(t,n){return"\n"+t.map((({name:t,value:o})=>((null==n?void 0:n.indent)||"")+`${t} = "${o}"`)).join(",\n")+"\n"}Object.defineProperty(exports,"__esModule",{value:!0}),exports.objectToRString=objectToRString,exports.postDataToRListBody=postDataToRListBody;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeShowExtensions=normalizeShowExtensions,exports.normalizeScrollYOffset=normalizeScrollYOffset;const dom_1=require("../../utils/dom"),helpers_1=require("../../utils/helpers");function normalizeShowExtensions(e){if(void 0===e)return!1;if(""===e)return!0;if("string"!=typeof e)return e;switch(e){case"true":return!0;case"false":return!1;default:return e.split(",").map((e=>e.trim()))}}function normalizeScrollYOffset(e){if("string"==typeof e&&!(0,helpers_1.isNumeric)(e)){const r=(0,dom_1.querySelector)(e);r||console.warn("scrollYOffset value is a selector to non-existing element. Using offset 0 by default");const t=r&&r.getBoundingClientRect().bottom||0;return()=>t}return"number"==typeof e||(0,helpers_1.isNumeric)(e)?()=>"number"==typeof e?e:parseFloat(e):"function"==typeof e?()=>{const r=e();return"number"!=typeof r&&console.warn(`scrollYOffset should return number but returned value "${r}" of type ${typeof r}`),r}:(void 0!==e&&console.warn("Wrong value for scrollYOffset ReDoc option: should be string, number or function"),()=>0)}
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeOptions=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeOptions=normalizeOptions;const theme_1=require("@redocly/theme"),constants_1=require("../../constants"),utils_1=require("../../utils"),helpers_1=require("./helpers"),constants_2=require("../code-samples/constants");function normalizeOptions(e,o){var s,n,i,a,l,t,r,d,u,c,p;e=Object.assign(Object.assign(Object.assign({},o),e),{markdocOptions:Object.assign(Object.assign({},null==e?void 0:e.markdocOptions),{components:Object.assign(Object.assign({},null===(s=null==o?void 0:o.markdocOptions)||void 0===s?void 0:s.components),null===(n=null==e?void 0:e.markdocOptions)||void 0===n?void 0:n.components),tags:Object.assign(Object.assign({},null===(i=null==o?void 0:o.markdocOptions)||void 0===i?void 0:i.tags),null===(a=null==e?void 0:e.markdocOptions)||void 0===a?void 0:a.tags),nodes:Object.assign(Object.assign(Object.assign({},null===(l=null==o?void 0:o.markdocOptions)||void 0===l?void 0:l.nodes),null===(t=null==e?void 0:e.markdocOptions)||void 0===t?void 0:t.nodes),{heading:(null===(d=null===(r=null==o?void 0:o.markdocOptions)||void 0===r?void 0:r.nodes)||void 0===d?void 0:d.heading)||(null===(u=null==e?void 0:e.markdocOptions)||void 0===u?void 0:u.nodes.heading)})})});const m=Array.isArray(e.ignoreNamedSchemas)?e.ignoreNamedSchemas:null===(c=e.ignoreNamedSchemas)||void 0===c?void 0:c.split(",").map((e=>e.trim()));return{downloadUrls:e.downloadUrls,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl&&(0,theme_1.addTrailingSlash)(e.corsProxyUrl),hideSidebar:(0,utils_1.argValueToBoolean)(e.hideSidebar,!1),jsonSamplesExpandLevel:(0,utils_1.argValueToExpandLevel)(e.jsonSamplesExpandLevel,2),generatedSamplesMaxDepth:(0,utils_1.argValueToInt)(e.generatedSamplesMaxDepth,8),hideDownloadButtons:(0,utils_1.argValueToBoolean)(e.hideDownloadButtons,!1),hideInfoMetadata:(0,utils_1.argValueToBoolean)(e.hideInfoMetadata,!1),hideLoading:(0,utils_1.argValueToBoolean)(e.hideLoading,!1),hideSchemaTitles:(0,utils_1.argValueToBoolean)(e.hideSchemaTitles,!1),maxDisplayedEnumValues:(0,utils_1.argValueToNumber)(e.maxDisplayedEnumValues),mockServer:(null===(p=e.mockServer)||void 0===p?void 0:p.url)?{url:e.mockServer.url,position:e.mockServer.position||"first",description:e.mockServer.description||"Mock server"}:void 0,hideReplay:(0,utils_1.argValueToBoolean)(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI||null,onlyRequiredInSamples:(0,utils_1.argValueToBoolean)(e.onlyRequiredInSamples,!1),onDeepLinkClick:e.onDeepLinkClick||(0,utils_1.getWindowReferenceOptions)(constants_1.WindowReferenceOptions.ON_DEEP_LINK_CLICK),requestInterceptor:e.requestInterceptor||(0,utils_1.getWindowReferenceOptions)(constants_1.WindowReferenceOptions.REQUEST_INTERCEPTOR),routingBasePath:(0,theme_1.isUndefined)(e.disableRouter)?"":e.routingBasePath&&(0,utils_1.normalizePath)(e.routingBasePath)||"",schemasExpansionLevel:(0,utils_1.argValueToExpandLevel)(e.schemasExpansionLevel),feedback:e.feedback||{hide:!1},sortRequiredPropsFirst:(0,utils_1.argValueToBoolean)(e.sortRequiredPropsFirst,!1),scrollYOffset:(0,helpers_1.normalizeScrollYOffset)(e.scrollYOffset),showExtensions:(0,helpers_1.normalizeShowExtensions)(e.showExtensions),sanitize:(0,utils_1.argValueToBoolean)(e.sanitize,!1),skipBundle:(0,utils_1.argValueToBoolean)(e.skipBundle,!1),ignoreNamedSchemas:new Set(m),markdocOptions:null==e?void 0:e.markdocOptions,codeSamples:e.codeSamples||{languages:Object.values(constants_2.Languages).map((e=>({lang:e})))},layout:e.layout||theme_1.LayoutVariant.THREE_PANEL,events:e.events||{},unstable_hooks:e.unstable_hooks||(0,utils_1.getWindowReferenceOptions)(constants_1.WindowReferenceOptions.HOOKS)||{},unstable_skipSamples:(0,utils_1.argValueToBoolean)(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples||[],hidePropertiesPrefix:(0,utils_1.argValueToBoolean)(null==e?void 0:e.hidePropertiesPrefix,!1)}}
|
|
2
2
|
//# sourceMappingURL=normalizeOptions.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSameHash=isSameHash,exports.constructFieldDeepFragment=constructFieldDeepFragment,exports.joinWithSeparator=joinWithSeparator,exports.makeDeepLink=makeDeepLink;const utils_1=require("../../utils"),mediaContent_1=require("../../models/mediaContent");function isSameHash(e,t){return e===t||"#"+e===t||e==="#"+t}function getContentTypeName(e){var t,n,o,i,d,s,r,p,l,a,u,v,c;if(!e.in)return"request"===e.deps.type&&(null===(o=null===(n=null===(t=e.deps.operation)||void 0===t?void 0:t.requestBody)||void 0===n?void 0:n.content)||void 0===o?void 0:o.mediaTypes)?(null===(s=null===(d=null===(i=e.deps.operation)||void 0===i?void 0:i.requestBody)||void 0===d?void 0:d.content)||void 0===s?void 0:s.mediaTypes.length)>1?(null===(p=null===(r=e.deps.operation)||void 0===r?void 0:r.requestBody)||void 0===p?void 0:p.content)&&(0,mediaContent_1.getActiveMediaType)(e.deps.operation.requestBody.content).name:void 0:"response"===e.deps.type&&(null===(a=null===(l=e.deps.response)||void 0===l?void 0:l.content)||void 0===a?void 0:a.mediaTypes)&&(null===(v=null===(u=e.deps.response)||void 0===u?void 0:u.content)||void 0===v?void 0:v.mediaTypes.length)>1?(null===(c=e.deps.response)||void 0===c?void 0:c.content)&&(0,mediaContent_1.getActiveMediaType)(e.deps.response.content).name:void 0}function constructFieldDeepFragment(e){var t,n;if(!e)return"";const o={t:e.deps.type,in:e.in||e.deps.in,c:"response"===e.deps.type?null===(t=e.deps.response)||void 0===t?void 0:t.code:void 0,cb:(null===(n=e.deps.operation)||void 0===n?void 0:n.isCallback)?e.deps.operation.callbackId:void 0,ct:getContentTypeName(e),path:e.fieldFullPath};return utils_1.queryString.stringify(o,{encode:!1,sort:!1})}function joinWithSeparator(e="",t="",n="/"){return e.endsWith(n)&&(e=e.slice(0,-n.length)),t.startsWith(n)&&(t=t.slice(n.length)),e&&t?e+n+t:e+t}function makeDeepLink(e,t){return(`/${e=(0,utils_1.encodeBackSlashes)(e)}#`+joinWithSeparator(e,t)).toLowerCase()}
|
|
2
2
|
//# sourceMappingURL=helpers.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildMenuStructure=buildMenuStructure,exports.buildContentItems=buildContentItems;const tags_1=require("./tags"),markdown_1=require("./markdown"),utils_1=require("../../utils"),constants_1=require("../../constants");function buildMenuStructure(t,e){var n,i,s;const{definition:o}=t,{schemaDefinitionsTagName:u}=e,r=[{id:"",name:(null===(i=null===(n=null==o?void 0:o.info)||void 0===n?void 0:n["x-seo"])||void 0===i?void 0:i.title)||(null===(s=null==o?void 0:o.info)||void 0===s?void 0:s.title)||"Overview",href:"/",depth:1,level:1,type:"section",infoDefinition:o.info,items:[]}],d=[...o.tags||[]];d.some((t=>t.name===constants_1.DEFAULT_WEBHOOKS_TAG_NAME))||d.push({name:constants_1.DEFAULT_WEBHOOKS_TAG_NAME});!d.find((t=>(null==t?void 0:t.name)===u))&&u&&d.push({name:u});const a=(0,tags_1.getTagsWithOperations)(t,d),l=o["x-tagGroups"];return r.push(...(0,markdown_1.addMarkdownItems)((0,utils_1.getValueFromMdParsedExtension)(o.info,"description")||"",void 0,1)),l&&l.length>0?r.push(...(0,tags_1.getTagGroupsItems)(t,void 0,l,a,e)):r.push(...(0,tags_1.getTagsItems)(t,a,void 0,void 0,e)),r}function buildContentItems(t,e){const n=buildMenuStructure(t,e);return{contentItems:n,flatItems:(0,utils_1.flattenByProp)(n||[],"items")}}
|
|
2
2
|
//# sourceMappingURL=builder.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addMarkdownItems=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addMarkdownItems=addMarkdownItems;const markdoc_1=require("@markdoc/markdoc"),theme_1=require("@redocly/theme"),models_1=require("../../models"),utils_1=require("../../utils");function addMarkdownItems(e,t,i){const n=(0,theme_1.isString)(e)?(0,markdoc_1.parse)(e):markdoc_1.Ast.fromJSON(JSON.stringify(null==e?void 0:e.result)),r=[];let o;const s=(e,t,i=r,n,o)=>{let s;e=(0,utils_1.unescapeHTMLChars)(e),n.attributes.id?s=n.attributes.id:(s=o?`${o}/${(0,utils_1.safeSlugify)(e)}`:`section/${(0,utils_1.safeSlugify)(e)}`,n.attributes.id=s);const l={id:s.toLowerCase(),name:e,level:t,items:[],ast:[n]};return i.push(l),l},l=(e,t)=>{var i,n;null===(n=null===(i=e[e.length-1])||void 0===i?void 0:i.ast)||void 0===n||n.push(t)},d=e=>{var t;for(const i of e.children){const e=getMarkdownContent(i)||"";"heading"===i.type&&1===i.attributes.level?o=s(e,i.attributes.level,void 0,i):i.attributes.level?s(e,i.attributes.level,null==o?void 0:o.items,i,null==o?void 0:o.id):(null===(t=null==o?void 0:o.items)||void 0===t?void 0:t.length)?l(null==o?void 0:o.items,i):(null==r?void 0:r.length)&&l(r,i)}};if(Array.isArray(n))for(const e of n)d(e);else d(n);return mapHeadingsDeep(t,r,i)}function mapHeadingsDeep(e,t,i=1){return t.map((t=>{const n=(0,models_1.getTagOrGroup)("section",t,e);return n.depth=i,t.items&&(n.items=mapHeadingsDeep(n,t.items,i+1)),n}))}function getMarkdownContent(e){var t,i;return"string"==typeof(null===(t=null==e?void 0:e.attributes)||void 0===t?void 0:t.content)?null===(i=e.attributes)||void 0===i?void 0:i.content:(null==e?void 0:e.children)?getMarkdownContent(e.children[0]):void 0}
|
|
2
2
|
//# sourceMappingURL=markdown.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getOperationsItems=getOperationsItems,exports.getHref=getHref;const utils_1=require("../../utils");function getOperationsItems(e,t,r){if(0===t.operations.length)return[];const o=[],s=[];for(const i of t.operations){const t=(0,utils_1.getOperationId)(i,e),p={id:t,type:"operation",parent:e,operationDefinition:i,depth:r,name:(0,utils_1.getOperationName)(i),httpVerb:i.httpVerb,path:i.pathName,items:[],isWebhook:i.isWebhook,operationId:i.operationId,badges:i["x-badges"]||[],href:getHref({id:t}),deprecated:!!i.deprecated};i.isWebhook?s.push(p):o.push(p)}return[...o.sort(((e,t)=>Number(e.deprecated)-Number(t.deprecated))),...s.sort(((e,t)=>Number(e.deprecated)-Number(t.deprecated)))]}function getHref({id:e}){return(0,utils_1.encodeBackSlashes)(`/${e}`.toLowerCase())}
|
|
2
2
|
//# sourceMappingURL=operation.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getTagsItems=getTagsItems,exports.getTagGroupsItems=getTagGroupsItems,exports.getTagsWithOperations=getTagsWithOperations;const group_1=require("../../models/group"),constants_1=require("../../constants"),utils_1=require("../../utils"),operation_1=require("./operation"),markdown_1=require("./markdown");function getTagsItems(e,t,s,o,n){let a;if(a=void 0===o?Object.keys(t):o.tags,!Array.isArray(a))return console.warn("Unexpected values of tags. Check tags or x-tagGroups in your definition."),[];const r=a.map((e=>t[e]?(t[e].used=!0,t[e]):(console.warn(`Non-existing tag "${e}" is added to the group "${null==o?void 0:o.name}"`),null))),i=[];for(const t of r){if(!t)continue;const o=(0,group_1.getTagOrGroup)("tag",t,s);if(o.depth=constants_1.GROUP_DEPTH+1,""===t.name){const e=[...(0,markdown_1.addMarkdownItems)((0,utils_1.getValueFromMdParsedExtension)(t,"description")||"",o,o.depth+1),...(0,operation_1.getOperationsItems)(void 0,t,o.depth+1)];i.push(...e);continue}const a=getTagRelatedSchema({definition:e.definition,tag:t,parent:o,schemaDefinitionsTagName:n.schemaDefinitionsTagName});o.items=[...a,...(0,markdown_1.addMarkdownItems)((0,utils_1.getValueFromMdParsedExtension)(t,"description")||"",o,o.depth+1),...(0,operation_1.getOperationsItems)(o,t,o.depth+1)],i.push(o)}return i.filter((({name:e,items:t})=>e!==constants_1.DEFAULT_WEBHOOKS_TAG_NAME||t.length>0))}function getTagGroupsItems(e,t,s,o,n){const a=[];for(const r of s){const s=(0,group_1.getTagOrGroup)("group",r,t);s.depth=constants_1.GROUP_DEPTH,s.items=getTagsItems(e,o,s,r,n),a.push(s)}return a}function getTagRelatedSchema({definition:e,tag:t,parent:s,schemaDefinitionsTagName:o}){var n;const a=o?[o]:[];return Object.entries((null===(n=e.components)||void 0===n?void 0:n.schemas)||{}).map((([e,o])=>{if(!(o["x-tags"]||a).includes(t.name))return null;const n=(0,group_1.getTagOrGroup)("schema",{name:e,"x-displayName":`${o.title||e}`,description:`{% schemaDefinition showWriteOnly="true" schemaRef="#/components/schemas/${e}" /%}`,isSchema:!0,level:2},s);return n.depth=s.depth+1,n})).filter(Boolean)}function getTagsWithOperations(e,t){const{definition:s}=e,o={},n=s["x-webhooks"]||s.webhooks;for(const e of t||[])o[e.name]=Object.assign(Object.assign({},e),{operations:[]});return s.paths&&getTags(e,s.paths,o),n&&getTags(e,n,o,!0),o}function getTags(e,t,s,o){for(const n of Object.keys(t||{})){const a=t[n],r=Object.keys(a).filter(utils_1.isOperationName);for(const t of r){const r=a[t];if(a.$ref){const{resolved:t}=e.deref(a);getTags(e,{[n]:t},s,o);continue}let i=null==r?void 0:r.tags;i&&i.length||(i=o?[constants_1.DEFAULT_WEBHOOKS_TAG_NAME]:[""]);for(const e of i){let i=s[e];void 0===i&&(i={name:e,operations:[]},s[e]=i),i["x-traitTag"]||i.operations.push(Object.assign(Object.assign({},r),{pathName:n,pointer:utils_1.JsonPointer.compile(["paths",n,t]),httpVerb:t,pathParameters:a.parameters||[],pathServers:a.servers,isWebhook:!!o}))}}}}
|
|
2
2
|
//# sourceMappingURL=tags.js.map
|
package/lib/services/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.cryptoLib=void 0,exports.isSameMime=isSameMime,exports.normalizeMimeType=normalizeMimeType,exports.unescapeServerVariables=unescapeServerVariables,exports.arrayMergeStrategy=arrayMergeStrategy,exports.isEmptyObject=isEmptyObject,exports.deepClone=deepClone;const deepmerge_1=__importDefault(require("deepmerge")),theme_1=require("@redocly/theme"),utils_1=require("../utils");function isSameMime(e,r){return!(!e||!r)&&normalizeMimeType(e)===normalizeMimeType(r)}function normalizeMimeType(e){if(!e)return;const r=e.split(";")[0].toLowerCase(),[t,i]=r.split("/");if(void 0===i)return t;return`${t}/${i.split("+").pop()}`}function unescapeServerVariables(e){const r=new RegExp("%7B","g"),t=new RegExp("%7D","g");return e.replace(r,"{").replace(t,"}").replace("///","//")}function arrayMergeStrategy(e,r){if(!e.length||!hasObjectOrArray(e))return r;const t=e.filter((e=>Object.keys(e).length>0));return r.forEach((function(r,i){(0,utils_1.isMergeableObject)(r)?t[i]=(0,deepmerge_1.default)(e[i],r,{arrayMerge:arrayMergeStrategy}):Array.isArray(r)?t.push(r):t[i]=r})),t}const hasObjectOrArray=e=>e.some((e=>(0,theme_1.isObject)(e)&&Object.keys(e).length>0));function isEmptyObject(e){return!!e&&0===Object.keys(e).length}function deepClone(e){if("object"!=typeof e||null===e)return e;const r=Array.isArray(e)?[]:{};for(const t in e){const i=e[t];r[t]=deepClone(i)}return r}exports.cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0;
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/lib/standalone.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revision=exports.version=exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.revision=exports.version=exports.setSecurityDetailsVariants=exports.setParameterValue=exports.setSecurityDetails=void 0,exports.hydrate=hydrate,exports.init=init,exports.setPublicPath=setPublicPath;const jsx_runtime_1=require("react/jsx-runtime");require("core-js/es/array/find-index"),require("core-js/es/array/find"),require("core-js/es/array/includes"),require("core-js/es/map"),require("core-js/es/number/is-integer"),require("core-js/es/object/assign"),require("core-js/es/object/entries"),require("core-js/es/object/is"),require("core-js/es/object/values"),require("core-js/es/promise"),require("core-js/es/string/ends-with"),require("core-js/es/string/starts-with"),require("core-js/es/symbol"),require("unfetch/polyfill/index"),require("url-polyfill");const path_1=require("path"),react_1=require("react"),client_1=require("react-dom/client"),theme_1=require("@redocly/theme"),utils_1=require("./utils"),components_1=require("./components");var utils_2=require("./utils");Object.defineProperty(exports,"setSecurityDetails",{enumerable:!0,get:function(){return utils_2.setSecurityDetails}}),Object.defineProperty(exports,"setParameterValue",{enumerable:!0,get:function(){return utils_2.setParameterValue}}),Object.defineProperty(exports,"setSecurityDetailsVariants",{enumerable:!0,get:function(){return utils_2.setSecurityDetailsVariants}});const url=(0,utils_1.getJsUrl)(),__dirname=url?(0,path_1.dirname)(url)+"/":"";function attributesMap(e){const t={},r=e.attributes;for(let e=0;e<r.length;e++){const i=r[e];t[i.name]=i.value}return t}function parseOptionsFromElement(e){const t=attributesMap(e),r={};for(const e in t){r[e.replace(/-(.)/g,((e,t)=>t.toUpperCase()))]=t[e]}return r}function hydrate(e,t=document.querySelector("redoc")){(0,client_1.hydrateRoot)(t,(0,jsx_runtime_1.jsx)(components_1.RedoclyOpenAPIDocs,{store:e}))}function init(e,t={},r=(0,utils_1.querySelector)("redoc")){if(null===r)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');let i,s;"string"==typeof e?i=e:"object"==typeof e&&(s=e);(0,client_1.createRoot)(r).render((0,react_1.createElement)(components_1.RedoclyOpenAPIDocsStandalone,{definition:s,definitionUrl:i,options:Object.assign(Object.assign({},t),parseOptionsFromElement(r))},["Loading..."]))}function setPublicPath(e){__webpack_public_path__=e}function autoInit(){const e=(0,utils_1.querySelector)("redoc");if(!e)return;const t=e.getAttribute("spec-url");t&&init(t,{},e)}exports.version=__REDOCLY_API_REFERENCE_VERSION__,exports.revision=__REDOCLY_API_REFERENCE_REVISION__,theme_1.IS_BROWSER&&setPublicPath(__dirname),autoInit();
|
|
2
2
|
//# sourceMappingURL=standalone.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function areArraysEqual(r
|
|
1
|
+
"use strict";function areArraysEqual(e,r){return e.length===r.length&&e.every(((e,a)=>e===r[a]))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.areArraysEqual=areArraysEqual;
|
|
2
2
|
//# sourceMappingURL=areArraysEqual.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function argValueToBoolean(e,
|
|
1
|
+
"use strict";function argValueToBoolean(e,r){return void 0===e?r||!1:"string"==typeof e?"false"!==e:e}function argValueToNumber(e,r=0){return"string"==typeof e?parseInt(e,10):"number"==typeof e?e:r}function argValueToInt(e,r=0){return"string"==typeof e?parseInt(e,10):"number"==typeof e?Math.ceil(e):r}function argValueToExpandLevel(e,r){return void 0===e?r:"all"===e?1/0:argValueToInt(e,r)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.argValueToBoolean=argValueToBoolean,exports.argValueToNumber=argValueToNumber,exports.argValueToInt=argValueToInt,exports.argValueToExpandLevel=argValueToExpandLevel;
|
|
2
2
|
//# sourceMappingURL=argValuesHelpers.js.map
|
package/lib/utils/compose.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const compose: <T>(fn1: (a: T) => T, ...fns: (
|
|
1
|
+
export declare const compose: <T>(fn1: (a: T) => T, ...fns: Array<(a: T) => T>) => (a: T) => T;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertExamplesFormat=void 0;const jstoxml_1=require("jstoxml"),openapi_1=require("./openapi"),convertExamplesFormat=e=>{if(!e.examples)return e;const t=Object.fromEntries(Object.entries(e.examples).map((([e,t])=>(0,openapi_1.isXmlLike)(t.mime)&&t.value&&"object"==typeof t.value?[e,Object.assign(Object.assign({},t),{value:(0,jstoxml_1.toXML)(t.value,{indent:" "})})]:[e,t])));return Object.assign(Object.assign({},e),{examples:t})};exports.convertExamplesFormat=convertExamplesFormat;
|
|
2
|
+
//# sourceMappingURL=convertExamplesFormat.js.map
|
package/lib/utils/cookies.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function setCookie(e,o,t={path:"/"}){if("undefined"==typeof document)return;"number"==typeof t.expires&&(t.expires=new Date(Date.now()+864e5*t.expires)),t.expires&&(t.expires=t.expires instanceof Date?t.expires.toUTCString():t.expires),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);let n="";for(const e in t)t[e]&&(n+="; "+e,!0!==t[e]&&(n+="="+String(t[e]).split(";")[0]));return document.cookie=e+"="+encode(o)+n}function getCookie(e,o){const t="undefined"!=typeof document?document.cookie:o,n=t?t.split("; "):[],i={};for(let o=0;o<n.length;o++){const t=n[o].split("="),r=t.slice(1).join("=");try{const o=decodeURIComponent(t[0]);if(o in i||(i[o]=decode(r)),e===o)break}catch(e){}}return e?i[e]:i}function removeCookie(e,o={path:"/"}){setCookie(e,"",Object.assign(Object.assign({},o),{expires:-1}))}function decode(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)}function encode(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";function setCookie(e,o,t={path:"/"}){if("undefined"==typeof document)return;"number"==typeof t.expires&&(t.expires=new Date(Date.now()+864e5*t.expires)),t.expires&&(t.expires=t.expires instanceof Date?t.expires.toUTCString():t.expires),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);let n="";for(const e in t)t[e]&&(n+="; "+e,!0!==t[e]&&(n+="="+String(t[e]).split(";")[0]));return document.cookie=e+"="+encode(o)+n}function getCookie(e,o){const t="undefined"!=typeof document?document.cookie:o,n=t?t.split("; "):[],i={};for(let o=0;o<n.length;o++){const t=n[o].split("="),r=t.slice(1).join("=");try{const o=decodeURIComponent(t[0]);if(o in i||(i[o]=decode(r)),e===o)break}catch(e){}}return e?i[e]:i}function removeCookie(e,o={path:"/"}){setCookie(e,"",Object.assign(Object.assign({},o),{expires:-1}))}function decode(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)}function encode(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.setCookie=setCookie,exports.getCookie=getCookie,exports.removeCookie=removeCookie;
|
|
2
2
|
//# sourceMappingURL=cookies.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function createParsedDocument(e){return{source:{absoluteRef:""},parsed:e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createParsedDocument=
|
|
1
|
+
"use strict";function createParsedDocument(e){return{source:{absoluteRef:""},parsed:e}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.createParsedDocument=createParsedDocument;
|
|
2
2
|
//# sourceMappingURL=createParsedDocument.js.map
|
package/lib/utils/debounce.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function debounce(e,
|
|
1
|
+
"use strict";function debounce(e,t,u){let n,o=0;return function(...c){o++,n?clearTimeout(n):u&&e(...c),n=setTimeout((function(){o>1&&e(...c),o=0,n=null}),t)}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.debounce=debounce;
|
|
2
2
|
//# sourceMappingURL=debounce.js.map
|
package/lib/utils/debug.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function debugTime(e){"production"!==process.env.NODE_ENV&&console.time(e)}function debugTimeEnd(e){"production"!==process.env.NODE_ENV&&console.timeEnd(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";function debugTime(e){"production"!==process.env.NODE_ENV&&console.time(e)}function debugTimeEnd(e){"production"!==process.env.NODE_ENV&&console.timeEnd(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.debugTime=debugTime,exports.debugTimeEnd=debugTimeEnd;
|
|
2
2
|
//# sourceMappingURL=debug.js.map
|