@redocly/openapi-docs 3.24.1 → 3.24.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/lib/telemetry/RedocTelemetry.js +1 -31
  2. package/package.json +4 -4
  3. package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +0 -1
  4. package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +0 -46
  5. package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +0 -1
  6. package/lib/components/Callbacks/__tests__/Callbacks.test.js +0 -46
  7. package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +0 -1
  8. package/lib/components/Content/__tests__/useAutoScroll.test.js +0 -88
  9. package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +0 -1
  10. package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +0 -123
  11. package/lib/components/ContentItems/__tests__/Items.test.d.ts +0 -1
  12. package/lib/components/ContentItems/__tests__/Items.test.js +0 -66
  13. package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +0 -1
  14. package/lib/components/ContentItems/__tests__/VirtualList.test.js +0 -135
  15. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +0 -1
  16. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +0 -63
  17. package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +0 -1
  18. package/lib/components/Download/__tests__/DownloadSpecification.test.js +0 -52
  19. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +0 -1
  20. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +0 -60
  21. package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +0 -1
  22. package/lib/components/ExpandAllButton/__tests__/helpers.test.js +0 -133
  23. package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +0 -1
  24. package/lib/components/Language/__tests__/LanguageDropdown.test.js +0 -23
  25. package/lib/components/Markdown/__tests__/Markdown.test.d.ts +0 -1
  26. package/lib/components/Markdown/__tests__/Markdown.test.js +0 -34
  27. package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +0 -1
  28. package/lib/components/McpOverview/__tests__/McpOverview.test.js +0 -66
  29. package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +0 -1
  30. package/lib/components/McpTool/__tests__/McpPrompt.test.js +0 -57
  31. package/lib/components/McpTool/__tests__/McpResource.test.d.ts +0 -1
  32. package/lib/components/McpTool/__tests__/McpResource.test.js +0 -81
  33. package/lib/components/McpTool/__tests__/McpTool.test.d.ts +0 -1
  34. package/lib/components/McpTool/__tests__/McpTool.test.js +0 -82
  35. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +0 -1
  36. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +0 -79
  37. package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +0 -1
  38. package/lib/components/OperationItem/__tests__/OperationItem.test.js +0 -70
  39. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +0 -16
  40. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +0 -42
  41. package/lib/components/Overview/__tests__/Overview.test.d.ts +0 -1
  42. package/lib/components/Overview/__tests__/Overview.test.js +0 -59
  43. package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +0 -1
  44. package/lib/components/PayloadSamples/__tests__/Example.test.js +0 -36
  45. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +0 -1
  46. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +0 -197
  47. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +0 -1
  48. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +0 -38
  49. package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +0 -1
  50. package/lib/components/PropertyDetails/__tests__/Extensions.test.js +0 -21
  51. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +0 -1
  52. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +0 -52
  53. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +0 -1
  54. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +0 -191
  55. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +0 -1
  56. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +0 -365
  57. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +0 -1
  58. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +0 -23
  59. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +0 -1
  60. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +0 -16
  61. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +0 -1
  62. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +0 -104
  63. package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +0 -1
  64. package/lib/components/RenderHook/__tests__/RenderHook.test.js +0 -15
  65. package/lib/components/Replay/__tests__/utils.test.d.ts +0 -1
  66. package/lib/components/Replay/__tests__/utils.test.js +0 -526
  67. package/lib/components/Request/__tests__/RequestDetails.test.d.ts +0 -1
  68. package/lib/components/Request/__tests__/RequestDetails.test.js +0 -98
  69. package/lib/components/RequestSamples/__tests__/Example.test.d.ts +0 -1
  70. package/lib/components/RequestSamples/__tests__/Example.test.js +0 -384
  71. package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +0 -1
  72. package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +0 -226
  73. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +0 -1
  74. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +0 -64
  75. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +0 -1
  76. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +0 -29
  77. package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +0 -1
  78. package/lib/components/Responses/__tests__/OperationResponseList.test.js +0 -89
  79. package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +0 -1
  80. package/lib/components/Responses/__tests__/ResponseDetails.test.js +0 -111
  81. package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +0 -1
  82. package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +0 -26
  83. package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +0 -1
  84. package/lib/components/Schema/__tests__/ArraySchema.test.js +0 -93
  85. package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +0 -1
  86. package/lib/components/Schema/__tests__/ObjectSchema.test.js +0 -115
  87. package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +0 -1
  88. package/lib/components/Schema/__tests__/OneOfSchema.test.js +0 -33
  89. package/lib/components/Schema/__tests__/Schema.test.d.ts +0 -1
  90. package/lib/components/Schema/__tests__/Schema.test.js +0 -67
  91. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +0 -1
  92. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +0 -22
  93. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +0 -1
  94. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +0 -95
  95. package/lib/components/Security/__tests__/Security.test.d.ts +0 -1
  96. package/lib/components/Security/__tests__/Security.test.js +0 -38
  97. package/lib/components/Security/__tests__/SecurityButton.test.d.ts +0 -1
  98. package/lib/components/Security/__tests__/SecurityButton.test.js +0 -92
  99. package/lib/components/Security/__tests__/SecurityModal.test.d.ts +0 -1
  100. package/lib/components/Security/__tests__/SecurityModal.test.js +0 -172
  101. package/lib/components/ServerList/__tests__/ServerList.test.d.ts +0 -1
  102. package/lib/components/ServerList/__tests__/ServerList.test.js +0 -83
  103. package/lib/components/Tabs/__tests__/Tabs.test.d.ts +0 -1
  104. package/lib/components/Tabs/__tests__/Tabs.test.js +0 -27
  105. package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +0 -1
  106. package/lib/components/ViewNested/__tests__/ViewNested.test.js +0 -42
  107. package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +0 -1
  108. package/lib/components/__tests__/Samples/ExampleSwitch.test.js +0 -45
  109. package/lib/components/__tests__/Samples/use-example-key.test.d.ts +0 -1
  110. package/lib/components/__tests__/Samples/use-example-key.test.js +0 -28
  111. package/lib/components/__tests__/common/ClearButton.test.d.ts +0 -1
  112. package/lib/components/__tests__/common/ClearButton.test.js +0 -18
  113. package/lib/components/__tests__/common/Dropdown.test.d.ts +0 -1
  114. package/lib/components/__tests__/common/Dropdown.test.js +0 -52
  115. package/lib/components/__tests__/mocks/examples.d.ts +0 -4
  116. package/lib/components/__tests__/mocks/examples.js +0 -115
  117. package/lib/components/common/__tests__/Dropdown.test.d.ts +0 -1
  118. package/lib/components/common/__tests__/Dropdown.test.js +0 -129
  119. package/lib/components/common/__tests__/LinkToField.test.d.ts +0 -1
  120. package/lib/components/common/__tests__/LinkToField.test.js +0 -39
  121. package/lib/jotai/__tests__/app.test.d.ts +0 -1
  122. package/lib/jotai/__tests__/app.test.js +0 -53
  123. package/lib/models/__tests__/Callback.test.d.ts +0 -1
  124. package/lib/models/__tests__/Callback.test.js +0 -15
  125. package/lib/models/__tests__/FieldModel.test.d.ts +0 -1
  126. package/lib/models/__tests__/FieldModel.test.js +0 -117
  127. package/lib/models/__tests__/MediaContent.test.d.ts +0 -1
  128. package/lib/models/__tests__/MediaContent.test.js +0 -105
  129. package/lib/models/__tests__/Operation.test.d.ts +0 -1
  130. package/lib/models/__tests__/Operation.test.js +0 -459
  131. package/lib/models/__tests__/Response.test.d.ts +0 -1
  132. package/lib/models/__tests__/Response.test.js +0 -221
  133. package/lib/models/__tests__/Schema.circular.test.d.ts +0 -1
  134. package/lib/models/__tests__/Schema.circular.test.js +0 -694
  135. package/lib/models/__tests__/Schema.test.d.ts +0 -1
  136. package/lib/models/__tests__/Schema.test.js +0 -1395
  137. package/lib/models/__tests__/example.test.d.ts +0 -1
  138. package/lib/models/__tests__/example.test.js +0 -90
  139. package/lib/models/__tests__/group.test.d.ts +0 -1
  140. package/lib/models/__tests__/group.test.js +0 -52
  141. package/lib/models/__tests__/helpers.d.ts +0 -5
  142. package/lib/models/__tests__/helpers.js +0 -62
  143. package/lib/models/__tests__/request.test.d.ts +0 -1
  144. package/lib/models/__tests__/request.test.js +0 -119
  145. package/lib/services/__tests__/OpenAPIParser.test.d.ts +0 -1
  146. package/lib/services/__tests__/OpenAPIParser.test.js +0 -80
  147. package/lib/services/__tests__/check.test.d.ts +0 -1
  148. package/lib/services/__tests__/check.test.js +0 -22
  149. package/lib/services/__tests__/utils.test.d.ts +0 -1
  150. package/lib/services/__tests__/utils.test.js +0 -42
  151. package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +0 -1
  152. package/lib/services/code-samples/__tests__/apply-environments.test.js +0 -64
  153. package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +0 -1
  154. package/lib/services/code-samples/__tests__/build-code-samples.test.js +0 -70
  155. package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +0 -1
  156. package/lib/services/code-samples/__tests__/convertSampleToString.test.js +0 -116
  157. package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +0 -1
  158. package/lib/services/code-samples/__tests__/generator-data-value.test.js +0 -277
  159. package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +0 -1
  160. package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +0 -258
  161. package/lib/services/code-samples/__tests__/generator-value.test.d.ts +0 -1
  162. package/lib/services/code-samples/__tests__/generator-value.test.js +0 -273
  163. package/lib/services/code-samples/__tests__/generator.test.d.ts +0 -249
  164. package/lib/services/code-samples/__tests__/generator.test.js +0 -1201
  165. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +0 -1
  166. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +0 -31
  167. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +0 -1
  168. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +0 -222
  169. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +0 -1
  170. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +0 -129
  171. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +0 -1
  172. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +0 -49
  173. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +0 -1
  174. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +0 -172
  175. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +0 -1
  176. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +0 -172
  177. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +0 -1
  178. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +0 -130
  179. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +0 -1
  180. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +0 -191
  181. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +0 -1
  182. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +0 -172
  183. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +0 -1
  184. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +0 -85
  185. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +0 -1
  186. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +0 -85
  187. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +0 -1
  188. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +0 -126
  189. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +0 -1
  190. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +0 -105
  191. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +0 -1
  192. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +0 -126
  193. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +0 -1
  194. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +0 -129
  195. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +0 -1
  196. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +0 -129
  197. package/lib/services/config-options/__tests__/helpers.test.d.ts +0 -1
  198. package/lib/services/config-options/__tests__/helpers.test.js +0 -234
  199. package/lib/services/history/__tests__/helpers.test.d.ts +0 -1
  200. package/lib/services/history/__tests__/helpers.test.js +0 -19
  201. package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +0 -1
  202. package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +0 -109
  203. package/lib/services/menu/__tests__/builder.test.d.ts +0 -1
  204. package/lib/services/menu/__tests__/builder.test.js +0 -307
  205. package/lib/services/menu/__tests__/operation.test.d.ts +0 -1
  206. package/lib/services/menu/__tests__/operation.test.js +0 -240
  207. package/lib/services/menu/__tests__/tags.test.d.ts +0 -1
  208. package/lib/services/menu/__tests__/tags.test.js +0 -71
  209. package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +0 -1
  210. package/lib/telemetry/__tests__/RedocTelemetry.test.js +0 -107
  211. package/lib/testProviders.d.ts +0 -6
  212. package/lib/testProviders.js +0 -14
  213. package/lib/utils/__tests__/areArraysEqual.test.d.ts +0 -1
  214. package/lib/utils/__tests__/areArraysEqual.test.js +0 -33
  215. package/lib/utils/__tests__/argValuesHelpers.d.ts +0 -1
  216. package/lib/utils/__tests__/argValuesHelpers.js +0 -56
  217. package/lib/utils/__tests__/calculateMaxLength.test.d.ts +0 -1
  218. package/lib/utils/__tests__/calculateMaxLength.test.js +0 -119
  219. package/lib/utils/__tests__/configure-helpers.test.d.ts +0 -1
  220. package/lib/utils/__tests__/configure-helpers.test.js +0 -356
  221. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +0 -1
  222. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +0 -392
  223. package/lib/utils/__tests__/debounce.test.d.ts +0 -1
  224. package/lib/utils/__tests__/debounce.test.js +0 -54
  225. package/lib/utils/__tests__/debug.test.d.ts +0 -1
  226. package/lib/utils/__tests__/debug.test.js +0 -23
  227. package/lib/utils/__tests__/dom.test.d.ts +0 -1
  228. package/lib/utils/__tests__/dom.test.js +0 -108
  229. package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +0 -1
  230. package/lib/utils/__tests__/getBreadcrumbs.test.js +0 -98
  231. package/lib/utils/__tests__/hasNestedFields.test.d.ts +0 -1
  232. package/lib/utils/__tests__/hasNestedFields.test.js +0 -147
  233. package/lib/utils/__tests__/helpers.test.d.ts +0 -1
  234. package/lib/utils/__tests__/helpers.test.js +0 -174
  235. package/lib/utils/__tests__/isMobile.test.d.ts +0 -1
  236. package/lib/utils/__tests__/isMobile.test.js +0 -28
  237. package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +0 -1
  238. package/lib/utils/__tests__/loadAndBundleSpec.test.js +0 -22
  239. package/lib/utils/__tests__/local-storage.test.d.ts +0 -1
  240. package/lib/utils/__tests__/local-storage.test.js +0 -48
  241. package/lib/utils/__tests__/object.test.d.ts +0 -1
  242. package/lib/utils/__tests__/object.test.js +0 -45
  243. package/lib/utils/__tests__/openapi.test.d.ts +0 -1
  244. package/lib/utils/__tests__/openapi.test.js +0 -1378
  245. package/lib/utils/__tests__/path.test.d.ts +0 -1
  246. package/lib/utils/__tests__/path.test.js +0 -16
  247. package/lib/utils/__tests__/queryString.test.d.ts +0 -1
  248. package/lib/utils/__tests__/queryString.test.js +0 -60
  249. package/lib/utils/__tests__/replaceVariables.test.d.ts +0 -1
  250. package/lib/utils/__tests__/replaceVariables.test.js +0 -46
  251. package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +0 -1
  252. package/lib/utils/__tests__/simplifyAstStructure.test.js +0 -26
  253. package/lib/utils/__tests__/sort.test.d.ts +0 -1
  254. package/lib/utils/__tests__/sort.test.js +0 -16
  255. package/lib/utils/__tests__/string.test.d.ts +0 -1
  256. package/lib/utils/__tests__/string.test.js +0 -16
  257. package/lib/utils/__tests__/theme-helpers.test.d.ts +0 -1
  258. package/lib/utils/__tests__/theme-helpers.test.js +0 -24
  259. package/lib/utils/__tests__/url.test.d.ts +0 -1
  260. package/lib/utils/__tests__/url.test.js +0 -134
