@redocly/openapi-docs 3.24.0-next.9 → 3.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{redocly-openapi-docs.min.AiChatProvider-DcsGB2gP.js → redocly-openapi-docs.min.AiChatProvider-j-VDfFJ9.js} +3 -3
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-wCZA4usG.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-BBRBmffc.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-jo7fqtSt.js → redocly-openapi-docs.min.AiPanel-DTzHqAiI.js} +116 -116
- package/dist/redocly-openapi-docs.min.FileWatcher-DDoyaS7A.js +1 -0
- package/dist/redocly-openapi-docs.min.Observable-D6wKbFwB.js +1 -0
- package/dist/redocly-openapi-docs.min.SemanticSearchService-DNFOPBZK.js +1 -0
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-B_f6WR8o.js → redocly-openapi-docs.min.SqliteDBStorage-Dy40Vq04.js} +1 -1
- package/dist/redocly-openapi-docs.min.TauriFileSystemAdapter-CpViFqJQ.js +1 -0
- package/dist/redocly-openapi-docs.min.TauriRootStorage-TCUrp2uB.js +1 -0
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js +1 -0
- package/dist/redocly-openapi-docs.min.core-BYyFOtMX.js +1 -0
- package/dist/redocly-openapi-docs.min.external-resolver-BkceRyB4.js +2 -0
- package/dist/redocly-openapi-docs.min.index-BCcol5vU.js +1 -0
- package/dist/redocly-openapi-docs.min.index-C6uU_v-b.js +1 -0
- package/dist/redocly-openapi-docs.min.index-CmXZfuiZ.js +7730 -0
- package/dist/redocly-openapi-docs.min.index-DVWw0ICA.js +1 -0
- package/dist/redocly-openapi-docs.min.index-YnvLQkG_.js +1 -0
- package/dist/redocly-openapi-docs.min.index-xl_tBaHD.js +1 -0
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-C-zlwxhp.js → redocly-openapi-docs.min.lint-2YpbCz3r.js} +69 -69
- package/dist/{redocly-openapi-docs.min.lint-graphql-qEh9cZHx.js → redocly-openapi-docs.min.lint-graphql-Bgfcu2tP.js} +1 -1
- package/dist/redocly-openapi-docs.min.periodic-revalidation-Dsp-n7ui.js +1 -0
- package/dist/redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js +1 -0
- package/dist/{redocly-openapi-docs.min.respect-run-hfNPYQ9x.js → redocly-openapi-docs.min.respect-run-Ct8taisL.js} +1 -1
- package/dist/redocly-openapi-docs.min.standalone-BPCdJgtH.js +11995 -0
- package/dist/redocly-openapi-docs.min.tauri-path-CmqBCxGb.js +1 -0
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-DgSsCKMW.js → redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js} +80 -80
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +1 -0
- package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +46 -0
- package/lib/components/Callbacks/CallbackOperation.js +1 -1
- package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +1 -0
- package/lib/components/Callbacks/__tests__/Callbacks.test.js +46 -0
- package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +1 -0
- package/lib/components/Content/__tests__/useAutoScroll.test.js +88 -0
- package/lib/components/Content/useAutoScroll.js +1 -1
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +1 -0
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +123 -0
- package/lib/components/ContentItem/useIsExpanded.js +1 -1
- package/lib/components/ContentItems/ContentItems.js +1 -1
- package/lib/components/ContentItems/VirtualList.js +1 -1
- package/lib/components/ContentItems/__tests__/Items.test.d.ts +1 -0
- package/lib/components/ContentItems/__tests__/Items.test.js +66 -0
- package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +1 -0
- package/lib/components/ContentItems/__tests__/VirtualList.test.js +135 -0
- package/lib/components/ContentItems/useScrollOnRender.js +1 -1
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +1 -0
- package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +63 -0
- package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +1 -0
- package/lib/components/Download/__tests__/DownloadSpecification.test.js +52 -0
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +1 -0
- package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +60 -0
- package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +1 -0
- package/lib/components/ExpandAllButton/__tests__/helpers.test.js +133 -0
- package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +1 -0
- package/lib/components/Language/__tests__/LanguageDropdown.test.js +23 -0
- package/lib/components/Markdown/__tests__/Markdown.test.d.ts +1 -0
- package/lib/components/Markdown/__tests__/Markdown.test.js +34 -0
- package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +1 -0
- package/lib/components/McpOverview/__tests__/McpOverview.test.js +66 -0
- package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpPrompt.test.js +57 -0
- package/lib/components/McpTool/__tests__/McpResource.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpResource.test.js +81 -0
- package/lib/components/McpTool/__tests__/McpTool.test.d.ts +1 -0
- package/lib/components/McpTool/__tests__/McpTool.test.js +82 -0
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +1 -0
- package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +79 -0
- package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +1 -0
- package/lib/components/OperationItem/__tests__/OperationItem.test.js +70 -0
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +16 -0
- package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +42 -0
- package/lib/components/Overview/__tests__/Overview.test.d.ts +1 -0
- package/lib/components/Overview/__tests__/Overview.test.js +59 -0
- package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/Example.test.js +36 -0
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +197 -0
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +1 -0
- package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +38 -0
- package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/Extensions.test.js +21 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +52 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +191 -0
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +365 -0
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +1 -0
- package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +23 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +1 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +16 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +1 -0
- package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +104 -0
- package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +1 -0
- package/lib/components/RenderHook/__tests__/RenderHook.test.js +15 -0
- package/lib/components/Replay/__tests__/utils.test.d.ts +1 -0
- package/lib/components/Replay/__tests__/utils.test.js +526 -0
- package/lib/components/Request/__tests__/RequestDetails.test.d.ts +1 -0
- package/lib/components/Request/__tests__/RequestDetails.test.js +98 -0
- package/lib/components/RequestSamples/__tests__/Example.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/Example.test.js +384 -0
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +226 -0
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +1 -0
- package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +64 -0
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +1 -0
- package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +29 -0
- package/lib/components/Responses/OperationResponseList.js +1 -1
- package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/OperationResponseList.test.js +89 -0
- package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/ResponseDetails.test.js +111 -0
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +1 -0
- package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +26 -0
- package/lib/components/Schema/Schema.js +1 -1
- package/lib/components/Schema/SubSchema.js +1 -1
- package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/ArraySchema.test.js +93 -0
- package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/ObjectSchema.test.js +115 -0
- package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/OneOfSchema.test.js +33 -0
- package/lib/components/Schema/__tests__/Schema.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/Schema.test.js +67 -0
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +1 -0
- package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +22 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +1 -1
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +1 -0
- package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +95 -0
- package/lib/components/Security/__tests__/Security.test.d.ts +1 -0
- package/lib/components/Security/__tests__/Security.test.js +38 -0
- package/lib/components/Security/__tests__/SecurityButton.test.d.ts +1 -0
- package/lib/components/Security/__tests__/SecurityButton.test.js +92 -0
- package/lib/components/Security/__tests__/SecurityModal.test.d.ts +1 -0
- package/lib/components/Security/__tests__/SecurityModal.test.js +172 -0
- package/lib/components/ServerList/__tests__/ServerList.test.d.ts +1 -0
- package/lib/components/ServerList/__tests__/ServerList.test.js +83 -0
- package/lib/components/SideMenu/hooks/useMenuItems.js +1 -1
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +1 -1
- package/lib/components/Tabs/__tests__/Tabs.test.d.ts +1 -0
- package/lib/components/Tabs/__tests__/Tabs.test.js +27 -0
- package/lib/components/TagItem/OperationsNavigation.js +1 -1
- package/lib/components/TagItem/TagItem.js +1 -1
- package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +1 -0
- package/lib/components/ViewNested/__tests__/ViewNested.test.js +42 -0
- package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +1 -0
- package/lib/components/__tests__/Samples/ExampleSwitch.test.js +45 -0
- package/lib/components/__tests__/Samples/use-example-key.test.d.ts +1 -0
- package/lib/components/__tests__/Samples/use-example-key.test.js +28 -0
- package/lib/components/__tests__/common/ClearButton.test.d.ts +1 -0
- package/lib/components/__tests__/common/ClearButton.test.js +18 -0
- package/lib/components/__tests__/common/Dropdown.test.d.ts +1 -0
- package/lib/components/__tests__/common/Dropdown.test.js +52 -0
- package/lib/components/__tests__/mocks/examples.d.ts +4 -0
- package/lib/components/__tests__/mocks/examples.js +115 -0
- package/lib/components/common/LinkToField.js +1 -1
- package/lib/components/common/__tests__/Dropdown.test.d.ts +1 -0
- package/lib/components/common/__tests__/Dropdown.test.js +129 -0
- package/lib/components/common/__tests__/LinkToField.test.d.ts +1 -0
- package/lib/components/common/__tests__/LinkToField.test.js +39 -0
- package/lib/components/common/linkify.js +1 -1
- package/lib/hooks/useRouter.js +1 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +1 -1
- package/lib/jotai/__tests__/app.test.d.ts +1 -0
- package/lib/jotai/__tests__/app.test.js +53 -0
- package/lib/models/__tests__/Callback.test.d.ts +1 -0
- package/lib/models/__tests__/Callback.test.js +15 -0
- package/lib/models/__tests__/FieldModel.test.d.ts +1 -0
- package/lib/models/__tests__/FieldModel.test.js +117 -0
- package/lib/models/__tests__/MediaContent.test.d.ts +1 -0
- package/lib/models/__tests__/MediaContent.test.js +105 -0
- package/lib/models/__tests__/Operation.test.d.ts +1 -0
- package/lib/models/__tests__/Operation.test.js +459 -0
- package/lib/models/__tests__/Response.test.d.ts +1 -0
- package/lib/models/__tests__/Response.test.js +221 -0
- package/lib/models/__tests__/Schema.circular.test.d.ts +1 -0
- package/lib/models/__tests__/Schema.circular.test.js +694 -0
- package/lib/models/__tests__/Schema.test.d.ts +1 -0
- package/lib/models/__tests__/Schema.test.js +1395 -0
- package/lib/models/__tests__/example.test.d.ts +1 -0
- package/lib/models/__tests__/example.test.js +90 -0
- package/lib/models/__tests__/group.test.d.ts +1 -0
- package/lib/models/__tests__/group.test.js +52 -0
- package/lib/models/__tests__/helpers.d.ts +5 -0
- package/lib/models/__tests__/helpers.js +62 -0
- package/lib/models/__tests__/request.test.d.ts +1 -0
- package/lib/models/__tests__/request.test.js +119 -0
- package/lib/services/__tests__/OpenAPIParser.test.d.ts +1 -0
- package/lib/services/__tests__/OpenAPIParser.test.js +80 -0
- package/lib/services/__tests__/check.test.d.ts +1 -0
- package/lib/services/__tests__/check.test.js +22 -0
- package/lib/services/__tests__/utils.test.d.ts +1 -0
- package/lib/services/__tests__/utils.test.js +42 -0
- package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/apply-environments.test.js +64 -0
- package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/build-code-samples.test.js +70 -0
- package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/convertSampleToString.test.js +116 -0
- package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-data-value.test.js +277 -0
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +258 -0
- package/lib/services/code-samples/__tests__/generator-value.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/generator-value.test.js +273 -0
- package/lib/services/code-samples/__tests__/generator.test.d.ts +249 -0
- package/lib/services/code-samples/__tests__/generator.test.js +1201 -0
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +1 -0
- package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +31 -0
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +222 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +129 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +49 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +130 -0
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +191 -0
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +172 -0
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +85 -0
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +85 -0
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +126 -0
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +105 -0
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +126 -0
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +129 -0
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +1 -0
- package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +129 -0
- package/lib/services/config-options/__tests__/helpers.test.d.ts +1 -0
- package/lib/services/config-options/__tests__/helpers.test.js +234 -0
- package/lib/services/history/__tests__/helpers.test.d.ts +1 -0
- package/lib/services/history/__tests__/helpers.test.js +19 -0
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +1 -0
- package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +109 -0
- package/lib/services/menu/__tests__/builder.test.d.ts +1 -0
- package/lib/services/menu/__tests__/builder.test.js +307 -0
- package/lib/services/menu/__tests__/operation.test.d.ts +1 -0
- package/lib/services/menu/__tests__/operation.test.js +240 -0
- package/lib/services/menu/__tests__/tags.test.d.ts +1 -0
- package/lib/services/menu/__tests__/tags.test.js +71 -0
- package/lib/telemetry/RedocTelemetry.js +31 -1
- package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +1 -0
- package/lib/telemetry/__tests__/RedocTelemetry.test.js +107 -0
- package/lib/testProviders.d.ts +6 -0
- package/lib/testProviders.js +14 -0
- package/lib/utils/__tests__/areArraysEqual.test.d.ts +1 -0
- package/lib/utils/__tests__/areArraysEqual.test.js +33 -0
- package/lib/utils/__tests__/argValuesHelpers.d.ts +1 -0
- package/lib/utils/__tests__/argValuesHelpers.js +56 -0
- package/lib/utils/__tests__/calculateMaxLength.test.d.ts +1 -0
- package/lib/utils/__tests__/calculateMaxLength.test.js +119 -0
- package/lib/utils/__tests__/configure-helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/configure-helpers.test.js +356 -0
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +1 -0
- package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +392 -0
- package/lib/utils/__tests__/debounce.test.d.ts +1 -0
- package/lib/utils/__tests__/debounce.test.js +54 -0
- package/lib/utils/__tests__/debug.test.d.ts +1 -0
- package/lib/utils/__tests__/debug.test.js +23 -0
- package/lib/utils/__tests__/dom.test.d.ts +1 -0
- package/lib/utils/__tests__/dom.test.js +108 -0
- package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +1 -0
- package/lib/utils/__tests__/getBreadcrumbs.test.js +98 -0
- package/lib/utils/__tests__/hasNestedFields.test.d.ts +1 -0
- package/lib/utils/__tests__/hasNestedFields.test.js +147 -0
- package/lib/utils/__tests__/helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/helpers.test.js +174 -0
- package/lib/utils/__tests__/isMobile.test.d.ts +1 -0
- package/lib/utils/__tests__/isMobile.test.js +28 -0
- package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +1 -0
- package/lib/utils/__tests__/loadAndBundleSpec.test.js +22 -0
- package/lib/utils/__tests__/local-storage.test.d.ts +1 -0
- package/lib/utils/__tests__/local-storage.test.js +48 -0
- package/lib/utils/__tests__/object.test.d.ts +1 -0
- package/lib/utils/__tests__/object.test.js +45 -0
- package/lib/utils/__tests__/openapi.test.d.ts +1 -0
- package/lib/utils/__tests__/openapi.test.js +1378 -0
- package/lib/utils/__tests__/path.test.d.ts +1 -0
- package/lib/utils/__tests__/path.test.js +16 -0
- package/lib/utils/__tests__/queryString.test.d.ts +1 -0
- package/lib/utils/__tests__/queryString.test.js +60 -0
- package/lib/utils/__tests__/replaceVariables.test.d.ts +1 -0
- package/lib/utils/__tests__/replaceVariables.test.js +46 -0
- package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +1 -0
- package/lib/utils/__tests__/simplifyAstStructure.test.js +26 -0
- package/lib/utils/__tests__/sort.test.d.ts +1 -0
- package/lib/utils/__tests__/sort.test.js +16 -0
- package/lib/utils/__tests__/string.test.d.ts +1 -0
- package/lib/utils/__tests__/string.test.js +16 -0
- package/lib/utils/__tests__/theme-helpers.test.d.ts +1 -0
- package/lib/utils/__tests__/theme-helpers.test.js +24 -0
- package/lib/utils/__tests__/url.test.d.ts +1 -0
- package/lib/utils/__tests__/url.test.js +134 -0
- package/lib/utils/path.d.ts +1 -1
- package/package.json +12 -12
- package/dist/redocly-openapi-docs.min.ai-chat-mappers-MY79QAeW.js +0 -1
- package/dist/redocly-openapi-docs.min.external-resolver-3KMJv7SC.js +0 -2
- package/dist/redocly-openapi-docs.min.index-BYVMr_la.js +0 -1
- package/dist/redocly-openapi-docs.min.index-CsqzTi3Z.js +0 -7586
- package/dist/redocly-openapi-docs.min.index-D8F7x0S6.js +0 -1
- package/dist/redocly-openapi-docs.min.index-qqKTpI_q.js +0 -1
- package/dist/redocly-openapi-docs.min.standalone-Ci6886Cr.js +0 -12114
- package/dist/redocly-openapi-docs.min.tauri-path-Bs1-AQjc.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getExampleValueByMimeType } from '../get-example-value-by-mime-type.js';
|
|
2
|
+
describe('getExampleValueByMimeType', () => {
|
|
3
|
+
it('returns an empty string for undefined values', () => {
|
|
4
|
+
expect(getExampleValueByMimeType(undefined, 'application/json')).toBe('');
|
|
5
|
+
});
|
|
6
|
+
it('pretty-prints objects for json-like media types', () => {
|
|
7
|
+
expect(getExampleValueByMimeType({ a: 1, b: 'two' }, 'application/json')).toBe('{\n "a": 1,\n "b": "two"\n}');
|
|
8
|
+
});
|
|
9
|
+
it('parses and pretty-prints JSON provided as a string', () => {
|
|
10
|
+
expect(getExampleValueByMimeType('{"a":1}', 'application/json')).toBe('{\n "a": 1\n}');
|
|
11
|
+
});
|
|
12
|
+
it('falls back to the raw string when a json-like string is not valid JSON', () => {
|
|
13
|
+
expect(getExampleValueByMimeType('not json', 'application/json')).toBe('not json');
|
|
14
|
+
});
|
|
15
|
+
it('url-encodes objects for application/x-www-form-urlencoded', () => {
|
|
16
|
+
const result = getExampleValueByMimeType({ a: 'x', b: 'y' }, 'application/x-www-form-urlencoded');
|
|
17
|
+
expect(result).toContain('a=x');
|
|
18
|
+
expect(result).toContain('b=y');
|
|
19
|
+
});
|
|
20
|
+
it('builds XML for xml-like media types', () => {
|
|
21
|
+
expect(getExampleValueByMimeType({ name: 'John' }, 'application/xml')).toContain('<name>John</name>');
|
|
22
|
+
});
|
|
23
|
+
it('stringifies objects as JSON for non-json, non-xml, non-form media types', () => {
|
|
24
|
+
expect(getExampleValueByMimeType({ a: 1 }, 'text/plain')).toBe('{\n "a": 1\n}');
|
|
25
|
+
});
|
|
26
|
+
it('stringifies primitive values', () => {
|
|
27
|
+
expect(getExampleValueByMimeType('hello', 'text/plain')).toBe('hello');
|
|
28
|
+
expect(getExampleValueByMimeType(42, 'text/plain')).toBe('42');
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=get-example-value-by-mime-type.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { HTTPSnippet } from '../index.js';
|
|
2
|
+
describe('Device Authorization Flow', () => {
|
|
3
|
+
// Base HAR request for device authorization
|
|
4
|
+
const baseDeviceAuthHAR = {
|
|
5
|
+
method: 'POST',
|
|
6
|
+
url: 'https://petstore.swagger.io/v2/pet',
|
|
7
|
+
httpVersion: 'HTTP/1.1',
|
|
8
|
+
headers: [
|
|
9
|
+
{ name: 'Content-Type', value: 'application/json' },
|
|
10
|
+
{ name: 'Authorization', value: 'Bearer <YOUR_TOKEN_HERE>' },
|
|
11
|
+
],
|
|
12
|
+
queryString: [],
|
|
13
|
+
postData: {
|
|
14
|
+
mimeType: 'application/json',
|
|
15
|
+
text: JSON.stringify({ name: 'Fluffy', status: 'available' }),
|
|
16
|
+
params: [],
|
|
17
|
+
},
|
|
18
|
+
cookies: [],
|
|
19
|
+
headersSize: -1,
|
|
20
|
+
bodySize: -1,
|
|
21
|
+
securityOAuth2ExtraCalls: [
|
|
22
|
+
{
|
|
23
|
+
method: 'POST',
|
|
24
|
+
url: 'http://petstore.swagger.io/api/oauth/device',
|
|
25
|
+
httpVersion: 'HTTP/1.1',
|
|
26
|
+
headers: [
|
|
27
|
+
{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' },
|
|
28
|
+
{ name: 'Accept', value: 'application/json' },
|
|
29
|
+
],
|
|
30
|
+
queryString: [],
|
|
31
|
+
postData: {
|
|
32
|
+
mimeType: 'application/x-www-form-urlencoded',
|
|
33
|
+
text: '',
|
|
34
|
+
params: [
|
|
35
|
+
{ name: 'client_id', value: 'test-client-id' },
|
|
36
|
+
{ name: 'scope', value: 'write:pets read:pets' },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
cookies: [],
|
|
40
|
+
headersSize: -1,
|
|
41
|
+
bodySize: -1,
|
|
42
|
+
flowType: 'deviceAuthorization',
|
|
43
|
+
tokenUrl: 'http://petstore.swagger.io/api/oauth/token',
|
|
44
|
+
clientId: 'test-client-id',
|
|
45
|
+
securityOAuth2ExtraCalls: [],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
describe('Node.js', () => {
|
|
50
|
+
it('should generate device authorization flow code', () => {
|
|
51
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
52
|
+
const code = snippet.convert('node', 'fetch', {});
|
|
53
|
+
expect(code).toContain('device_code');
|
|
54
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
55
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/token');
|
|
56
|
+
expect(code).toContain('while (Date.now() < deadline)');
|
|
57
|
+
expect(code).toContain('urn:ietf:params:oauth:grant-type:device_code');
|
|
58
|
+
expect(code).toContain('accessToken');
|
|
59
|
+
expect(code).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('JavaScript', () => {
|
|
63
|
+
it('should generate device authorization flow code', () => {
|
|
64
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
65
|
+
const code = snippet.convert('javascript', 'fetch', {});
|
|
66
|
+
expect(code).toContain('device_code');
|
|
67
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
68
|
+
expect(code).toContain('while (Date.now() < deadline)');
|
|
69
|
+
expect(code).toContain('accessToken');
|
|
70
|
+
expect(code).toMatchSnapshot();
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('Python', () => {
|
|
74
|
+
it('should generate device authorization flow code', () => {
|
|
75
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
76
|
+
const code = snippet.convert('python', 'requests', {});
|
|
77
|
+
expect(code).toContain('time.time()');
|
|
78
|
+
expect(code).toContain('device_code');
|
|
79
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
80
|
+
expect(code).toContain('while time.time() < deadline:');
|
|
81
|
+
expect(code).toContain('access_token');
|
|
82
|
+
expect(code).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe('PHP', () => {
|
|
86
|
+
it('should generate device authorization flow code', () => {
|
|
87
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
88
|
+
const code = snippet.convert('php', 'curl', {});
|
|
89
|
+
expect(code).toContain('device_code');
|
|
90
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
91
|
+
expect(code).toContain('while (time() < $deadline)');
|
|
92
|
+
expect(code).toContain('usleep');
|
|
93
|
+
expect(code).toContain('$accessToken');
|
|
94
|
+
expect(code).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('Go', () => {
|
|
98
|
+
it('should generate device authorization flow code', () => {
|
|
99
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
100
|
+
const code = snippet.convert('go', 'native', {});
|
|
101
|
+
expect(code).toContain('"time"');
|
|
102
|
+
expect(code).toContain('Device_code');
|
|
103
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
104
|
+
expect(code).toContain('for time.Now().Unix() < deadline');
|
|
105
|
+
expect(code).toContain('time.Sleep');
|
|
106
|
+
expect(code).toContain('accessToken');
|
|
107
|
+
expect(code).toMatchSnapshot();
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
describe('C#', () => {
|
|
111
|
+
it('should generate device authorization flow code', () => {
|
|
112
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
113
|
+
const code = snippet.convert('csharp', 'httpclient', {});
|
|
114
|
+
expect(code).toContain('using System.Text.Json');
|
|
115
|
+
expect(code).toContain('deviceCode');
|
|
116
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
117
|
+
expect(code).toContain('while (DateTime.UtcNow < deadline)');
|
|
118
|
+
expect(code).toContain('await Task.Delay');
|
|
119
|
+
expect(code).toContain('accessToken');
|
|
120
|
+
expect(code).toMatchSnapshot();
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('C# + Newtonsoft', () => {
|
|
124
|
+
it('should generate device authorization flow code', () => {
|
|
125
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
126
|
+
const code = snippet.convert('csharpNewtonsoft', 'httpclient', {});
|
|
127
|
+
expect(code).toContain('using Newtonsoft.Json.Linq');
|
|
128
|
+
expect(code).toContain('deviceCode');
|
|
129
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
130
|
+
expect(code).toContain('while (DateTime.UtcNow < deadline)');
|
|
131
|
+
expect(code).toContain('JObject');
|
|
132
|
+
expect(code).toContain('accessToken');
|
|
133
|
+
expect(code).toMatchSnapshot();
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
describe('Java', () => {
|
|
137
|
+
it('should generate device authorization flow code', () => {
|
|
138
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
139
|
+
const code = snippet.convert('java', 'httpclient', {});
|
|
140
|
+
expect(code).toContain('JSONObject');
|
|
141
|
+
expect(code).toContain('deviceCode');
|
|
142
|
+
expect(code).toContain('/api/oauth/device');
|
|
143
|
+
expect(code).toContain('/api/oauth/token');
|
|
144
|
+
expect(code).toContain('while (System.currentTimeMillis() < deadline)');
|
|
145
|
+
expect(code).toContain('Thread.sleep');
|
|
146
|
+
expect(code).toContain('accessToken');
|
|
147
|
+
expect(code).toMatchSnapshot();
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
describe('Java8+Apache', () => {
|
|
151
|
+
it('should generate device authorization flow code', () => {
|
|
152
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
153
|
+
const code = snippet.convert('java8', 'apachehttp', {});
|
|
154
|
+
expect(code).toContain('JSONObject');
|
|
155
|
+
expect(code).toContain('deviceCode');
|
|
156
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
157
|
+
expect(code).toContain('while (System.currentTimeMillis() < deadline)');
|
|
158
|
+
expect(code).toContain('Thread.sleep');
|
|
159
|
+
expect(code).toContain('accessToken');
|
|
160
|
+
expect(code).toMatchSnapshot();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
describe('R', () => {
|
|
164
|
+
it('should generate device authorization flow code', () => {
|
|
165
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
166
|
+
const code = snippet.convert('r', 'httr', {});
|
|
167
|
+
expect(code).toContain('library(httr)');
|
|
168
|
+
expect(code).toContain('device_code');
|
|
169
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
170
|
+
expect(code).toContain('while (as.numeric(Sys.time()) < deadline)');
|
|
171
|
+
expect(code).toContain('Sys.sleep');
|
|
172
|
+
expect(code).toContain('access_token');
|
|
173
|
+
expect(code).toMatchSnapshot();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe('Ruby', () => {
|
|
177
|
+
it('should generate device authorization flow code', () => {
|
|
178
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
179
|
+
const code = snippet.convert('ruby', 'native', {});
|
|
180
|
+
expect(code).toContain("require 'json'");
|
|
181
|
+
expect(code).toContain('device_code');
|
|
182
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
183
|
+
expect(code).toContain('while Time.now.to_i < deadline');
|
|
184
|
+
expect(code).toContain('sleep');
|
|
185
|
+
expect(code).toContain('access_token');
|
|
186
|
+
expect(code).toMatchSnapshot();
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('curl', () => {
|
|
190
|
+
it('should generate device authorization flow script', () => {
|
|
191
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
192
|
+
const code = snippet.convert('shell', 'curl', {});
|
|
193
|
+
expect(code).toContain('DEVICE_CODE=');
|
|
194
|
+
expect(code).toContain('http://petstore.swagger.io/api/oauth/device');
|
|
195
|
+
expect(code).toContain('while [ $(date +%s) -lt $DEADLINE ]');
|
|
196
|
+
expect(code).toContain('jq -r');
|
|
197
|
+
expect(code).toContain('ACCESS_TOKEN');
|
|
198
|
+
expect(code).toMatchSnapshot();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
describe('Error handling', () => {
|
|
202
|
+
it('should handle slow_down error', () => {
|
|
203
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
204
|
+
const code = snippet.convert('node', 'fetch', {});
|
|
205
|
+
expect(code).toContain('slow_down');
|
|
206
|
+
expect(code).toContain('intervalMs');
|
|
207
|
+
});
|
|
208
|
+
it('should handle access_denied and expired_token errors', () => {
|
|
209
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
210
|
+
const pythonCode = snippet.convert('python', 'requests', {});
|
|
211
|
+
expect(pythonCode).toContain('access_denied');
|
|
212
|
+
expect(pythonCode).toContain('expired_token');
|
|
213
|
+
expect(pythonCode).toContain('Device flow failed');
|
|
214
|
+
});
|
|
215
|
+
it('should handle timeout', () => {
|
|
216
|
+
const snippet = new HTTPSnippet(baseDeviceAuthHAR);
|
|
217
|
+
const goCode = snippet.convert('go', 'native', {});
|
|
218
|
+
expect(goCode).toContain('Timed out waiting for authorization');
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
//# sourceMappingURL=device-authorization.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { buildUrlExpression, parseUrlIntoOperands, printUrlVariablesDeclarations, } from '../code-helpers.js';
|
|
2
|
+
import { Lang } from '../constants.js';
|
|
3
|
+
import { CodeBuilder } from '../code-builder.js';
|
|
4
|
+
import { buildUrlExpressionData, commonVariablesInput, printUrlVariablesDeclarationsOutput, } from '../mocks/code-helpers-mock.js';
|
|
5
|
+
describe('parseUrlIntoOperands', () => {
|
|
6
|
+
it('should correctly parse string without path parameters', () => {
|
|
7
|
+
expect(parseUrlIntoOperands('/v1/test', {})).toEqual([{ type: 'string', value: '/v1/test' }]);
|
|
8
|
+
});
|
|
9
|
+
it('should correctly parse string with single known parameter in the end', () => {
|
|
10
|
+
expect(parseUrlIntoOperands('/v1/{test}', { test: '1' })).toEqual([
|
|
11
|
+
{ type: 'string', value: '/v1/' },
|
|
12
|
+
{ type: 'variable', name: 'test' },
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
it('should correctly parse string with single known parameter in the middle', () => {
|
|
16
|
+
expect(parseUrlIntoOperands('/v1/{test}/test', { test: '1' })).toEqual([
|
|
17
|
+
{ type: 'string', value: '/v1/' },
|
|
18
|
+
{ type: 'variable', name: 'test' },
|
|
19
|
+
{ type: 'string', value: '/test' },
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
it('should correctly parse string with single known parameter and trailing slash', () => {
|
|
23
|
+
expect(parseUrlIntoOperands('/v1/{test}/', { test: '1' })).toEqual([
|
|
24
|
+
{ type: 'string', value: '/v1/' },
|
|
25
|
+
{ type: 'variable', name: 'test' },
|
|
26
|
+
{ type: 'string', value: '/' },
|
|
27
|
+
]);
|
|
28
|
+
});
|
|
29
|
+
it('should correctly parse string with multiple known parameters', () => {
|
|
30
|
+
expect(parseUrlIntoOperands('/v1/{test2}/{test}', { test: '1', test2: '1' })).toEqual([
|
|
31
|
+
{ type: 'string', value: '/v1/' },
|
|
32
|
+
{ type: 'variable', name: 'test2' },
|
|
33
|
+
{ type: 'string', value: '/' },
|
|
34
|
+
{ type: 'variable', name: 'test' },
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('printUrlVariablesDeclarations', () => {
|
|
39
|
+
it('should print empty string on empty pathParameters/serverVariables', () => {
|
|
40
|
+
const variablesPrefix = 'variablesPrefix';
|
|
41
|
+
const snippetRequest = { pathParameters: {}, serverVariables: {} };
|
|
42
|
+
for (const key in Lang) {
|
|
43
|
+
const code = new CodeBuilder({
|
|
44
|
+
indentation: '',
|
|
45
|
+
variablesPrefix,
|
|
46
|
+
lang: Lang[key],
|
|
47
|
+
lineJoin: '\n',
|
|
48
|
+
});
|
|
49
|
+
printUrlVariablesDeclarations(snippetRequest, code);
|
|
50
|
+
expect(code.join()).toEqual('');
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
it('should declare variable presented in pathParameters/serverVariables for given lang', () => {
|
|
54
|
+
const variablesPrefix = 'variablesPrefix';
|
|
55
|
+
for (const key in Lang) {
|
|
56
|
+
const lang = Lang[key];
|
|
57
|
+
const output = printUrlVariablesDeclarationsOutput[lang];
|
|
58
|
+
const code = new CodeBuilder({
|
|
59
|
+
indentation: '',
|
|
60
|
+
variablesPrefix,
|
|
61
|
+
lang,
|
|
62
|
+
lineJoin: '\n',
|
|
63
|
+
});
|
|
64
|
+
printUrlVariablesDeclarations(commonVariablesInput, code);
|
|
65
|
+
try {
|
|
66
|
+
expect(code.join()).toEqual(output);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
throw new Error(`${lang} is broken ${e}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('buildUrlExpression', () => {
|
|
75
|
+
it('should not change url if variables are empty', () => {
|
|
76
|
+
const variablesPrefix = 'variablesPrefix';
|
|
77
|
+
const url = 'http://acme.com';
|
|
78
|
+
const input = {
|
|
79
|
+
pathParameters: {},
|
|
80
|
+
serverVariables: {},
|
|
81
|
+
url,
|
|
82
|
+
fullUrl: url,
|
|
83
|
+
pathname: url,
|
|
84
|
+
};
|
|
85
|
+
for (const key in Lang) {
|
|
86
|
+
const lang = Lang[key];
|
|
87
|
+
const code = new CodeBuilder({
|
|
88
|
+
indentation: '',
|
|
89
|
+
variablesPrefix,
|
|
90
|
+
lang,
|
|
91
|
+
lineJoin: '\n',
|
|
92
|
+
});
|
|
93
|
+
const res = buildUrlExpression(input, code).replace(/["']/g, '');
|
|
94
|
+
try {
|
|
95
|
+
expect(res).toEqual('http://acme.com');
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
throw new Error(`${lang} is broken ${e}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
it('should work with given input', () => {
|
|
103
|
+
const variablesPrefix = 'variablesPrefix';
|
|
104
|
+
const url = 'http://acme.com/{pathParam1}/{pathParam2}/{pathParam3}/{pathParam4}/{serverVariable1}/{serverVariable2}';
|
|
105
|
+
const input = {
|
|
106
|
+
...commonVariablesInput,
|
|
107
|
+
url,
|
|
108
|
+
fullUrl: url,
|
|
109
|
+
pathname: url,
|
|
110
|
+
};
|
|
111
|
+
for (const key in Lang) {
|
|
112
|
+
const lang = Lang[key];
|
|
113
|
+
const code = new CodeBuilder({
|
|
114
|
+
indentation: '',
|
|
115
|
+
variablesPrefix,
|
|
116
|
+
lang,
|
|
117
|
+
lineJoin: '\n',
|
|
118
|
+
});
|
|
119
|
+
const res = buildUrlExpression(input, code);
|
|
120
|
+
try {
|
|
121
|
+
expect(res).toEqual(buildUrlExpressionData[lang]);
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
throw new Error(`${lang} is broken ${e}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=code-helpers.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import StringUtility from '../string-utility.js';
|
|
2
|
+
describe('StringUtility', () => {
|
|
3
|
+
const testStrings = [
|
|
4
|
+
'lives-Down_by-the.River',
|
|
5
|
+
'Lives`Down,by~the RIVER',
|
|
6
|
+
'LivesDownBY the RIVER',
|
|
7
|
+
];
|
|
8
|
+
describe('toCamelCase', () => {
|
|
9
|
+
it('returns camelCase string', () => {
|
|
10
|
+
const expectedResult = 'livesDownByTheRiver';
|
|
11
|
+
testStrings.forEach((str) => {
|
|
12
|
+
expect(StringUtility.toCamelCase(str)).toEqual(expectedResult);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('toTitleCase', () => {
|
|
17
|
+
it('returns Title Case string', () => {
|
|
18
|
+
const expectedResult = 'Lives Down By The River';
|
|
19
|
+
testStrings.forEach((str) => {
|
|
20
|
+
expect(StringUtility.toTitleCase(str)).toEqual(expectedResult);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe('toPascalCase', () => {
|
|
25
|
+
it('returns PascalCase string', () => {
|
|
26
|
+
const expectedResult = 'LivesDownByTheRiver';
|
|
27
|
+
testStrings.forEach((str) => {
|
|
28
|
+
expect(StringUtility.toPascalCase(str)).toEqual(expectedResult);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('toLowerCase', () => {
|
|
33
|
+
it('returns lowercase string', () => {
|
|
34
|
+
const expectedResult = 'livesdownbytheriver';
|
|
35
|
+
testStrings.forEach((str) => {
|
|
36
|
+
expect(StringUtility.toLowerCase(str)).toEqual(expectedResult);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('toSnakeCase', () => {
|
|
41
|
+
it('returns snake_case string', () => {
|
|
42
|
+
const expectedResult = 'lives_down_by_the_river';
|
|
43
|
+
testStrings.forEach((str) => {
|
|
44
|
+
expect(StringUtility.toSnakeCase(str)).toEqual(expectedResult);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=string-utility.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HTTPSnippet } from '../../../index.js';
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
export { HTTPSnippet } from '../../../index.js'; // we need to reexport it before to prevent circular ref issue
|
|
2
|
+
import httpclient from '../httpclient.js';
|
|
3
|
+
import { originalOptions, serverVariablesOptions, source } from '../../__mocks__/mock.js';
|
|
4
|
+
describe('#code-samples C#', () => {
|
|
5
|
+
describe('handler', () => {
|
|
6
|
+
it('returns code API PUT /pet', () => {
|
|
7
|
+
const result = httpclient(source['PUT http://petstore.swagger.io/v2/pet'], originalOptions, {
|
|
8
|
+
target: 'csharp',
|
|
9
|
+
client: 'httpclient',
|
|
10
|
+
});
|
|
11
|
+
expect(result).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
it('returns code with path parameters reserved (data) and not (petId) /pet/{petId}/uploadImage/{data}', () => {
|
|
14
|
+
const result = httpclient(source['POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage/{data}'], originalOptions, { target: 'csharp', client: 'httpclient' });
|
|
15
|
+
expect(result).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
it('returns code with one path parameter inside url /pet/{petId}/uploadImage', () => {
|
|
18
|
+
const result = httpclient(source['POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage'], originalOptions, { target: 'csharp', client: 'httpclient' });
|
|
19
|
+
expect(result).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
it('returns code with path parameter and query /pet/findByStatus/{id}?status=...', () => {
|
|
22
|
+
const result = httpclient(source['GET http://petstore.swagger.io/v2/pet/findByStatus/{id}'], originalOptions, { target: 'csharp', client: 'httpclient' });
|
|
23
|
+
expect(result).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
it('should generate code with server variables', () => {
|
|
26
|
+
const result = httpclient(source['POST https://{customerId}.saas-app.com:{port}/v2'], serverVariablesOptions, {
|
|
27
|
+
target: 'csharp',
|
|
28
|
+
client: 'httpclient',
|
|
29
|
+
});
|
|
30
|
+
expect(result).toMatchSnapshot();
|
|
31
|
+
});
|
|
32
|
+
it('should generate code with basic auth', () => {
|
|
33
|
+
const result = httpclient(source['POST http://petstore.swagger.io/login'], serverVariablesOptions, {
|
|
34
|
+
target: 'csharp',
|
|
35
|
+
client: 'httpclient',
|
|
36
|
+
});
|
|
37
|
+
expect(result).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
it('should handle URL_ENCODED with text but no params (serializedValue case)', () => {
|
|
40
|
+
const sourceWithUrlEncodedText = {
|
|
41
|
+
method: 'post',
|
|
42
|
+
url: 'http://petstore.swagger.io/v2/pet',
|
|
43
|
+
httpVersion: 'HTTP/1.1',
|
|
44
|
+
cookies: [],
|
|
45
|
+
headers: [{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' }],
|
|
46
|
+
queryString: [],
|
|
47
|
+
postData: {
|
|
48
|
+
mimeType: 'application/x-www-form-urlencoded',
|
|
49
|
+
text: 'name=Museum+Visitor&value=premium&count=5',
|
|
50
|
+
params: [],
|
|
51
|
+
},
|
|
52
|
+
headersSize: 0,
|
|
53
|
+
bodySize: 0,
|
|
54
|
+
securityOAuth2ExtraCalls: [],
|
|
55
|
+
pathParameters: {},
|
|
56
|
+
serverVariables: {},
|
|
57
|
+
queryObj: {},
|
|
58
|
+
headersObj: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
59
|
+
cookiesObj: {},
|
|
60
|
+
allHeaders: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
61
|
+
uriObj: {
|
|
62
|
+
protocol: 'http:',
|
|
63
|
+
slashes: true,
|
|
64
|
+
auth: null,
|
|
65
|
+
host: 'petstore.swagger.io',
|
|
66
|
+
port: null,
|
|
67
|
+
hostname: 'petstore.swagger.io',
|
|
68
|
+
hash: null,
|
|
69
|
+
search: '',
|
|
70
|
+
query: {},
|
|
71
|
+
pathname: '/v2/pet',
|
|
72
|
+
path: '/v2/pet',
|
|
73
|
+
href: 'http://petstore.swagger.io/v2/pet',
|
|
74
|
+
},
|
|
75
|
+
fullUrl: 'http://petstore.swagger.io/v2/pet',
|
|
76
|
+
};
|
|
77
|
+
const result = httpclient(sourceWithUrlEncodedText, originalOptions, {
|
|
78
|
+
target: 'csharp',
|
|
79
|
+
client: 'httpclient',
|
|
80
|
+
});
|
|
81
|
+
expect(result).toMatchSnapshot();
|
|
82
|
+
});
|
|
83
|
+
it('should handle MULTIPART with text but no params (serializedValue case)', () => {
|
|
84
|
+
const sourceWithMultipartText = {
|
|
85
|
+
method: 'post',
|
|
86
|
+
url: 'http://petstore.swagger.io/v2/pet',
|
|
87
|
+
httpVersion: 'HTTP/1.1',
|
|
88
|
+
cookies: [],
|
|
89
|
+
headers: [{ name: 'Content-Type', value: 'multipart/form-data' }],
|
|
90
|
+
queryString: [],
|
|
91
|
+
postData: {
|
|
92
|
+
mimeType: 'multipart/form-data',
|
|
93
|
+
text: '--boundary123\r\nContent-Disposition: form-data; name="field1"\r\n\r\nvalue1\r\n--boundary123\r\nContent-Disposition: form-data; name="field2"\r\n\r\nvalue2\r\n--boundary123--',
|
|
94
|
+
params: [],
|
|
95
|
+
},
|
|
96
|
+
headersSize: 0,
|
|
97
|
+
bodySize: 0,
|
|
98
|
+
securityOAuth2ExtraCalls: [],
|
|
99
|
+
pathParameters: {},
|
|
100
|
+
serverVariables: {},
|
|
101
|
+
queryObj: {},
|
|
102
|
+
headersObj: { 'Content-Type': 'multipart/form-data' },
|
|
103
|
+
cookiesObj: {},
|
|
104
|
+
allHeaders: { 'Content-Type': 'multipart/form-data' },
|
|
105
|
+
uriObj: {
|
|
106
|
+
protocol: 'http:',
|
|
107
|
+
slashes: true,
|
|
108
|
+
auth: null,
|
|
109
|
+
host: 'petstore.swagger.io',
|
|
110
|
+
port: null,
|
|
111
|
+
hostname: 'petstore.swagger.io',
|
|
112
|
+
hash: null,
|
|
113
|
+
search: '',
|
|
114
|
+
query: {},
|
|
115
|
+
pathname: '/v2/pet',
|
|
116
|
+
path: '/v2/pet',
|
|
117
|
+
href: 'http://petstore.swagger.io/v2/pet',
|
|
118
|
+
},
|
|
119
|
+
fullUrl: 'http://petstore.swagger.io/v2/pet',
|
|
120
|
+
};
|
|
121
|
+
const result = httpclient(sourceWithMultipartText, originalOptions, {
|
|
122
|
+
target: 'csharp',
|
|
123
|
+
client: 'httpclient',
|
|
124
|
+
});
|
|
125
|
+
expect(result).toMatchSnapshot();
|
|
126
|
+
});
|
|
127
|
+
it('should handle OCTET_STREAM with text (binary data case)', () => {
|
|
128
|
+
const sourceWithOctetStream = {
|
|
129
|
+
method: 'post',
|
|
130
|
+
url: 'http://petstore.swagger.io/v2/upload',
|
|
131
|
+
httpVersion: 'HTTP/1.1',
|
|
132
|
+
cookies: [],
|
|
133
|
+
headers: [{ name: 'Content-Type', value: 'application/octet-stream' }],
|
|
134
|
+
queryString: [],
|
|
135
|
+
postData: {
|
|
136
|
+
mimeType: 'application/octet-stream',
|
|
137
|
+
text: 'SGVsbG8gV29ybGQ=',
|
|
138
|
+
},
|
|
139
|
+
headersSize: 0,
|
|
140
|
+
bodySize: 0,
|
|
141
|
+
securityOAuth2ExtraCalls: [],
|
|
142
|
+
pathParameters: {},
|
|
143
|
+
serverVariables: {},
|
|
144
|
+
queryObj: {},
|
|
145
|
+
headersObj: { 'Content-Type': 'application/octet-stream' },
|
|
146
|
+
cookiesObj: {},
|
|
147
|
+
allHeaders: { 'Content-Type': 'application/octet-stream' },
|
|
148
|
+
uriObj: {
|
|
149
|
+
protocol: 'http:',
|
|
150
|
+
slashes: true,
|
|
151
|
+
auth: null,
|
|
152
|
+
host: 'petstore.swagger.io',
|
|
153
|
+
port: null,
|
|
154
|
+
hostname: 'petstore.swagger.io',
|
|
155
|
+
hash: null,
|
|
156
|
+
search: '',
|
|
157
|
+
query: {},
|
|
158
|
+
pathname: '/v2/upload',
|
|
159
|
+
path: '/v2/upload',
|
|
160
|
+
href: 'http://petstore.swagger.io/v2/upload',
|
|
161
|
+
},
|
|
162
|
+
fullUrl: 'http://petstore.swagger.io/v2/upload',
|
|
163
|
+
};
|
|
164
|
+
const result = httpclient(sourceWithOctetStream, originalOptions, {
|
|
165
|
+
target: 'csharp',
|
|
166
|
+
client: 'httpclient',
|
|
167
|
+
});
|
|
168
|
+
expect(result).toMatchSnapshot();
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=httpclient.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HTTPSnippet } from '../../../index.js';
|