@redocly/openapi-docs 3.24.0 → 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-CIrPFbvX.js → redocly-openapi-docs.min.AiChatProvider-j-VDfFJ9.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-eAy3scC4.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-BBRBmffc.js} +1 -1
- package/dist/{redocly-openapi-docs.min.AiPanel-C6CGDyzy.js → redocly-openapi-docs.min.AiPanel-DTzHqAiI.js} +1 -1
- package/dist/{redocly-openapi-docs.min.FileWatcher-dIKl80Ec.js → redocly-openapi-docs.min.FileWatcher-DDoyaS7A.js} +1 -1
- package/dist/{redocly-openapi-docs.min.SemanticSearchService-D4V6-td8.js → redocly-openapi-docs.min.SemanticSearchService-DNFOPBZK.js} +1 -1
- package/dist/{redocly-openapi-docs.min.SqliteDBStorage-D9-Rb-N7.js → redocly-openapi-docs.min.SqliteDBStorage-Dy40Vq04.js} +1 -1
- package/dist/{redocly-openapi-docs.min.TauriFileSystemAdapter-CHW6hO3z.js → redocly-openapi-docs.min.TauriFileSystemAdapter-CpViFqJQ.js} +1 -1
- package/dist/{redocly-openapi-docs.min.TauriRootStorage-CHiKNUn2.js → redocly-openapi-docs.min.TauriRootStorage-TCUrp2uB.js} +1 -1
- package/dist/{redocly-openapi-docs.min.ai-chat-mappers-C19k85fj.js → redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js} +1 -1
- package/dist/{redocly-openapi-docs.min.external-resolver-BH7DBWU-.js → redocly-openapi-docs.min.external-resolver-BkceRyB4.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-BQp5pipW.js → redocly-openapi-docs.min.index-BCcol5vU.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-dirYvuKs.js → redocly-openapi-docs.min.index-C6uU_v-b.js} +1 -1
- package/dist/{redocly-openapi-docs.min.index-BuFUmOUm.js → redocly-openapi-docs.min.index-CmXZfuiZ.js} +11 -11
- package/dist/{redocly-openapi-docs.min.index-DLlCa16R.js → redocly-openapi-docs.min.index-DVWw0ICA.js} +1 -1
- package/dist/redocly-openapi-docs.min.js +1 -1
- package/dist/{redocly-openapi-docs.min.lint-Xu623Q1T.js → redocly-openapi-docs.min.lint-2YpbCz3r.js} +2 -2
- package/dist/{redocly-openapi-docs.min.lint-graphql-D-Nm5P1M.js → redocly-openapi-docs.min.lint-graphql-Bgfcu2tP.js} +1 -1
- package/dist/{redocly-openapi-docs.min.respect-run-CWNqYysq.js → redocly-openapi-docs.min.respect-run-Ct8taisL.js} +1 -1
- package/dist/{redocly-openapi-docs.min.standalone-CRo0Sa5b.js → redocly-openapi-docs.min.standalone-BPCdJgtH.js} +3 -3
- package/dist/{redocly-openapi-docs.min.tauri-path-BUSVirPk.js → redocly-openapi-docs.min.tauri-path-CmqBCxGb.js} +1 -1
- package/dist/{redocly-openapi-docs.min.useAiChatQueries-CXyQzME7.js → redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js} +2 -2
- 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/__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/ContentItem/__tests__/useIsExpanded.test.d.ts +1 -0
- package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +123 -0
- 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/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/__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/__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/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/Tabs/__tests__/Tabs.test.d.ts +1 -0
- package/lib/components/Tabs/__tests__/Tabs.test.js +27 -0
- 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/__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/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/package.json +4 -4
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import { convertOperationToReplayValue, convertOperationToReplayValueForRedoc, convertRequestSecurity, } from '../utils.js';
|
|
2
|
+
import { getOperation } from '../../../models/index.js';
|
|
3
|
+
vi.mock('../../../services', () => {
|
|
4
|
+
return {
|
|
5
|
+
OpenAPIParser: class MockOpenAPIParser {
|
|
6
|
+
definition;
|
|
7
|
+
constructor(definition) {
|
|
8
|
+
this.definition = definition;
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
normalizeOptions: vi.fn(() => ({})),
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
vi.mock('../../../models', () => ({
|
|
15
|
+
getOperation: vi.fn(),
|
|
16
|
+
}));
|
|
17
|
+
const mockGetOperation = vi.mocked(getOperation);
|
|
18
|
+
const createMockField = (name, example) => ({
|
|
19
|
+
name,
|
|
20
|
+
example,
|
|
21
|
+
schema: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
format: undefined,
|
|
24
|
+
enum: [],
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
describe('Replay utils', () => {
|
|
28
|
+
describe('convertOperationToReplayValue', () => {
|
|
29
|
+
it('returns undefined when openAPI is not provided', () => {
|
|
30
|
+
const result = convertOperationToReplayValue('/path', 'get', undefined);
|
|
31
|
+
expect(result).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
it('returns undefined when operation is not found', () => {
|
|
34
|
+
const mockOpenAPI = {
|
|
35
|
+
paths: {
|
|
36
|
+
'/path': {
|
|
37
|
+
get: {},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
mockGetOperation.mockReturnValue(null);
|
|
42
|
+
const result = convertOperationToReplayValue('/path', 'get', mockOpenAPI);
|
|
43
|
+
expect(result).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
it('forwards docs options to getOperation (e.g. mock server for embedded replay)', () => {
|
|
46
|
+
const mockOpenAPI = {
|
|
47
|
+
paths: {
|
|
48
|
+
'/test': {
|
|
49
|
+
get: {},
|
|
50
|
+
parameters: [],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
mockGetOperation.mockClear();
|
|
55
|
+
mockGetOperation.mockReturnValue({
|
|
56
|
+
id: 'op1',
|
|
57
|
+
name: 'Test Operation',
|
|
58
|
+
httpVerb: 'get',
|
|
59
|
+
operationId: 'testOp',
|
|
60
|
+
parameters: [],
|
|
61
|
+
path: '/test',
|
|
62
|
+
href: '/test',
|
|
63
|
+
servers: [],
|
|
64
|
+
security: [],
|
|
65
|
+
responses: [],
|
|
66
|
+
});
|
|
67
|
+
const docsOptions = {
|
|
68
|
+
mockServer: {
|
|
69
|
+
url: 'http://localhost:9999/_mock/slug',
|
|
70
|
+
description: 'Mock server',
|
|
71
|
+
position: 'first',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
convertOperationToReplayValue('/test', 'get', mockOpenAPI, undefined, undefined, undefined, undefined, docsOptions);
|
|
75
|
+
expect(mockGetOperation).toHaveBeenCalled();
|
|
76
|
+
const lastCall = mockGetOperation.mock.calls[mockGetOperation.mock.calls.length - 1];
|
|
77
|
+
expect(lastCall[3]).toEqual(docsOptions);
|
|
78
|
+
});
|
|
79
|
+
it('converts operation to replay value correctly', () => {
|
|
80
|
+
const mockOperation = {
|
|
81
|
+
id: 'op1',
|
|
82
|
+
name: 'Test Operation',
|
|
83
|
+
httpVerb: 'get',
|
|
84
|
+
operationId: 'testOp',
|
|
85
|
+
parameters: [],
|
|
86
|
+
path: '/test',
|
|
87
|
+
href: '/test',
|
|
88
|
+
servers: [],
|
|
89
|
+
security: [],
|
|
90
|
+
responses: [
|
|
91
|
+
{
|
|
92
|
+
code: '200',
|
|
93
|
+
description: 'Success',
|
|
94
|
+
content: {
|
|
95
|
+
mediaTypes: [
|
|
96
|
+
{
|
|
97
|
+
name: 'application/json',
|
|
98
|
+
schema: {
|
|
99
|
+
rawSchema: { type: 'object' },
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
};
|
|
107
|
+
const mockOpenAPI = {
|
|
108
|
+
paths: {
|
|
109
|
+
'/test': {
|
|
110
|
+
get: {},
|
|
111
|
+
parameters: [],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
116
|
+
const result = convertOperationToReplayValue('/test', 'get', mockOpenAPI);
|
|
117
|
+
expect(result).toEqual({
|
|
118
|
+
id: 'op1',
|
|
119
|
+
name: 'Test Operation',
|
|
120
|
+
method: 'get',
|
|
121
|
+
operationId: 'testOp',
|
|
122
|
+
parameters: [],
|
|
123
|
+
body: undefined,
|
|
124
|
+
path: '/test',
|
|
125
|
+
href: '/test',
|
|
126
|
+
servers: [],
|
|
127
|
+
security: [],
|
|
128
|
+
responses: {
|
|
129
|
+
'200': {
|
|
130
|
+
code: '200',
|
|
131
|
+
description: 'Success',
|
|
132
|
+
mediaTypes: {
|
|
133
|
+
'application/json': {
|
|
134
|
+
name: 'application/json',
|
|
135
|
+
schema: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
components: {},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
it('should set allowReserved on parameters when operation params have allowReserved', () => {
|
|
146
|
+
const mockOperation = {
|
|
147
|
+
id: 'op1',
|
|
148
|
+
name: 'Test',
|
|
149
|
+
httpVerb: 'get',
|
|
150
|
+
operationId: 'testOp',
|
|
151
|
+
parameters: [
|
|
152
|
+
{
|
|
153
|
+
name: 'filter',
|
|
154
|
+
in: 'query',
|
|
155
|
+
required: false,
|
|
156
|
+
allowReserved: true,
|
|
157
|
+
schema: { type: 'string' },
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
path: '/test',
|
|
161
|
+
href: '/test',
|
|
162
|
+
servers: [],
|
|
163
|
+
security: [],
|
|
164
|
+
responses: [],
|
|
165
|
+
};
|
|
166
|
+
const mockOpenAPI = {
|
|
167
|
+
paths: { '/test': { get: {} } },
|
|
168
|
+
};
|
|
169
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
170
|
+
const result = convertOperationToReplayValue('/test', 'get', mockOpenAPI);
|
|
171
|
+
expect(result?.parameters).toHaveLength(1);
|
|
172
|
+
expect(result?.parameters?.[0].allowReserved).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
it('finds operation in additionalOperations when not in standard methods', () => {
|
|
175
|
+
const mockOpenAPI = {
|
|
176
|
+
paths: {
|
|
177
|
+
'/resource': {
|
|
178
|
+
get: { summary: 'Get resource' },
|
|
179
|
+
additionalOperations: {
|
|
180
|
+
test: {
|
|
181
|
+
summary: 'Custom TEST method',
|
|
182
|
+
operationId: 'testOp',
|
|
183
|
+
responses: {},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
let receivedOperationDef = null;
|
|
190
|
+
mockGetOperation.mockImplementation((_parser, operationDef) => {
|
|
191
|
+
receivedOperationDef = operationDef;
|
|
192
|
+
return {
|
|
193
|
+
id: 'custom-op',
|
|
194
|
+
method: 'test',
|
|
195
|
+
operationId: 'testOp',
|
|
196
|
+
parameters: [],
|
|
197
|
+
responses: [],
|
|
198
|
+
servers: [],
|
|
199
|
+
security: [],
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
const result = convertOperationToReplayValue('/resource', 'test', mockOpenAPI);
|
|
203
|
+
expect(receivedOperationDef).toBeDefined();
|
|
204
|
+
expect(receivedOperationDef.summary).toBe('Custom TEST method');
|
|
205
|
+
expect(receivedOperationDef.operationId).toBe('testOp');
|
|
206
|
+
expect(receivedOperationDef.httpVerb).toBe('test');
|
|
207
|
+
expect(receivedOperationDef.pathName).toBe('/resource');
|
|
208
|
+
expect(result).toBeDefined();
|
|
209
|
+
});
|
|
210
|
+
it('returns undefined when method not found and additionalOperations does not contain it', () => {
|
|
211
|
+
const mockOpenAPI = {
|
|
212
|
+
paths: {
|
|
213
|
+
'/resource': {
|
|
214
|
+
get: { summary: 'Get resource' },
|
|
215
|
+
additionalOperations: {
|
|
216
|
+
test: { summary: 'Custom TEST method' },
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
mockGetOperation.mockReturnValue(null);
|
|
222
|
+
const result = convertOperationToReplayValue('/resource', 'greet', mockOpenAPI);
|
|
223
|
+
expect(result).toBeUndefined();
|
|
224
|
+
expect(mockGetOperation).toHaveBeenCalled();
|
|
225
|
+
const callArgs = mockGetOperation.mock.calls[0];
|
|
226
|
+
expect(callArgs[1]?.summary).toBeUndefined();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
describe('convertOperationToReplayValueForRedoc', () => {
|
|
230
|
+
it('returns undefined when base conversion returns undefined', () => {
|
|
231
|
+
const result = convertOperationToReplayValueForRedoc()('/path', 'get', undefined);
|
|
232
|
+
expect(result).toBeUndefined();
|
|
233
|
+
});
|
|
234
|
+
it('adds generated operationId when none exists', () => {
|
|
235
|
+
const mockOpenAPI = {
|
|
236
|
+
paths: {
|
|
237
|
+
'/test': {
|
|
238
|
+
get: {},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
const mockOperation = {
|
|
243
|
+
path: '/test',
|
|
244
|
+
method: 'get',
|
|
245
|
+
httpVerb: 'get',
|
|
246
|
+
operationId: undefined,
|
|
247
|
+
parameters: [],
|
|
248
|
+
security: [],
|
|
249
|
+
responses: [],
|
|
250
|
+
servers: [],
|
|
251
|
+
};
|
|
252
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
253
|
+
const result = convertOperationToReplayValueForRedoc()('/test', 'get', mockOpenAPI);
|
|
254
|
+
expect(result?.operationId).toBe('/paths/~1test/get');
|
|
255
|
+
});
|
|
256
|
+
it('uses stored operation state for active request body example', () => {
|
|
257
|
+
const mockOpenAPI = {
|
|
258
|
+
paths: {
|
|
259
|
+
'/test': {
|
|
260
|
+
get: {},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
const mockOperation = {
|
|
265
|
+
id: 'op1',
|
|
266
|
+
name: 'Test operation',
|
|
267
|
+
path: '/test',
|
|
268
|
+
href: '/test',
|
|
269
|
+
method: 'get',
|
|
270
|
+
httpVerb: 'get',
|
|
271
|
+
operationId: undefined,
|
|
272
|
+
parameters: [],
|
|
273
|
+
servers: [],
|
|
274
|
+
security: [],
|
|
275
|
+
responses: [],
|
|
276
|
+
requestBody: {
|
|
277
|
+
required: false,
|
|
278
|
+
content: {
|
|
279
|
+
mediaTypes: [
|
|
280
|
+
{
|
|
281
|
+
name: 'application/json',
|
|
282
|
+
schema: {
|
|
283
|
+
rawSchema: { type: 'object' },
|
|
284
|
+
},
|
|
285
|
+
examples: {
|
|
286
|
+
default: {
|
|
287
|
+
value: { id: 1 },
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
296
|
+
const result = convertOperationToReplayValueForRedoc(undefined, undefined, undefined, {
|
|
297
|
+
'/paths/~1test/get': {
|
|
298
|
+
activeExampleName: 'event_entry',
|
|
299
|
+
activeOneOf: {},
|
|
300
|
+
activeSecuritySchemeIds: [],
|
|
301
|
+
requestValues: {},
|
|
302
|
+
request: {},
|
|
303
|
+
response: {},
|
|
304
|
+
},
|
|
305
|
+
})('/test', 'get', mockOpenAPI);
|
|
306
|
+
expect(result?.body?.activeExampleName).toBe('event_entry');
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
describe('convertRequestSecurity', () => {
|
|
310
|
+
it('returns undefined when security is not provided', () => {
|
|
311
|
+
const result = convertRequestSecurity(undefined);
|
|
312
|
+
expect(result).toBeUndefined();
|
|
313
|
+
});
|
|
314
|
+
it('converts security requirements correctly', () => {
|
|
315
|
+
const mockSecurity = [
|
|
316
|
+
{
|
|
317
|
+
schemes: [
|
|
318
|
+
{
|
|
319
|
+
id: 'auth1',
|
|
320
|
+
type: 'oauth2',
|
|
321
|
+
in: 'header',
|
|
322
|
+
scopes: ['read'],
|
|
323
|
+
scheme: 'bearer',
|
|
324
|
+
name: 'Authorization',
|
|
325
|
+
flows: { implicit: {} },
|
|
326
|
+
'x-defaultAccessToken': 'token123',
|
|
327
|
+
'x-defaultTokenType': 'Bearer',
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
},
|
|
331
|
+
];
|
|
332
|
+
const result = convertRequestSecurity(mockSecurity);
|
|
333
|
+
expect(result).toEqual([
|
|
334
|
+
[
|
|
335
|
+
{
|
|
336
|
+
id: 'auth1',
|
|
337
|
+
type: 'oauth2',
|
|
338
|
+
in: 'header',
|
|
339
|
+
scopes: ['read'],
|
|
340
|
+
scheme: 'bearer',
|
|
341
|
+
name: 'Authorization',
|
|
342
|
+
flows: { implicit: {} },
|
|
343
|
+
'x-defaultAccessToken': 'token123',
|
|
344
|
+
'x-defaultTokenType': 'Bearer',
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
]);
|
|
348
|
+
});
|
|
349
|
+
it('removes undefined properties from security scheme', () => {
|
|
350
|
+
const mockSecurity = [
|
|
351
|
+
{
|
|
352
|
+
schemes: [
|
|
353
|
+
{
|
|
354
|
+
id: 'auth1',
|
|
355
|
+
type: 'apiKey',
|
|
356
|
+
in: 'header',
|
|
357
|
+
name: 'X-API-Key',
|
|
358
|
+
flows: undefined,
|
|
359
|
+
'x-defaultAccessToken': undefined,
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
];
|
|
364
|
+
const result = convertRequestSecurity(mockSecurity);
|
|
365
|
+
expect(result?.[0][0]).toEqual({
|
|
366
|
+
id: 'auth1',
|
|
367
|
+
type: 'apiKey',
|
|
368
|
+
in: 'header',
|
|
369
|
+
name: 'X-API-Key',
|
|
370
|
+
});
|
|
371
|
+
expect(result?.[0][0].flows).toBeUndefined();
|
|
372
|
+
expect(result?.[0][0]['x-defaultAccessToken']).toBeUndefined();
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
describe('convertOperationToReplayValue with form-urlencoded body', () => {
|
|
376
|
+
it('extracts parameters from oneOf schema for application/x-www-form-urlencoded', () => {
|
|
377
|
+
const mockFields = [
|
|
378
|
+
createMockField('client_id', 'YOUR_CLIENT_ID'),
|
|
379
|
+
createMockField('client_secret', 'YOUR_CLIENT_SECRET'),
|
|
380
|
+
createMockField('grant_type', 'client_credentials'),
|
|
381
|
+
];
|
|
382
|
+
const mockOperation = {
|
|
383
|
+
id: 'op1',
|
|
384
|
+
name: 'Get Token',
|
|
385
|
+
httpVerb: 'post',
|
|
386
|
+
operationId: 'getToken',
|
|
387
|
+
parameters: [],
|
|
388
|
+
path: '/oauth/token',
|
|
389
|
+
href: '/oauth/token',
|
|
390
|
+
servers: [],
|
|
391
|
+
security: [],
|
|
392
|
+
responses: [],
|
|
393
|
+
requestBody: {
|
|
394
|
+
required: true,
|
|
395
|
+
content: {
|
|
396
|
+
mediaTypes: [
|
|
397
|
+
{
|
|
398
|
+
name: 'application/x-www-form-urlencoded',
|
|
399
|
+
schema: {
|
|
400
|
+
fields: undefined,
|
|
401
|
+
oneOf: [
|
|
402
|
+
{
|
|
403
|
+
fields: mockFields,
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
},
|
|
407
|
+
examples: {
|
|
408
|
+
default: {
|
|
409
|
+
value: {
|
|
410
|
+
client_id: 'YOUR_CLIENT_ID',
|
|
411
|
+
client_secret: 'YOUR_CLIENT_SECRET',
|
|
412
|
+
grant_type: 'client_credentials',
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
const mockOpenAPI = {
|
|
422
|
+
paths: {
|
|
423
|
+
'/oauth/token': {
|
|
424
|
+
post: {},
|
|
425
|
+
parameters: [],
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
430
|
+
const result = convertOperationToReplayValue('/oauth/token', 'post', mockOpenAPI);
|
|
431
|
+
expect(result?.body).toBeDefined();
|
|
432
|
+
expect(result?.body?.mediaTypes?.['application/x-www-form-urlencoded']).toBeDefined();
|
|
433
|
+
const formUrlEncodedMediaType = result?.body?.mediaTypes?.['application/x-www-form-urlencoded'];
|
|
434
|
+
expect(formUrlEncodedMediaType?.parameters).toBeDefined();
|
|
435
|
+
expect(formUrlEncodedMediaType?.parameters).toHaveLength(3);
|
|
436
|
+
expect(formUrlEncodedMediaType?.parameters?.[0]?.name).toBe('client_id');
|
|
437
|
+
expect(formUrlEncodedMediaType?.parameters?.[1]?.name).toBe('client_secret');
|
|
438
|
+
expect(formUrlEncodedMediaType?.parameters?.[2]?.name).toBe('grant_type');
|
|
439
|
+
});
|
|
440
|
+
it('extracts parameters from direct schema fields when available', () => {
|
|
441
|
+
const mockFields = [
|
|
442
|
+
createMockField('username', 'testuser'),
|
|
443
|
+
createMockField('password', 'testpass'),
|
|
444
|
+
];
|
|
445
|
+
const mockOperation = {
|
|
446
|
+
id: 'op1',
|
|
447
|
+
name: 'Login',
|
|
448
|
+
httpVerb: 'post',
|
|
449
|
+
operationId: 'login',
|
|
450
|
+
parameters: [],
|
|
451
|
+
path: '/login',
|
|
452
|
+
href: '/login',
|
|
453
|
+
servers: [],
|
|
454
|
+
security: [],
|
|
455
|
+
responses: [],
|
|
456
|
+
requestBody: {
|
|
457
|
+
required: true,
|
|
458
|
+
content: {
|
|
459
|
+
mediaTypes: [
|
|
460
|
+
{
|
|
461
|
+
name: 'application/x-www-form-urlencoded',
|
|
462
|
+
schema: {
|
|
463
|
+
fields: mockFields,
|
|
464
|
+
},
|
|
465
|
+
examples: {},
|
|
466
|
+
},
|
|
467
|
+
],
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
const mockOpenAPI = {
|
|
472
|
+
paths: {
|
|
473
|
+
'/login': {
|
|
474
|
+
post: {},
|
|
475
|
+
parameters: [],
|
|
476
|
+
},
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
480
|
+
const result = convertOperationToReplayValue('/login', 'post', mockOpenAPI);
|
|
481
|
+
const formUrlEncodedMediaType = result?.body?.mediaTypes?.['application/x-www-form-urlencoded'];
|
|
482
|
+
expect(formUrlEncodedMediaType?.parameters).toHaveLength(2);
|
|
483
|
+
expect(formUrlEncodedMediaType?.parameters?.[0]?.name).toBe('username');
|
|
484
|
+
expect(formUrlEncodedMediaType?.parameters?.[1]?.name).toBe('password');
|
|
485
|
+
});
|
|
486
|
+
it('returns undefined parameters when schema has no fields and no oneOf', () => {
|
|
487
|
+
const mockOperation = {
|
|
488
|
+
id: 'op1',
|
|
489
|
+
name: 'Test',
|
|
490
|
+
httpVerb: 'post',
|
|
491
|
+
operationId: 'test',
|
|
492
|
+
parameters: [],
|
|
493
|
+
path: '/test',
|
|
494
|
+
href: '/test',
|
|
495
|
+
servers: [],
|
|
496
|
+
security: [],
|
|
497
|
+
responses: [],
|
|
498
|
+
requestBody: {
|
|
499
|
+
required: true,
|
|
500
|
+
content: {
|
|
501
|
+
mediaTypes: [
|
|
502
|
+
{
|
|
503
|
+
name: 'application/x-www-form-urlencoded',
|
|
504
|
+
schema: {},
|
|
505
|
+
examples: {},
|
|
506
|
+
},
|
|
507
|
+
],
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
};
|
|
511
|
+
const mockOpenAPI = {
|
|
512
|
+
paths: {
|
|
513
|
+
'/test': {
|
|
514
|
+
post: {},
|
|
515
|
+
parameters: [],
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
};
|
|
519
|
+
mockGetOperation.mockReturnValue(mockOperation);
|
|
520
|
+
const result = convertOperationToReplayValue('/test', 'post', mockOpenAPI);
|
|
521
|
+
const formUrlEncodedMediaType = result?.body?.mediaTypes?.['application/x-www-form-urlencoded'];
|
|
522
|
+
expect(formUrlEncodedMediaType?.parameters).toBeUndefined();
|
|
523
|
+
});
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { RequestDetails } from '../RequestDetails.js';
|
|
4
|
+
import { getField, getMediaContent } from '../../../models/index.js';
|
|
5
|
+
import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
|
|
6
|
+
import { withTestProviders, TestMemoryRouter } from '../../../testProviders.js';
|
|
7
|
+
const OPERATION_POINTER = '#/paths/~1pets/get';
|
|
8
|
+
// Wide enough that 45 * 45 = 2025 rows blow the 2000-row budget one level after
|
|
9
|
+
// the schema's own properties.
|
|
10
|
+
const WIDTH = 45;
|
|
11
|
+
const SMALL_WIDTH = 44;
|
|
12
|
+
function makeWideProperties(prefix, value, width = WIDTH) {
|
|
13
|
+
return Object.fromEntries(Array.from({ length: width }, (_, i) => [`${prefix}_${i}`, { ...value }]));
|
|
14
|
+
}
|
|
15
|
+
const definition = {
|
|
16
|
+
openapi: '3.0.0',
|
|
17
|
+
info: { title: 'test', version: '0' },
|
|
18
|
+
paths: {},
|
|
19
|
+
components: {
|
|
20
|
+
schemas: {
|
|
21
|
+
Small: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: makeWideProperties('small', { $ref: '#/components/schemas/SmallLeaf' }, SMALL_WIDTH),
|
|
24
|
+
},
|
|
25
|
+
SmallLeaf: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
properties: makeWideProperties('small_leaf', { type: 'string' }, SMALL_WIDTH),
|
|
28
|
+
},
|
|
29
|
+
Big: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: makeWideProperties('big', { $ref: '#/components/schemas/BigLeaf' }),
|
|
32
|
+
},
|
|
33
|
+
BigLeaf: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: makeWideProperties('leaf', { type: 'string' }),
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
// The probe replaces the parameters/body tree: it renders a real SubSchema at the
|
|
41
|
+
// level nested parameter nodes actually mount at (PropertyDetails defaults level
|
|
42
|
+
// to 1 and passes level + 1), so the test observes whether "Expand all" reaches
|
|
43
|
+
// parameter nesting.
|
|
44
|
+
vi.mock('../../RequestParameters/index.js', async () => {
|
|
45
|
+
const { SubSchema } = await import('../../Schema/SubSchema.js');
|
|
46
|
+
return {
|
|
47
|
+
RequestParameters: () => (_jsx(SubSchema, { expandByDefault: false, expandable: true, level: 2, propertyLength: WIDTH, deepLink: `${OPERATION_POINTER}/t=request`, operationPointer: OPERATION_POINTER, children: _jsx("div", { "data-testid": "nested-content" }) })),
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
const options = normalizeOptions({});
|
|
51
|
+
const parser = new OpenAPIParser(definition, undefined, options);
|
|
52
|
+
const operationDeps = { operation: { pointer: OPERATION_POINTER } };
|
|
53
|
+
function makeOperation(overrides) {
|
|
54
|
+
return {
|
|
55
|
+
id: 'getPets',
|
|
56
|
+
pointer: OPERATION_POINTER,
|
|
57
|
+
description: undefined,
|
|
58
|
+
externalDocs: undefined,
|
|
59
|
+
extensions: {},
|
|
60
|
+
security: [],
|
|
61
|
+
parameters: [],
|
|
62
|
+
requestBody: undefined,
|
|
63
|
+
callbackId: '',
|
|
64
|
+
...overrides,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function renderRequestDetails(operation) {
|
|
68
|
+
return render(withTestProviders(_jsx(TestMemoryRouter, { children: _jsx(RequestDetails, { operation: operation, translate: (_key, value) => value || _key }) }), { definition }));
|
|
69
|
+
}
|
|
70
|
+
describe('RequestDetails expand-all depth', () => {
|
|
71
|
+
it('expands parameter nesting one level when the parameter schema fits the budget', () => {
|
|
72
|
+
const parameter = getField(parser, { name: 'filter', in: 'query', schema: { $ref: '#/components/schemas/Small' } }, '', options, operationDeps);
|
|
73
|
+
renderRequestDetails(makeOperation({ parameters: [parameter] }));
|
|
74
|
+
expect(screen.queryByTestId('nested-content')).not.toBeInTheDocument();
|
|
75
|
+
// A parameter's own property rows render behind a level-2 node (the parameter
|
|
76
|
+
// row itself is level 1). Showing the 45 properties fits the budget, so
|
|
77
|
+
// "Expand all" must open the parameter node — not skip parameters entirely.
|
|
78
|
+
fireEvent.click(screen.getByRole('button', { name: /expand all/i }));
|
|
79
|
+
expect(screen.getByTestId('nested-content')).toBeInTheDocument();
|
|
80
|
+
});
|
|
81
|
+
it('keeps nested body nodes collapsed when their rows exceed the budget', () => {
|
|
82
|
+
const requestBody = {
|
|
83
|
+
content: getMediaContent({
|
|
84
|
+
parser,
|
|
85
|
+
info: { 'application/json': { schema: { $ref: '#/components/schemas/Big' } } },
|
|
86
|
+
isRequestType: true,
|
|
87
|
+
options,
|
|
88
|
+
data: operationDeps,
|
|
89
|
+
}),
|
|
90
|
+
};
|
|
91
|
+
renderRequestDetails(makeOperation({ requestBody }));
|
|
92
|
+
// The body root's 45 property rows are always visible; expanding their nested
|
|
93
|
+
// level-2 nodes would add 2025 rows and blow the budget, so depth stays 1.
|
|
94
|
+
fireEvent.click(screen.getByRole('button', { name: /expand all/i }));
|
|
95
|
+
expect(screen.queryByTestId('nested-content')).not.toBeInTheDocument();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
//# sourceMappingURL=RequestDetails.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|