@@ -1,31 +1 @@
1
- import { Telemetry } from '@redocly/redoc-opentelemetry';
2
- import pkg from '../../package.json' with { type: 'json' };
3
- const OTEL_TRACES_URL = 'https://otel.cloud.redocly.com/v1/traces';
4
- export class RedocTelemetry extends Telemetry {
5
- specType;
6
- constructor(config) {
7
- super();
8
- this.specType = config.specType;
9
- this.init({
10
- otel: {
11
- isProd: process.env.NODE_ENV === 'production' || process.env.ENABLE_LOCAL_TELEMETRY === 'true',
12
- serviceVersion: config.serviceVersion || `${pkg.name}@${pkg.version}`,
13
- version: '1.0.0',
14
- collectorTraceUrl: config.collectorUrl || OTEL_TRACES_URL,
15
- serviceName: config.serviceName || 'redoc-ce',
16
- tracerName: 'client-telemetry',
17
- },
18
- disabled: config.disabled || false,
19
- });
20
- }
21
- // TODO: remove this once we have a proper way to enrich the data
22
- send(event, data) {
23
- if (data && Array.isArray(data) && data.length > 0) {
24
- data = data.map((item) => item && typeof item === 'object' ? { ...item, specType: this.specType } : item);
25
- }
26
- super.send(event, data, {
27
- env: process.env.NODE_ENV,
28
- });
29
- }
30
- }
31
- //# sourceMappingURL=RedocTelemetry.js.map
1
+ import{Telemetry as o}from"@redocly/redoc-opentelemetry";import c from"../../package.json"with{type:"json"};const p="https://otel.cloud.redocly.com/v1/traces";class n extends o{specType;constructor(e){super(),this.specType=e.specType,this.init({otel:{isProd:process.env.NODE_ENV==="production"||process.env.ENABLE_LOCAL_TELEMETRY==="true",serviceVersion:e.serviceVersion||`${c.name}@${c.version}`,version:"1.0.0",collectorTraceUrl:e.collectorUrl||p,serviceName:e.serviceName||"redoc-ce",tracerName:"client-telemetry"},disabled:e.disabled||!1})}send(e,r){r&&Array.isArray(r)&&r.length>0&&(r=r.map(s=>s&&typeof s=="object"?{...s,specType:this.specType}:s)),super.send(e,r,{env:process.env.NODE_ENV})}}export{n as RedocTelemetry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/openapi-docs",
3
- "version": "3.24.1",
3
+ "version": "3.24.2",
4
4
  "description": "Redocly OpenAPI Docs",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -39,9 +39,9 @@
39
39
  "url-template": "^2.0.8",
40
40
  "util": "~0.12.5",
41
41
  "web-vitals": "3.3.1",
42
- "@redocly/redoc-opentelemetry": "0.2.2",
43
42
  "@redocly/config": "0.53.1",
44
- "@redocly/replay": "0.27.1"
43
+ "@redocly/replay": "0.27.2",
44
+ "@redocly/redoc-opentelemetry": "0.2.2"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@shikijs/transformers": "3.21.0",
@@ -71,7 +71,7 @@
71
71
  "url": "~0.11.0",
72
72
  "vite": "7.3.6",
73
73
  "vitest": "4.1.10",
74
- "@redocly/theme": "0.68.1"
74
+ "@redocly/theme": "0.68.2"
75
75
  },
76
76
  "scripts": {
77
77
  "start": "pnpm run copy-highlight-hook && vite",
@@ -1 +0,0 @@
1
- export {};
@@ -1,46 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import util from 'util';
3
- import { render } from '@testing-library/react';
4
- import * as Jotai from 'jotai';
5
- import { LayoutVariant } from '@redocly/config';
6
- import { ApiInfo } from '../ApiInfo.js';
7
- import { TestBrowserRouter } from '../../../testProviders.js';
8
- Object.defineProperty(global, 'TextEncoder', {
9
- value: util.TextEncoder,
10
- });
11
- vi.mock('jotai', async () => ({
12
- ...(await vi.importActual('jotai')),
13
- useAtomValue: vi.fn(),
14
- }));
15
- describe('ApiInfo', () => {
16
- it('ApiInfo renders correctly', () => {
17
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue({
18
- parser: {
19
- definition: {
20
- info: {
21
- downloadFileName: 'downloadFileNameValue',
22
- summary: ' ',
23
- description: 'This is a sample server Petstore server.',
24
- },
25
- },
26
- },
27
- options: {
28
- downloadDefinitionUrl: 'downloadDefinitionUrlValue',
29
- expandDefaultServerVariables: true,
30
- },
31
- });
32
- const result = render(_jsx(ApiInfo, { layout: LayoutVariant.THREE_PANEL, item: {
33
- infoDefinition: {
34
- info: {
35
- downloadFileName: 'downloadFileNameValue',
36
- summary: 'Some summary',
37
- description: 'This is a sample server Petstore server.',
38
- },
39
- },
40
- } }), {
41
- wrapper: TestBrowserRouter,
42
- });
43
- expect(result).toMatchSnapshot();
44
- });
45
- });
46
- //# sourceMappingURL=ApiInfo.test.js.map
@@ -1,46 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
5
- import { getCallback } from '../../../models/index.js';
6
- import { CallbackOperation } from '../CallbackOperation.js';
7
- import { CallbacksList } from '../CallbacksList.js';
8
- import { CallbackSummary } from '../CallbackSummary.js';
9
- import * as simpleCallbackFixture from './fixtures/simple-callback.json';
10
- import { TestBrowserRouter } from '../../../testProviders.js';
11
- const options = normalizeOptions({});
12
- describe('Components', () => {
13
- describe('Callbacks', () => {
14
- const parser = new OpenAPIParser(simpleCallbackFixture, undefined, options);
15
- const callback = getCallback(parser, 'Test.Callback', { $ref: '#/components/callbacks/Test' }, '', options, '');
16
- const renderCallbackOperation = (props = {}) => render(_jsx(CallbackOperation, { operation: callback.operations[0], onExpand: () => { }, selectedCallback: null, ...props }), {
17
- wrapper: TestBrowserRouter,
18
- });
19
- it('should correctly render CallbackView', () => {
20
- const { getByText } = renderCallbackOperation();
21
- expect(getByText('testCallback')).toBeInTheDocument();
22
- });
23
- it('should correctly render CallbackTitle', () => {
24
- const { getByText } = render(_jsx(CallbackSummary, { toggle: () => { }, callback: callback.operations[0], translate: () => '' }), {
25
- wrapper: TestBrowserRouter,
26
- });
27
- expect(getByText('testCallback')).toBeInTheDocument();
28
- });
29
- it('should expand the callback when the summary is clicked', async () => {
30
- const user = userEvent.setup();
31
- const onExpand = vi.fn();
32
- const { getByText, getByTestId, queryByTestId } = renderCallbackOperation({ onExpand });
33
- expect(queryByTestId('panel-body')).not.toBeInTheDocument();
34
- await user.click(getByText('testCallback'));
35
- expect(onExpand).toHaveBeenCalledWith(callback.operations[0]);
36
- expect(getByTestId('panel-body')).toBeInTheDocument();
37
- });
38
- it('should correctly render CallbacksList', () => {
39
- const { getByText } = render(_jsx(CallbacksList, { callbacks: [callback], onExpand: () => { }, selectedCallback: null }), {
40
- wrapper: TestBrowserRouter,
41
- });
42
- expect(getByText('testCallback')).toBeInTheDocument();
43
- });
44
- });
45
- });
46
- //# sourceMappingURL=Callbacks.test.js.map
@@ -1,88 +0,0 @@
1
- import { renderHook } from '@testing-library/react';
2
- import { useLocation } from 'react-router';
3
- import { vi } from 'vitest';
4
- import { useAutoScroll } from '../useAutoScroll.js';
5
- vi.mock('react-router', () => ({
6
- useLocation: vi.fn(),
7
- }));
8
- vi.mock('lodash.throttle', () => ({
9
- default: (fn) => fn,
10
- }));
11
- vi.mock('@redocly/theme', async () => {
12
- const actual = await vi.importActual('@redocly/theme');
13
- return {
14
- ...actual,
15
- IS_BROWSER: true,
16
- useActiveSectionId: vi.fn(() => '/test'),
17
- };
18
- });
19
- describe('useAutoScroll', () => {
20
- beforeEach(() => {
21
- vi.useFakeTimers();
22
- vi.clearAllMocks();
23
- useAutoScroll.initialPageLoad = true;
24
- window.history.replaceState = vi.fn();
25
- window.scrollTo = vi.fn();
26
- document.getElementById = vi.fn();
27
- document.querySelector = vi.fn();
28
- Object.defineProperty(window, 'location', {
29
- value: { pathname: '', hash: '' },
30
- writable: true,
31
- });
32
- });
33
- afterEach(() => {
34
- vi.useRealTimers();
35
- vi.restoreAllMocks();
36
- });
37
- test('should processing without toLowerCase', () => {
38
- const mockLocation = {
39
- pathname: '/test',
40
- hash: '#TestHash',
41
- state: null,
42
- key: '',
43
- search: '',
44
- };
45
- useLocation.mockReturnValue(mockLocation);
46
- renderHook(() => useAutoScroll('/'));
47
- expect(document.getElementById).toHaveBeenCalledWith('TestHash');
48
- });
49
- test('should extract and process legacy hash patterns', () => {
50
- const mockLocation = {
51
- pathname: '/test',
52
- hash: '#tag/TestTag',
53
- state: null,
54
- key: '',
55
- search: '',
56
- };
57
- useLocation.mockReturnValue(mockLocation);
58
- renderHook(() => useAutoScroll('/'));
59
- expect(document.getElementById).toHaveBeenCalledWith('test/testtag');
60
- });
61
- test('should scroll to top when on base path without hash', () => {
62
- const mockLocation = {
63
- pathname: '/',
64
- hash: '',
65
- state: null,
66
- key: '',
67
- search: '',
68
- };
69
- useLocation.mockReturnValue(mockLocation);
70
- renderHook(() => useAutoScroll('/'));
71
- expect(window.scrollTo).toHaveBeenCalledWith(0, 0);
72
- });
73
- test('should scroll element into view when found', () => {
74
- const mockElement = { scrollIntoView: vi.fn() };
75
- const mockLocation = {
76
- pathname: '/test',
77
- hash: '#TestHash',
78
- state: null,
79
- key: '',
80
- search: '',
81
- };
82
- useLocation.mockReturnValue(mockLocation);
83
- document.getElementById.mockReturnValue(mockElement);
84
- renderHook(() => useAutoScroll('/'));
85
- expect(mockElement.scrollIntoView).toHaveBeenCalled();
86
- });
87
- });
88
- //# sourceMappingURL=useAutoScroll.test.js.map
@@ -1,123 +0,0 @@
1
- import { renderHook } from '@testing-library/react';
2
- import { useLocation } from 'react-router';
3
- import { useIsExpanded } from '../useIsExpanded.js';
4
- // Mock react-router
5
- vi.mock('react-router', () => ({
6
- useLocation: vi.fn(),
7
- }));
8
- const mockUseLocation = useLocation;
9
- describe('useIsExpanded', () => {
10
- const mockRoutingBasePath = '/docs';
11
- beforeEach(() => {
12
- mockUseLocation.mockReset();
13
- });
14
- it('should return false for non-tag items', () => {
15
- mockUseLocation.mockReturnValue({
16
- pathname: '/docs/pets',
17
- hash: '',
18
- state: undefined,
19
- key: '',
20
- search: '',
21
- });
22
- const item = {
23
- type: 'operation',
24
- href: '/pets',
25
- items: [],
26
- };
27
- const { result } = renderHook(() => useIsExpanded({ item, routingBasePath: mockRoutingBasePath }));
28
- expect(result.current).toBe(false);
29
- });
30
- it('should return true when current path matches item href', () => {
31
- mockUseLocation.mockReturnValue({
32
- pathname: '/docs/pets',
33
- hash: '',
34
- state: undefined,
35
- key: '',
36
- search: '',
37
- });
38
- const item = {
39
- type: 'tag',
40
- href: '/pets',
41
- items: [{ type: 'operation', href: '/pets/get', items: [] }],
42
- };
43
- const { result } = renderHook(() => useIsExpanded({ item, routingBasePath: mockRoutingBasePath }));
44
- expect(result.current).toBe(true);
45
- });
46
- it('should return true when legacy hash matches item href', () => {
47
- mockUseLocation.mockReturnValue({
48
- pathname: '/docs',
49
- hash: '#tag/pets',
50
- state: undefined,
51
- key: '',
52
- search: '',
53
- });
54
- const item = {
55
- type: 'tag',
56
- href: '/pets',
57
- items: [],
58
- };
59
- const { result } = renderHook(() => useIsExpanded({ item, routingBasePath: mockRoutingBasePath }));
60
- expect(result.current).toBe(true);
61
- });
62
- it('should handle nested items', () => {
63
- mockUseLocation.mockReturnValue({
64
- pathname: '/docs/pets/create',
65
- hash: '',
66
- state: undefined,
67
- key: '',
68
- search: '',
69
- });
70
- const item = {
71
- type: 'tag',
72
- href: '/pets',
73
- items: [
74
- {
75
- type: 'section',
76
- href: '/pets',
77
- items: [
78
- {
79
- type: 'section',
80
- href: '/pets/create',
81
- items: [],
82
- },
83
- ],
84
- },
85
- ],
86
- };
87
- const { result } = renderHook(() => useIsExpanded({ item, routingBasePath: mockRoutingBasePath }));
88
- expect(result.current).toBe(true);
89
- });
90
- it('should handle encoded URLs', () => {
91
- mockUseLocation.mockReturnValue({
92
- pathname: '/docs/user%20profile',
93
- hash: '',
94
- state: undefined,
95
- key: '',
96
- search: '',
97
- });
98
- const item = {
99
- type: 'tag',
100
- href: '/user profile',
101
- items: [],
102
- };
103
- const { result } = renderHook(() => useIsExpanded({ item, routingBasePath: mockRoutingBasePath }));
104
- expect(result.current).toBe(true);
105
- });
106
- it('should return false when no matches found', () => {
107
- mockUseLocation.mockReturnValue({
108
- pathname: '/docs/users',
109
- hash: '',
110
- state: undefined,
111
- key: '',
112
- search: '',
113
- });
114
- const item = {
115
- type: 'tag',
116
- href: '/pets',
117
- items: [{ type: 'operation', href: '/pets/list', items: [] }],
118
- };
119
- const { result } = renderHook(() => useIsExpanded({ item, routingBasePath: mockRoutingBasePath }));
120
- expect(result.current).toBe(false);
121
- });
122
- });
123
- //# sourceMappingURL=useIsExpanded.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,66 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { render, screen } from '@testing-library/react';
3
- import { Items } from '../Items.js';
4
- import { TestMemoryRouter } from '../../../testProviders.js';
5
- vi.mock('../../ContentItem', () => ({
6
- ContentItem: ({ children, item }) => (_jsxs("div", { "data-testid": `content-item-${item.id}`, children: [item.title, children] })),
7
- }));
8
- vi.mock('../VirtualList', () => ({
9
- VirtualList: ({ items }) => (_jsx("div", { "data-testid": "virtual-list", children: items.map((item) => (_jsx("div", { children: item.title }, item.id))) })),
10
- }));
11
- const mockItems = [
12
- { id: '1', title: 'Item 1', type: 'group', items: [] },
13
- { id: '2', title: 'Item 2', type: 'group', items: [] },
14
- ];
15
- const mockMixedTypeItems = Array.from({ length: 16 }, (_, i) => ({
16
- id: `mixed-${i}`,
17
- title: `Item ${i}`,
18
- type: i % 2 === 0 ? 'operation' : 'schema',
19
- items: [],
20
- }));
21
- const mockOperationItems = Array.from({ length: 16 }, (_, i) => ({
22
- id: `op-${i}`,
23
- title: `Operation ${i}`,
24
- type: 'operation',
25
- items: [],
26
- }));
27
- describe('Items', () => {
28
- const renderWithRouter = (component) => {
29
- return render(_jsx(TestMemoryRouter, { children: component }));
30
- };
31
- it('renders null when items array is empty', () => {
32
- const { container } = renderWithRouter(_jsx(Items, { items: [], routingBasePath: "/docs" }));
33
- expect(container.firstChild).toBeNull();
34
- });
35
- it('renders regular list for less than 10 items', () => {
36
- renderWithRouter(_jsx(Items, { items: mockItems, routingBasePath: "/docs" }));
37
- expect(screen.getByTestId('content-item-1')).toBeInTheDocument();
38
- expect(screen.getByTestId('content-item-2')).toBeInTheDocument();
39
- expect(screen.queryByTestId('virtual-list')).not.toBeInTheDocument();
40
- });
41
- it('renders VirtualList for more than 15 operation items', () => {
42
- renderWithRouter(_jsx(Items, { items: mockOperationItems, routingBasePath: "/docs" }));
43
- expect(screen.getByTestId('virtual-list')).toBeInTheDocument();
44
- expect(screen.queryByTestId('content-item-1')).not.toBeInTheDocument();
45
- });
46
- it('renders VirtualList for more than 15 mixed operation and schema items', () => {
47
- renderWithRouter(_jsx(Items, { items: mockMixedTypeItems, routingBasePath: "/docs" }));
48
- expect(screen.getByTestId('virtual-list')).toBeInTheDocument();
49
- expect(screen.queryByTestId('content-item-mixed-0')).not.toBeInTheDocument();
50
- });
51
- it('renders nested items correctly', () => {
52
- const nestedItems = [
53
- {
54
- id: '1',
55
- title: 'Parent',
56
- type: 'group',
57
- items: [{ id: '1-1', title: 'Child', type: 'group', items: [] }],
58
- },
59
- ];
60
- renderWithRouter(_jsx(Items, { items: nestedItems, routingBasePath: "/docs" }));
61
- expect(screen.getByTestId('content-item-1')).toBeInTheDocument();
62
- expect(screen.getByText('Parent')).toBeInTheDocument();
63
- expect(screen.getByText('Child')).toBeInTheDocument();
64
- });
65
- });
66
- //# sourceMappingURL=Items.test.js.map
@@ -1,135 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render, screen } from '@testing-library/react';
3
- import { Routes, Route } from 'react-router';
4
- import { act } from 'react';
5
- import { VirtualList } from '../VirtualList.js';
6
- import { TestMemoryRouter } from '../../../testProviders.js';
7
- const mockItems = [
8
- { href: '/item1', title: 'Item 1' },
9
- { href: '/item2', title: 'Item 2' },
10
- { href: '/item3', title: 'Item 3' },
11
- { href: '/item4', title: 'Item 4' },
12
- { href: '/item5', title: 'Item 5' },
13
- ];
14
- const renderItem = (item) => (_jsx("div", { "data-testid": item.href.replace('/', ''), children: typeof item.title === 'string'
15
- ? String(item.title)
16
- : String(item.name) }, item.href));
17
- const renderWithRouter = (initialPath, props) => {
18
- return render(_jsx(TestMemoryRouter, { initialEntries: [initialPath], children: _jsx(Routes, { children: _jsx(Route, { path: "*", element: _jsx(VirtualList, { ...props }) }) }) }));
19
- };
20
- describe('VirtualList', () => {
21
- beforeEach(() => {
22
- vi.useFakeTimers();
23
- });
24
- afterEach(() => {
25
- vi.clearAllTimers();
26
- vi.useRealTimers();
27
- });
28
- it('should render empty list when no items provided', () => {
29
- renderWithRouter('/', {
30
- items: [],
31
- renderItem,
32
- routingBasePath: '/',
33
- });
34
- expect(screen.queryByTestId(/item/)).not.toBeInTheDocument();
35
- });
36
- it('should initially render first three items when no active item', () => {
37
- renderWithRouter('/non-existing', {
38
- items: mockItems,
39
- renderItem,
40
- routingBasePath: '/',
41
- });
42
- expect(screen.getByTestId('item1')).toBeInTheDocument();
43
- expect(screen.getByTestId('item2')).toBeInTheDocument();
44
- expect(screen.getByTestId('item3')).toBeInTheDocument();
45
- expect(screen.queryByTestId('item4')).not.toBeInTheDocument();
46
- expect(screen.queryByTestId('item5')).not.toBeInTheDocument();
47
- });
48
- it('should render items around active item', () => {
49
- renderWithRouter('/item3', {
50
- items: mockItems,
51
- renderItem,
52
- routingBasePath: '/',
53
- });
54
- expect(screen.getByTestId('item2')).toBeInTheDocument();
55
- expect(screen.getByTestId('item3')).toBeInTheDocument();
56
- expect(screen.getByTestId('item4')).toBeInTheDocument();
57
- });
58
- it('should handle first item selection', () => {
59
- renderWithRouter('/item1', {
60
- items: mockItems,
61
- renderItem,
62
- routingBasePath: '/',
63
- });
64
- expect(screen.getByTestId('item1')).toBeInTheDocument();
65
- expect(screen.getByTestId('item2')).toBeInTheDocument();
66
- expect(screen.queryByTestId('item3')).toBeInTheDocument();
67
- });
68
- it('should handle last item selection', () => {
69
- renderWithRouter('/item5', {
70
- items: mockItems,
71
- renderItem,
72
- routingBasePath: '/',
73
- });
74
- expect(screen.queryByTestId('item1')).not.toBeInTheDocument();
75
- expect(screen.queryByTestId('item2')).not.toBeInTheDocument();
76
- expect(screen.queryByTestId('item3')).not.toBeInTheDocument();
77
- expect(screen.getByTestId('item4')).toBeInTheDocument();
78
- expect(screen.getByTestId('item5')).toBeInTheDocument();
79
- });
80
- it('should eventually render all items after timeout', () => {
81
- renderWithRouter('/item3', {
82
- items: mockItems,
83
- renderItem,
84
- routingBasePath: '/',
85
- });
86
- expect(screen.getByTestId('item2')).toBeInTheDocument();
87
- expect(screen.getByTestId('item3')).toBeInTheDocument();
88
- expect(screen.getByTestId('item4')).toBeInTheDocument();
89
- act(() => {
90
- vi.advanceTimersByTime(1000);
91
- });
92
- expect(screen.getByTestId('item1')).toBeInTheDocument();
93
- expect(screen.getByTestId('item2')).toBeInTheDocument();
94
- expect(screen.getByTestId('item3')).toBeInTheDocument();
95
- expect(screen.getByTestId('item4')).toBeInTheDocument();
96
- expect(screen.getByTestId('item5')).toBeInTheDocument();
97
- });
98
- it('should handle custom routing base path', () => {
99
- renderWithRouter('/docs/item1', {
100
- items: mockItems,
101
- renderItem,
102
- routingBasePath: '/docs',
103
- });
104
- expect(screen.getByTestId('item1')).toBeInTheDocument();
105
- expect(screen.getByTestId('item2')).toBeInTheDocument();
106
- expect(screen.queryByTestId('item3')).toBeInTheDocument();
107
- });
108
- it('should not re-render if all items are already visible', () => {
109
- const { rerender } = renderWithRouter('/item1', {
110
- items: mockItems,
111
- renderItem,
112
- routingBasePath: '/',
113
- });
114
- act(() => {
115
- vi.advanceTimersByTime(1000);
116
- });
117
- const initialRenderCount = screen.getAllByTestId(/item/).length;
118
- rerender(_jsx(TestMemoryRouter, { initialEntries: ['/item3'], children: _jsx(Routes, { children: _jsx(Route, { path: "*", element: _jsx(VirtualList, { items: mockItems, renderItem: renderItem, routingBasePath: "/" }) }) }) }));
119
- expect(screen.getAllByTestId(/item/).length).toBe(initialRenderCount);
120
- });
121
- it('should cleanup on unmount', () => {
122
- const { unmount } = renderWithRouter('/item1', {
123
- items: mockItems,
124
- renderItem,
125
- routingBasePath: '/',
126
- });
127
- unmount();
128
- expect(() => {
129
- act(() => {
130
- vi.runAllTimers();
131
- });
132
- }).not.toThrow();
133
- });
134
- });
135
- //# sourceMappingURL=VirtualList.test.js.map
@@ -1,63 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { render } from '@testing-library/react';
3
- import * as Jotai from 'jotai';
4
- import { normalizeOptions, OpenAPIParser } from '../../../services/index.js';
5
- import { getSchema } from '../../../models/index.js';
6
- import { Schema } from '../../Schema/index.js';
7
- import * as simpleDiscriminatorFixture from './fixtures/simple-discriminator.json';
8
- import * as discriminatorWithDefaultFixture from '../../../models/__tests__/fixtures/discriminator-with-default-mapping.json';
9
- import { TestBrowserRouter } from '../../../testProviders.js';
10
- const options = normalizeOptions({});
11
- vi.mock('jotai', async () => ({
12
- ...(await vi.importActual('jotai')),
13
- useAtomValue: vi.fn(),
14
- }));
15
- describe('DiscriminatorDropdown', () => {
16
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue(options);
17
- const parser = new OpenAPIParser(simpleDiscriminatorFixture, undefined, options);
18
- const schema = getSchema({
19
- parser,
20
- schemaOrRef: { $ref: '#/components/schemas/Pet' },
21
- pointer: '#/components/schemas/Pet',
22
- options,
23
- deps: { operation: { pointer: 'defaultPointer' } },
24
- });
25
- describe('discriminator', () => {
26
- vi.spyOn(Jotai, 'useAtomValue').mockReturnValue({
27
- activeOneOf: {
28
- '#/components/schemas/Pet': 0,
29
- },
30
- });
31
- it('should correctly render SchemaView', () => {
32
- const { getByText } = render(_jsx(Schema, { schema: schema }), {
33
- wrapper: TestBrowserRouter,
34
- });
35
- expect(getByText('type')).toBeInTheDocument();
36
- expect(getByText('C̵a̵t̵ (deprecated)')).toBeInTheDocument();
37
- });
38
- });
39
- describe('discriminator with defaultMapping', () => {
40
- const parserWithDefault = new OpenAPIParser(discriminatorWithDefaultFixture, undefined, options);
41
- const schemaWithDefault = getSchema({
42
- parser: parserWithDefault,
43
- schemaOrRef: { $ref: '#/components/schemas/Pet' },
44
- pointer: '#/components/schemas/Pet',
45
- options,
46
- deps: { operation: { pointer: 'defaultPointer' } },
47
- });
48
- it('schema has correct oneOf structure with defaultMapping', () => {
49
- expect(schemaWithDefault.oneOf).toHaveLength(3);
50
- expect(schemaWithDefault.oneOf?.[0].title).toBe('cat');
51
- expect(schemaWithDefault.oneOf?.[0].isDefaultMapping).toBe(false);
52
- expect(schemaWithDefault.oneOf?.[1].title).toBe('dog');
53
- expect(schemaWithDefault.oneOf?.[1].isDefaultMapping).toBe(false);
54
- expect(schemaWithDefault.oneOf?.[2].title).toBe('Default mapping');
55
- expect(schemaWithDefault.oneOf?.[2].isDefaultMapping).toBe(true);
56
- });
57
- it('finds correct defaultMappingIdx', () => {
58
- const defaultMappingIdx = schemaWithDefault.oneOf?.findIndex((subSchema) => subSchema.isDefaultMapping);
59
- expect(defaultMappingIdx).toBe(2);
60
- });
61
- });
62
- });
63
- //# sourceMappingURL=DiscriminatorDropdown.test.js.map