@redocly/openapi-docs 3.12.0 → 3.12.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 (384) hide show
  1. package/dist/redocly-openapi-docs.min.js +753 -750
  2. package/lib/components/ApiInfo/ApiInfo.js +29 -1
  3. package/lib/components/ApiInfo/Metadata.js +29 -1
  4. package/lib/components/ApiInfo/index.js +2 -1
  5. package/lib/components/ApiInfo/styled.js +16 -8
  6. package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
  7. package/lib/components/CallbackSamples/index.js +2 -1
  8. package/lib/components/Callbacks/CallbackDetails.js +17 -3
  9. package/lib/components/Callbacks/CallbackOperation.js +24 -3
  10. package/lib/components/Callbacks/CallbackSummary.js +19 -3
  11. package/lib/components/Callbacks/CallbacksList.js +16 -1
  12. package/lib/components/Callbacks/index.js +4 -1
  13. package/lib/components/Callbacks/styled.js +6 -3
  14. package/lib/components/Content/Content.js +10 -1
  15. package/lib/components/Content/index.js +2 -1
  16. package/lib/components/Content/useAutoScroll.js +50 -1
  17. package/lib/components/ContentItem/ContentItem.js +31 -1
  18. package/lib/components/ContentItem/index.js +2 -1
  19. package/lib/components/ContentItem/useIsExpanded.js +33 -1
  20. package/lib/components/ContentItems/ContentItems.js +19 -1
  21. package/lib/components/ContentItems/Items.js +13 -1
  22. package/lib/components/ContentItems/VirtualList.js +35 -1
  23. package/lib/components/ContentItems/helpers.js +49 -1
  24. package/lib/components/ContentItems/index.js +2 -1
  25. package/lib/components/ContentItems/useScrollOnRender.js +26 -1
  26. package/lib/components/Discriminator/Discriminator.js +27 -2
  27. package/lib/components/Discriminator/index.js +2 -1
  28. package/lib/components/Download/DownloadSpecification.js +46 -4
  29. package/lib/components/Download/index.js +2 -1
  30. package/lib/components/Download/types.js +2 -0
  31. package/lib/components/Download/useDownloadInfo.js +42 -1
  32. package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
  33. package/lib/components/ErrorBoundary/index.js +2 -1
  34. package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
  35. package/lib/components/ExpandAllButton/index.js +2 -1
  36. package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
  37. package/lib/components/ExternalDocumentation/index.js +2 -1
  38. package/lib/components/Language/LanguageDropdown.js +21 -1
  39. package/lib/components/Language/LanguageItem.js +33 -1
  40. package/lib/components/Language/LanguageList.js +93 -1
  41. package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
  42. package/lib/components/Language/constants.js +3 -1
  43. package/lib/components/Language/index.js +4 -1
  44. package/lib/components/Language/styled.js +29 -15
  45. package/lib/components/Markdown/Markdown.js +64 -1
  46. package/lib/components/Markdown/index.js +3 -1
  47. package/lib/components/Markdown/types.js +2 -0
  48. package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
  49. package/lib/components/MediaTypeSwitch/index.js +2 -1
  50. package/lib/components/OperationItem/Description.js +9 -1
  51. package/lib/components/OperationItem/OperationItem.js +70 -5
  52. package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
  53. package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
  54. package/lib/components/OperationItem/index.js +2 -1
  55. package/lib/components/OperationItem/types.js +2 -0
  56. package/lib/components/Overlay.js +48 -3
  57. package/lib/components/Overview/Overview.js +20 -1
  58. package/lib/components/Overview/index.js +2 -1
  59. package/lib/components/PageFooter/PageFooter.js +19 -1
  60. package/lib/components/PageFooter/index.js +2 -1
  61. package/lib/components/Panel/ResponsePanel.js +12 -6
  62. package/lib/components/Panel/Trigger.js +4 -2
  63. package/lib/components/Panel/index.js +3 -1
  64. package/lib/components/PanelItem/PanelItem.js +6 -1
  65. package/lib/components/PanelItem/index.js +3 -1
  66. package/lib/components/PanelItem/styled.js +20 -10
  67. package/lib/components/PayloadSamples/Example.js +6 -1
  68. package/lib/components/PayloadSamples/ExampleValue.js +30 -1
  69. package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
  70. package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
  71. package/lib/components/PayloadSamples/index.js +7 -1
  72. package/lib/components/PayloadSamples/styled.js +9 -4
  73. package/lib/components/PayloadSamples/types.js +2 -0
  74. package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
  75. package/lib/components/PropertyDetails/EnumValues.js +37 -1
  76. package/lib/components/PropertyDetails/Examples.js +26 -1
  77. package/lib/components/PropertyDetails/Extensions.js +17 -2
  78. package/lib/components/PropertyDetails/FieldDetail.js +15 -2
  79. package/lib/components/PropertyDetails/FieldDetails.js +51 -6
  80. package/lib/components/PropertyDetails/Pattern.js +21 -1
  81. package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
  82. package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
  83. package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
  84. package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
  85. package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
  86. package/lib/components/PropertyDetails/index.js +4 -1
  87. package/lib/components/PropertyDetails/styled.js +15 -7
  88. package/lib/components/PropertyDetails/types.js +2 -0
  89. package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
  90. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
  91. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
  92. package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
  93. package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
  94. package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
  95. package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
  96. package/lib/components/RenderHook/RenderHook.js +17 -1
  97. package/lib/components/RenderHook/index.js +2 -1
  98. package/lib/components/Replay/EmbeddedReplay.js +41 -3
  99. package/lib/components/Replay/Replay.js +99 -1
  100. package/lib/components/Replay/index.js +3 -1
  101. package/lib/components/Replay/utils.js +208 -1
  102. package/lib/components/Request/RequestDetails.js +33 -2
  103. package/lib/components/Request/types.js +2 -0
  104. package/lib/components/RequestParameters/Body.js +8 -1
  105. package/lib/components/RequestParameters/ParametersGroup.js +19 -4
  106. package/lib/components/RequestParameters/RequestParameters.js +40 -1
  107. package/lib/components/RequestParameters/index.js +4 -1
  108. package/lib/components/RequestSamples/CodeSample.js +55 -2
  109. package/lib/components/RequestSamples/Example.js +37 -1
  110. package/lib/components/RequestSamples/RequestSamples.js +89 -5
  111. package/lib/components/RequestSamples/index.js +3 -1
  112. package/lib/components/RequestSamples/useCodeSamples.js +92 -1
  113. package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
  114. package/lib/components/ResponseSamples/Summary.js +9 -1
  115. package/lib/components/ResponseSamples/index.js +2 -1
  116. package/lib/components/Responses/OperationResponseList.js +42 -2
  117. package/lib/components/Responses/ResponseDetails.js +18 -1
  118. package/lib/components/Responses/ResponseHeaders.js +15 -1
  119. package/lib/components/Responses/index.js +6 -1
  120. package/lib/components/Responses/styled.js +14 -6
  121. package/lib/components/Responses/types.js +2 -0
  122. package/lib/components/RightPanel/RightPanel.js +21 -1
  123. package/lib/components/RightPanel/index.js +2 -1
  124. package/lib/components/Samples/ExampleSwitch.js +33 -1
  125. package/lib/components/Samples/index.js +3 -1
  126. package/lib/components/Samples/use-example-key.js +12 -1
  127. package/lib/components/Schema/ArraySchema.js +45 -1
  128. package/lib/components/Schema/ObjectSchema.js +29 -1
  129. package/lib/components/Schema/OneOfSchema.js +47 -3
  130. package/lib/components/Schema/RecursiveSchema.js +10 -1
  131. package/lib/components/Schema/Schema.js +63 -2
  132. package/lib/components/Schema/SubSchema.js +20 -1
  133. package/lib/components/Schema/helpers.js +16 -1
  134. package/lib/components/Schema/index.js +5 -1
  135. package/lib/components/Schema/types.js +2 -0
  136. package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
  137. package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
  138. package/lib/components/SchemaDefinition/index.js +2 -1
  139. package/lib/components/SectionContent/SectionContent.js +49 -6
  140. package/lib/components/SectionContent/index.js +2 -1
  141. package/lib/components/SectionItem/SectionItem.js +14 -1
  142. package/lib/components/SectionItem/index.js +2 -1
  143. package/lib/components/Security/Divider.js +9 -2
  144. package/lib/components/Security/OAuthFlow.js +11 -1
  145. package/lib/components/Security/OAuthScopes.js +59 -9
  146. package/lib/components/Security/Security.js +15 -1
  147. package/lib/components/Security/SecurityButton.js +31 -7
  148. package/lib/components/Security/SecurityFlow.js +28 -4
  149. package/lib/components/Security/SecurityModal.js +34 -5
  150. package/lib/components/Security/SecuritySchemeItem.js +15 -4
  151. package/lib/components/Security/helper.js +16 -1
  152. package/lib/components/Security/index.js +11 -1
  153. package/lib/components/Security/styled.js +6 -3
  154. package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
  155. package/lib/components/SelectOrLabel/index.js +2 -1
  156. package/lib/components/ServerList/ServerList.js +36 -10
  157. package/lib/components/ServerList/index.js +2 -1
  158. package/lib/components/ServerList/types.js +2 -0
  159. package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
  160. package/lib/components/ServerListDropdown/index.js +2 -1
  161. package/lib/components/ServerListDropdown/styled.js +15 -6
  162. package/lib/components/SideMenu/SideMenu.js +13 -2
  163. package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
  164. package/lib/components/SideMenu/index.js +2 -1
  165. package/lib/components/SideMenu/types.js +2 -0
  166. package/lib/components/StickySidebar/SidebarActions.js +14 -2
  167. package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
  168. package/lib/components/StickySidebar/index.js +2 -1
  169. package/lib/components/Tabs/Tabs.js +16 -5
  170. package/lib/components/Tabs/index.js +3 -1
  171. package/lib/components/Tabs/useTabsState.js +22 -1
  172. package/lib/components/TagItem/OperationNavigationItems.js +18 -4
  173. package/lib/components/TagItem/OperationsNavigation.js +46 -2
  174. package/lib/components/TagItem/TagItem.js +40 -7
  175. package/lib/components/TagItem/index.js +2 -1
  176. package/lib/components/TagItem/styled.js +5 -2
  177. package/lib/components/TagItem/types.js +2 -0
  178. package/lib/components/ViewNested/ViewNested.js +42 -9
  179. package/lib/components/ViewNested/index.js +2 -1
  180. package/lib/components/common/Badges.js +21 -5
  181. package/lib/components/common/BodyContent/BodyContent.js +31 -4
  182. package/lib/components/common/BodyContent/index.js +2 -1
  183. package/lib/components/common/ClearButton/ClearButton.js +5 -1
  184. package/lib/components/common/ClearButton/index.js +3 -1
  185. package/lib/components/common/ClearButton/styled.js +5 -2
  186. package/lib/components/common/ClearButton/types.js +2 -0
  187. package/lib/components/common/CodeBlockPanel.js +7 -3
  188. package/lib/components/common/ConstraintsView.js +14 -2
  189. package/lib/components/common/Dropdown/Dropdown.js +22 -4
  190. package/lib/components/common/Dropdown/index.js +2 -1
  191. package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
  192. package/lib/components/common/ExpandableExample/index.js +2 -1
  193. package/lib/components/common/Extensions.js +17 -2
  194. package/lib/components/common/Fields/fields-layout.js +76 -51
  195. package/lib/components/common/Fields/fields.js +39 -17
  196. package/lib/components/common/Fields/index.js +3 -1
  197. package/lib/components/common/LinkToField.js +33 -6
  198. package/lib/components/common/OperationItemTitle.js +12 -6
  199. package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
  200. package/lib/components/common/SchemaSelection/index.js +2 -1
  201. package/lib/components/common/Select/Select.js +21 -1
  202. package/lib/components/common/Select/index.js +3 -1
  203. package/lib/components/common/Select/styled.js +17 -9
  204. package/lib/components/common/Select/types.js +2 -0
  205. package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
  206. package/lib/components/common/Skeleton/Skeleton.js +15 -5
  207. package/lib/components/common/Skeleton/index.js +3 -1
  208. package/lib/components/common/headers.js +4 -2
  209. package/lib/components/common/index.js +14 -1
  210. package/lib/components/common/linkify.js +28 -4
  211. package/lib/components/common/mixins.js +4 -2
  212. package/lib/components/common/panels.js +52 -29
  213. package/lib/components/common/schema.js +16 -8
  214. package/lib/components/common/styled.js +15 -7
  215. package/lib/components/index.js +25 -1
  216. package/lib/components/pluggable/RedocExample.js +20 -1
  217. package/lib/components/pluggable/RedocSchema.js +22 -1
  218. package/lib/components/pluggable/index.js +3 -1
  219. package/lib/components/pluggable/styled.components.js +9 -4
  220. package/lib/constants.js +30 -1
  221. package/lib/empty.js +7 -1
  222. package/lib/events/codeSampleCopy.js +19 -1
  223. package/lib/events/creator.js +5 -1
  224. package/lib/events/index.js +8 -1
  225. package/lib/events/languageSwitch.js +18 -1
  226. package/lib/events/panelToggle.js +16 -1
  227. package/lib/events/serverSwitch.js +13 -1
  228. package/lib/events/tryItOpen.js +12 -1
  229. package/lib/events/tryItSent.js +12 -1
  230. package/lib/events/types.js +11 -1
  231. package/lib/hoc/types.js +2 -0
  232. package/lib/hoc/utils.js +4 -1
  233. package/lib/hoc/withRouter.js +17 -1
  234. package/lib/hoc/withStore.js +28 -1
  235. package/lib/hooks/index.js +9 -1
  236. package/lib/hooks/useActivateExample.js +35 -1
  237. package/lib/hooks/useActiveWithFallback.js +12 -1
  238. package/lib/hooks/useContentItems.js +10 -1
  239. package/lib/hooks/useLicense.js +17 -1
  240. package/lib/hooks/usePerformanceMetrics.js +26 -1
  241. package/lib/hooks/useRouter.js +17 -1
  242. package/lib/hooks/useTelemetry.js +5 -1
  243. package/lib/hooks/useTranslate.js +6 -1
  244. package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
  245. package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
  246. package/lib/icons/CSharpIcon/index.js +2 -1
  247. package/lib/icons/CurlIcon/CurlIcon.js +8 -2
  248. package/lib/icons/CurlIcon/index.js +2 -1
  249. package/lib/icons/GOIcon/GOIcon.js +7 -1
  250. package/lib/icons/GOIcon/index.js +2 -1
  251. package/lib/icons/JavaIcon/JavaIcon.js +7 -1
  252. package/lib/icons/JavaIcon/index.js +2 -1
  253. package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
  254. package/lib/icons/JavaScriptIcon/index.js +2 -1
  255. package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
  256. package/lib/icons/NodeJSIcon/index.js +2 -1
  257. package/lib/icons/PHPIcon/PHPIcon.js +7 -1
  258. package/lib/icons/PHPIcon/index.js +2 -1
  259. package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
  260. package/lib/icons/PayloadIcon/index.js +2 -1
  261. package/lib/icons/PythonIcon/PythonIcon.js +7 -1
  262. package/lib/icons/PythonIcon/index.js +2 -1
  263. package/lib/icons/RIcon/RIcon.js +7 -1
  264. package/lib/icons/RIcon/index.js +2 -1
  265. package/lib/icons/RubyIcon/RubyIcon.js +7 -1
  266. package/lib/icons/RubyIcon/index.js +2 -1
  267. package/lib/index.js +49 -1
  268. package/lib/jotai/app.js +113 -1
  269. package/lib/jotai/operation.js +28 -1
  270. package/lib/jotai/replay.js +5 -1
  271. package/lib/jotai/store.js +8 -1
  272. package/lib/jotai/use-write-atom.js +9 -1
  273. package/lib/models/callback.js +28 -1
  274. package/lib/models/code-sample-options.js +2 -0
  275. package/lib/models/example.js +17 -1
  276. package/lib/models/field.js +109 -1
  277. package/lib/models/group.js +38 -1
  278. package/lib/models/index.js +14 -1
  279. package/lib/models/mediaContent.js +26 -1
  280. package/lib/models/mediaType.js +153 -1
  281. package/lib/models/operation.js +166 -1
  282. package/lib/models/request.js +25 -1
  283. package/lib/models/response.js +46 -1
  284. package/lib/models/schema.js +474 -2
  285. package/lib/models/security.js +84 -1
  286. package/lib/models/tab.js +2 -0
  287. package/lib/models/types.js +2 -0
  288. package/lib/services/OpenAPIParser.js +321 -1
  289. package/lib/services/check.js +104 -1
  290. package/lib/services/code-samples/constants.js +16 -1
  291. package/lib/services/code-samples/generator.js +540 -1
  292. package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
  293. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
  294. package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
  295. package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
  296. package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
  297. package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
  298. package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
  299. package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
  300. package/lib/services/code-samples/httpsnippet/index.js +166 -1
  301. package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
  302. package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
  303. package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
  304. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
  305. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
  306. package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
  307. package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
  308. package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
  309. package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
  310. package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
  311. package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
  312. package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
  313. package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
  314. package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
  315. package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
  316. package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
  317. package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
  318. package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
  319. package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
  320. package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
  321. package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
  322. package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
  323. package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
  324. package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
  325. package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
  326. package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
  327. package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
  328. package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
  329. package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
  330. package/lib/services/code-samples/index.js +3 -1
  331. package/lib/services/code-samples/types.js +2 -0
  332. package/lib/services/config-options/helpers.js +49 -1
  333. package/lib/services/config-options/index.js +3 -1
  334. package/lib/services/config-options/normalizeOptions.js +83 -1
  335. package/lib/services/config-options/types.js +2 -0
  336. package/lib/services/history/helpers.js +63 -1
  337. package/lib/services/history/index.js +2 -1
  338. package/lib/services/index.js +9 -1
  339. package/lib/services/menu/builder.js +47 -1
  340. package/lib/services/menu/index.js +2 -1
  341. package/lib/services/menu/markdown.js +93 -1
  342. package/lib/services/menu/operation.js +50 -1
  343. package/lib/services/menu/tags.js +166 -1
  344. package/lib/services/types.js +2 -0
  345. package/lib/services/utils.js +83 -1
  346. package/lib/standalone.js +68 -1
  347. package/lib/styled-components.js +6 -1
  348. package/lib/types/app.js +2 -0
  349. package/lib/types/index.js +4 -1
  350. package/lib/types/open-api.js +2 -0
  351. package/lib/types/security.js +2 -0
  352. package/lib/utils/JsonPointer.js +84 -1
  353. package/lib/utils/areArraysEqual.js +4 -1
  354. package/lib/utils/argValuesHelpers.js +35 -1
  355. package/lib/utils/compose.js +2 -1
  356. package/lib/utils/configure-helpers.js +223 -1
  357. package/lib/utils/convertSwagger2OpenAPI.js +14 -1
  358. package/lib/utils/cookies.js +73 -1
  359. package/lib/utils/debounce.js +22 -1
  360. package/lib/utils/debug.js +11 -1
  361. package/lib/utils/dom.js +65 -1
  362. package/lib/utils/environments.js +13 -1
  363. package/lib/utils/helpers.js +222 -12
  364. package/lib/utils/index.js +25 -1
  365. package/lib/utils/isMobile.js +13 -1
  366. package/lib/utils/loadAndBundleSpec.js +32 -1
  367. package/lib/utils/local-storage.js +12 -1
  368. package/lib/utils/object.js +31 -1
  369. package/lib/utils/openapi.js +592 -1
  370. package/lib/utils/parameters.js +13 -1
  371. package/lib/utils/path.js +22 -1
  372. package/lib/utils/queryString.js +60 -1
  373. package/lib/utils/replaceVariables.js +14 -1
  374. package/lib/utils/saveTextBeforeHeading.js +35 -1
  375. package/lib/utils/security-details.js +49 -1
  376. package/lib/utils/session-storage.js +12 -1
  377. package/lib/utils/simplifyAstStructure.js +22 -1
  378. package/lib/utils/sort.js +21 -1
  379. package/lib/utils/string.js +65 -1
  380. package/lib/utils/telemetry.js +7 -1
  381. package/lib/utils/test-utils.js +26 -1
  382. package/lib/utils/theme-helpers.js +24 -3
  383. package/lib/utils/url.js +38 -1
  384. package/package.json +4 -4
@@ -1 +1,92 @@
1
- import{useAtomValue as u}from"jotai";import{getCodeSample as x}from"../../services/index.js";import{globalStoreAtom as D}from"../../jotai/store.js";import{operationStore as K}from"../../jotai/operation.js";import{environmentAtom as k,getLangKey as f,languageAtom as E,activeMimeNameAtom as j}from"../../jotai/app.js";import{useTranslate as N}from"../../hooks/index.js";function G({payload:t,isWebhook:s,definitionSamples:l,pointer:a,envVariables:r}){const{parser:m,options:{codeSamples:o,generatedSamplesMaxDepth:c}}=u(D),i=u(j),g=u(K(a)),{languages:d}=u(E),[S]=u(k),v=N(),p=new Map(d?.map(({key:e,order:n})=>[e,n])),M=l.filter(e=>p.has(f(e))),y=P(M,r,S),b=new Set(y.map(f));let C=[];if(!s){const e=o.languages?.filter(({lang:n,label:w})=>n!=="Payload"&&!b.has(f({lang:n,label:w})))||[];C=O(e,o,m.definition,c,g,S,v,i)}const L=[...y,...C],A=d?.find(({lang:e})=>e===t?.lang)?.title,h=t&&f({label:A,lang:t.lang});return t&&h&&p.has(h)&&L.push({...t,label:A,order:p.get(h)}),{samples:L.map(e=>{const n=e.label??e.lang;return{key:f(e),title:n,order:typeof p.get(n.toLowerCase())=="number"?p.get(n.toLowerCase()):9999,...e}}).sort((e,n)=>e.order-n.order)}}function O(t,{skipOptionalParameters:s,withOAuth2Call:l},a,r,m,o,c,i){return t.map(({lang:g,label:d,options:S})=>({lang:g,label:d,get:v=>x({...v,lang:g,options:{...S,skipOptionalParameters:s,withOAuth2Call:l,spec:a,generatedPayloadSamplesMaxDepth:r,store:m,activeMimeName:i},environment:o,translate:c})}))}function P(t,s,l){if(!s||!t.length)return t;const a=l?.server;let r={...s.values||{}};return a&&s.serverValues?.[a]&&(r={...r,...s.serverValues[a]}),Object.keys(r).length===0?t:t.map(m=>{const o={...m};return"source"in o&&typeof o.source=="string"&&(o.source=o.source.replace(/\{\{([^}]+)\}\}/g,(c,i)=>r[i]!==void 0?r[i]:c)),o})}export{G as useCodeSamples};
1
+ import { useAtomValue } from 'jotai';
2
+ import { getCodeSample } from '../../services/index.js';
3
+ import { globalStoreAtom } from '../../jotai/store.js';
4
+ import { operationStore } from '../../jotai/operation.js';
5
+ import { environmentAtom, getLangKey, languageAtom, activeMimeNameAtom } from '../../jotai/app.js';
6
+ import { useTranslate } from '../../hooks/index.js';
7
+ export function useCodeSamples({ payload, isWebhook, definitionSamples, pointer, envVariables, }) {
8
+ const { parser, options: { codeSamples, generatedSamplesMaxDepth }, } = useAtomValue(globalStoreAtom);
9
+ const activeMimeName = useAtomValue(activeMimeNameAtom);
10
+ const operationState = useAtomValue(operationStore(pointer));
11
+ const { languages } = useAtomValue(languageAtom);
12
+ const [environment] = useAtomValue(environmentAtom);
13
+ const translate = useTranslate();
14
+ const orderMap = new Map(languages?.map(({ key, order }) => [key, order]));
15
+ const filteredDefinitionSamples = definitionSamples.filter((item) => orderMap.has(getLangKey(item)));
16
+ const envDefinitionSamples = applyEnvironments(filteredDefinitionSamples, envVariables, environment);
17
+ const definitionExamplesKeys = new Set(envDefinitionSamples.map(getLangKey));
18
+ let generatedSamples = [];
19
+ if (!isWebhook) {
20
+ const generateLanguages = codeSamples.languages?.filter(({ lang, label }) => lang !== 'Payload' && !definitionExamplesKeys.has(getLangKey({ lang, label }))) || [];
21
+ generatedSamples = createCodeSamples(generateLanguages, codeSamples, parser.definition, generatedSamplesMaxDepth, operationState, environment, translate, activeMimeName);
22
+ }
23
+ const allCodeSamples = [...envDefinitionSamples, ...generatedSamples];
24
+ const payloadLabel = languages?.find(({ lang }) => lang === payload?.lang)?.title;
25
+ const payloadLabelKey = payload && getLangKey({ label: payloadLabel, lang: payload.lang });
26
+ if (payload && payloadLabelKey && orderMap.has(payloadLabelKey)) {
27
+ allCodeSamples.push({
28
+ ...payload,
29
+ label: payloadLabel,
30
+ order: orderMap.get(payloadLabelKey),
31
+ });
32
+ }
33
+ // Adding new properties for UI purposes and sort samples
34
+ const samples = allCodeSamples
35
+ .map((sample) => {
36
+ const title = sample.label ?? sample.lang;
37
+ return {
38
+ key: getLangKey(sample),
39
+ title,
40
+ order: typeof orderMap.get(title.toLowerCase()) === 'number'
41
+ ? orderMap.get(title.toLowerCase())
42
+ : 9999,
43
+ ...sample,
44
+ };
45
+ })
46
+ .sort((a, b) => a.order - b.order);
47
+ return { samples };
48
+ }
49
+ function createCodeSamples(languages, { skipOptionalParameters, withOAuth2Call }, spec, generatedPayloadSamplesMaxDepth, store, environment, translate, activeMimeName) {
50
+ return languages.map(({ lang, label, options }) => {
51
+ return {
52
+ lang,
53
+ label,
54
+ get: (source) => getCodeSample({
55
+ ...source,
56
+ lang,
57
+ options: {
58
+ ...options,
59
+ skipOptionalParameters,
60
+ withOAuth2Call,
61
+ spec,
62
+ generatedPayloadSamplesMaxDepth,
63
+ store,
64
+ activeMimeName,
65
+ },
66
+ environment,
67
+ translate,
68
+ }),
69
+ };
70
+ });
71
+ }
72
+ function applyEnvironments(samples, envVariables, currentEnvironment) {
73
+ if (!envVariables || !samples.length)
74
+ return samples;
75
+ const serverUrl = currentEnvironment?.server;
76
+ let envValues = { ...(envVariables.values || {}) };
77
+ if (serverUrl && envVariables.serverValues?.[serverUrl]) {
78
+ envValues = { ...envValues, ...envVariables.serverValues[serverUrl] };
79
+ }
80
+ if (Object.keys(envValues).length === 0)
81
+ return samples;
82
+ return samples.map((sample) => {
83
+ const clonedSample = { ...sample };
84
+ if ('source' in clonedSample && typeof clonedSample.source === 'string') {
85
+ clonedSample.source = clonedSample.source.replace(/\{\{([^}]+)\}\}/g, (match, variableName) => {
86
+ return envValues[variableName] !== undefined ? envValues[variableName] : match; // Keep original if no replacement found
87
+ });
88
+ }
89
+ return clonedSample;
90
+ });
91
+ }
92
+ //# sourceMappingURL=useCodeSamples.js.map
@@ -1 +1,47 @@
1
- import{jsx as t}from"react/jsx-runtime";import{memo as b,useCallback as i}from"react";import{useAtomValue as n}from"jotai";import{PayloadSamples as h,StyledCodeBlock as v}from"../PayloadSamples/index.js";import{createCodeSampleCopyEvent as k}from"../../events/index.js";import{globalOptionsAtom as T}from"../../jotai/store.js";import{Summary as g}from"./Summary.js";import{Tabs as x}from"../Tabs/index.js";import{CodeBlockPanel as N}from"../common/index.js";import{useTelemetry as _,useTranslate as A}from"../../hooks/index.js";import{activeMimeNameAtom as E}from"../../jotai/app.js";import{operationStore as P}from"../../jotai/operation.js";function R({operation:o,activeResponseTab:d,onTabChange:y,onPanelToggle:a}){const m=_(),{events:p}=n(T),f=A(),u=o.responses.filter(e=>e.content?.hasSample??!1),s=o.responses.map(({code:e})=>({key:e,title:e})),r=s?.find(({key:e})=>e===d)||s?.[0],l=n(E),{activeExampleName:c}=n(P(o.pointer)),C=i(()=>{m.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{snippetType:"response"}});const e=k({operation:o,type:"response",activeMimeName:l,activeExampleName:c});p?.codeSamplesCopy?.(e)},[m,o,p,l,c]),S=i(e=>{a?.(e,"response-samples")},[a]);return u.length?t(N,{className:"panel-response-samples",header:()=>t(g,{tabs:t(x,{tabs:s,activeTab:r,onChange:e=>y(e.key)})}),isExpandable:!1,children:o.responses.map(e=>e.code===r.key?t("div",{children:e?.content?.hasSample?t(h,{content:e.content,onCopyClick:C,onPanelToggle:S}):t(v,{source:f("openapi.noResponseContent","No content")})},e.code):null)}):null}const J=b(R);export{J as ResponseSamples};
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo, useCallback } from 'react';
3
+ import { useAtomValue } from 'jotai';
4
+ import { PayloadSamples, StyledCodeBlock } from '../PayloadSamples/index.js';
5
+ import { createCodeSampleCopyEvent } from '../../events/index.js';
6
+ import { globalOptionsAtom } from '../../jotai/store.js';
7
+ import { Summary } from './Summary.js';
8
+ import { Tabs } from '../Tabs/index.js';
9
+ import { CodeBlockPanel } from '../common/index.js';
10
+ import { useTelemetry, useTranslate } from '../../hooks/index.js';
11
+ import { activeMimeNameAtom } from '../../jotai/app.js';
12
+ import { operationStore } from '../../jotai/operation.js';
13
+ function ResponseSamplesComponent({ operation, activeResponseTab, onTabChange, onPanelToggle, }) {
14
+ const telemetry = useTelemetry();
15
+ const { events } = useAtomValue(globalOptionsAtom);
16
+ const translate = useTranslate();
17
+ const responses = operation.responses.filter((response) => response.content?.hasSample ?? false);
18
+ const tabs = operation.responses.map(({ code }) => ({ key: code, title: code }));
19
+ const activeTab = tabs?.find(({ key }) => key === activeResponseTab) || tabs?.[0];
20
+ const activeMimeName = useAtomValue(activeMimeNameAtom);
21
+ const { activeExampleName } = useAtomValue(operationStore(operation.pointer));
22
+ const handleCodeSampleCopy = useCallback(() => {
23
+ telemetry.send({
24
+ type: 'openapi_docs.copy_code_snippet.clicked',
25
+ payload: { snippetType: 'response' },
26
+ });
27
+ const event = createCodeSampleCopyEvent({
28
+ operation,
29
+ type: 'response',
30
+ activeMimeName,
31
+ activeExampleName,
32
+ });
33
+ events?.codeSamplesCopy?.(event);
34
+ }, [telemetry, operation, events, activeMimeName, activeExampleName]);
35
+ const handlePanelToggle = useCallback((isExpanded) => {
36
+ onPanelToggle?.(isExpanded, 'response-samples');
37
+ }, [onPanelToggle]);
38
+ if (!responses.length) {
39
+ return null;
40
+ }
41
+ const renderSummary = () => {
42
+ return (_jsx(Summary, { tabs: _jsx(Tabs, { tabs: tabs, activeTab: activeTab, onChange: (tab) => onTabChange(tab.key) }) }));
43
+ };
44
+ return (_jsx(CodeBlockPanel, { className: "panel-response-samples", header: renderSummary, isExpandable: false, children: operation.responses.map((response) => response.code === activeTab.key ? (_jsx("div", { children: response?.content?.hasSample ? (_jsx(PayloadSamples, { content: response.content, onCopyClick: handleCodeSampleCopy, onPanelToggle: handlePanelToggle })) : (_jsx(StyledCodeBlock, { source: translate('openapi.noResponseContent', 'No content') })) }, response.code)) : null) }));
45
+ }
46
+ export const ResponseSamples = memo(ResponseSamplesComponent);
47
+ //# sourceMappingURL=ResponseSamples.js.map
@@ -1 +1,9 @@
1
- import{jsx as r,jsxs as a}from"react/jsx-runtime";import{PanelHeader as t}from"@redocly/theme/components/Panel/PanelHeader";import{PanelHeaderTitle as o}from"@redocly/theme/components/Panel/PanelHeaderTitle";import{useTranslate as n}from"../../hooks/index.js";const d=({tabs:e})=>{const s=n();return a(t,{isExpandable:!1,children:[r(o,{"data-testid":"title",children:s("openapi.response","Response")}),e]})};export{d as Summary};
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { PanelHeader } from '@redocly/theme/components/Panel/PanelHeader';
3
+ import { PanelHeaderTitle } from '@redocly/theme/components/Panel/PanelHeaderTitle';
4
+ import { useTranslate } from '../../hooks/index.js';
5
+ export const Summary = ({ tabs }) => {
6
+ const translate = useTranslate();
7
+ return (_jsxs(PanelHeader, { isExpandable: false, children: [_jsx(PanelHeaderTitle, { "data-testid": "title", children: translate('openapi.response', 'Response') }), tabs] }));
8
+ };
9
+ //# sourceMappingURL=Summary.js.map
@@ -1 +1,2 @@
1
- import{ResponseSamples as p}from"./ResponseSamples.js";export{p as ResponseSamples};
1
+ export { ResponseSamples } from './ResponseSamples.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,44 @@
1
- import{jsx as n,jsxs as a,Fragment as A}from"react/jsx-runtime";import{memo as L,useMemo as j}from"react";import{useLocation as w}from"react-router-dom";import{useAtomValue as C}from"jotai";import{Tabs as M,useTabsState as F}from"../Tabs/index.js";import{ResponseDetails as P}from"./ResponseDetails.js";import{makeDeepLink as R}from"../../services/index.js";import{Row as _,StyledTitle as B}from"./styled.js";import{LinkToField as D}from"../common/LinkToField.js";import{pathIncludesLink as f}from"../../utils/index.js";import{ExpandAllButton as E}from"../ExpandAllButton/index.js";import{useTranslate as N}from"../../hooks/index.js";import{getActiveMediaType as $}from"../../models/index.js";import{activeMimeNameAtom as I}from"../../jotai/app.js";import{styled as O}from"../../styled-components.js";const oe=L(({responses:i,renderTitle:d,operationId:s,operationPointer:u,activeResponseTab:m,onTabChange:T,callbackId:h,onPanelToggle:b})=>{const p=w(),g=N(),c=C(I),r=i.map(({code:e})=>({key:e,title:e})),k=r.find(({key:e})=>e===m||f(p,s)&&f(p,`c=${e}`)),{activeTab:x,handleTabChange:y}=F({tabs:r,defaultTab:k?.key,onChange:T}),o=r.find(e=>e.key===(m||x)),t=i.find(e=>e.code===o?.key),v=j(()=>{if(!t?.content)return!1;const{schema:e}=$(t?.content,c)||{};return e?.fields?.some(({schema:l})=>!l.isPrimitive&&!l.isCircular)},[c,t?.content]);return o?a(A,{children:[a(S,{children:[d?.(o)||a(B,{children:[n(D,{to:R(s,`response&c=${o.key}`)}),g("openapi.responses","Responses")]}),n(M,{tabs:r,activeTab:o,onChange:y}),v&&n(E,{type:"response",operationPointer:u,onPanelToggle:b})]}),t?n("div",{children:n(P,{response:t,operationId:s,callbackId:h})},t.code):null]}):null}),S=O(_)`
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { memo, useMemo } from 'react';
3
+ import { useLocation } from 'react-router-dom';
4
+ import { useAtomValue } from 'jotai';
5
+ import { Tabs, useTabsState } from '../Tabs/index.js';
6
+ import { ResponseDetails } from './ResponseDetails.js';
7
+ import { makeDeepLink } from '../../services/index.js';
8
+ import { Row, StyledTitle } from './styled.js';
9
+ import { LinkToField } from '../common/LinkToField.js';
10
+ import { pathIncludesLink } from '../../utils/index.js';
11
+ import { ExpandAllButton } from '../ExpandAllButton/index.js';
12
+ import { useTranslate } from '../../hooks/index.js';
13
+ import { getActiveMediaType } from '../../models/index.js';
14
+ import { activeMimeNameAtom } from '../../jotai/app.js';
15
+ import { styled } from '../../styled-components.js';
16
+ export const OperationResponseList = memo(({ responses, renderTitle, operationId, operationPointer, activeResponseTab, onTabChange, callbackId, onPanelToggle, }) => {
17
+ const location = useLocation();
18
+ const translate = useTranslate();
19
+ const activeMimeName = useAtomValue(activeMimeNameAtom);
20
+ const tabs = responses.map(({ code }) => ({ key: code, title: code }));
21
+ const defaultTab = tabs.find(({ key }) => key === activeResponseTab ||
22
+ (pathIncludesLink(location, operationId) && pathIncludesLink(location, `c=${key}`)));
23
+ const { activeTab, handleTabChange } = useTabsState({
24
+ tabs,
25
+ defaultTab: defaultTab?.key,
26
+ onChange: onTabChange,
27
+ });
28
+ const tab = tabs.find((t) => t.key === (activeResponseTab || activeTab));
29
+ const response = responses.find((r) => r.code === tab?.key);
30
+ const showExpandAllButton = useMemo(() => {
31
+ if (!response?.content)
32
+ return false;
33
+ const { schema } = getActiveMediaType(response?.content, activeMimeName) || {};
34
+ return schema?.fields?.some(({ schema: fieldSchema }) => !fieldSchema.isPrimitive && !fieldSchema.isCircular);
35
+ }, [activeMimeName, response?.content]);
36
+ if (!tab)
37
+ return null;
38
+ return (_jsxs(_Fragment, { children: [_jsxs(TitleWrap, { children: [renderTitle?.(tab) || (_jsxs(StyledTitle, { children: [_jsx(LinkToField, { to: makeDeepLink(operationId, `response&c=${tab.key}`) }), translate('openapi.responses', 'Responses')] })), _jsx(Tabs, { tabs: tabs, activeTab: tab, onChange: handleTabChange }), showExpandAllButton && (_jsx(ExpandAllButton, { type: "response", operationPointer: operationPointer, onPanelToggle: onPanelToggle }))] }), response ? (_jsx("div", { children: _jsx(ResponseDetails, { response: response, operationId: operationId, callbackId: callbackId }) }, response.code)) : null] }));
39
+ });
40
+ const TitleWrap = styled(Row) `
2
41
  flex-wrap: wrap;
3
42
  gap: var(--spacing-unit);
4
- `;export{oe as OperationResponseList};
43
+ `;
44
+ //# sourceMappingURL=OperationResponseList.js.map
@@ -1 +1,18 @@
1
- import{jsx as r,Fragment as f,jsxs as u}from"react/jsx-runtime";import{memo as x}from"react";import{ResponseHeaders as k}from"./ResponseHeaders.js";import{StyledDescription as i}from"./styled.js";import{BodyContent as y}from"../common/BodyContent/index.js";import{makeDeepLink as $}from"../../services/index.js";function h({response:s,operationId:e,callbackId:n,disableDeepLinks:o}){const{description:t,headers:d,content:a,summary:c,code:m}=s;return u(f,{children:[r(i,{className:"redoc-markdown",source:c}),r(i,{className:"redoc-markdown",source:t}),r(k,{headers:d,deepLink:o?void 0:p(e,n,m,"headers")}),r(y,{content:a,skipWriteOnly:!0,deepLink:o?void 0:p(e,n,m,"body")})]})}const w=x(h);function p(s,e="",n,o){const t=e?`${e}/response&c=${n}/${o}`:`response&c=${n}/${o}`;return $(s,t)}export{w as ResponseDetails};
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { ResponseHeaders } from './ResponseHeaders.js';
4
+ import { StyledDescription } from './styled.js';
5
+ import { BodyContent } from '../common/BodyContent/index.js';
6
+ import { makeDeepLink } from '../../services/index.js';
7
+ function ResponseDetailsComponent({ response, operationId, callbackId, disableDeepLinks, }) {
8
+ const { description, headers, content, summary, code } = response;
9
+ return (_jsxs(_Fragment, { children: [_jsx(StyledDescription, { className: "redoc-markdown", source: summary }), _jsx(StyledDescription, { className: "redoc-markdown", source: description }), _jsx(ResponseHeaders, { headers: headers, deepLink: disableDeepLinks ? undefined : generateDeepLink(operationId, callbackId, code, 'headers') }), _jsx(BodyContent, { content: content, skipWriteOnly: true, deepLink: disableDeepLinks ? undefined : generateDeepLink(operationId, callbackId, code, 'body') })] }));
10
+ }
11
+ export const ResponseDetails = memo(ResponseDetailsComponent);
12
+ function generateDeepLink(operationId, callbackId = '', code, place) {
13
+ const suffix = callbackId
14
+ ? `${callbackId}/response&c=${code}/${place}`
15
+ : `response&c=${code}/${place}`;
16
+ return makeDeepLink(operationId, suffix);
17
+ }
18
+ //# sourceMappingURL=ResponseDetails.js.map
@@ -1 +1,15 @@
1
- import{jsx as s,jsxs as t}from"react/jsx-runtime";import{memo as m}from"react";import{HeadersCaption as a,StyledHeadersProperties as p}from"./styled.js";import{PropertyDetails as l}from"../PropertyDetails/index.js";import{LinkToField as d}from"../common/LinkToField.js";import{useTranslate as f}from"../../hooks/index.js";function u({headers:e,deepLink:r}){const n=f();return e===void 0||e.length===0?null:t(p,{children:[t(a,{children:[r&&s(d,{to:r}),n("openapi.header","Headers")]}),e.map((o,i)=>s(l,{isFirst:i===0,field:o,disableDeepLinks:!r},o.name))]})}const C=m(u);export{C as ResponseHeaders};
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { HeadersCaption, StyledHeadersProperties } from './styled.js';
4
+ import { PropertyDetails } from '../PropertyDetails/index.js';
5
+ import { LinkToField } from '../common/LinkToField.js';
6
+ import { useTranslate } from '../../hooks/index.js';
7
+ function ResponseHeadersComponent({ headers, deepLink, }) {
8
+ const translate = useTranslate();
9
+ if (headers === undefined || headers.length === 0) {
10
+ return null;
11
+ }
12
+ return (_jsxs(StyledHeadersProperties, { children: [_jsxs(HeadersCaption, { children: [deepLink && _jsx(LinkToField, { to: deepLink }), translate('openapi.header', 'Headers')] }), headers.map((field, index) => (_jsx(PropertyDetails, { isFirst: index === 0, field: field, disableDeepLinks: !deepLink }, field.name)))] }));
13
+ }
14
+ export const ResponseHeaders = memo(ResponseHeadersComponent);
15
+ //# sourceMappingURL=ResponseHeaders.js.map
@@ -1 +1,6 @@
1
- import{OperationResponseList as r}from"./OperationResponseList.js";import{ResponseDetails as s}from"./ResponseDetails.js";import{ResponseHeaders as i}from"./ResponseHeaders.js";export*from"./types.js";import{HeadersCaption as n,StyledHeadersProperties as f,StyledTitle as l,StyledDescription as m}from"./styled.js";export{n as HeadersCaption,r as OperationResponseList,s as ResponseDetails,i as ResponseHeaders,m as StyledDescription,f as StyledHeadersProperties,l as StyledTitle};
1
+ export { OperationResponseList } from './OperationResponseList.js';
2
+ export { ResponseDetails } from './ResponseDetails.js';
3
+ export { ResponseHeaders } from './ResponseHeaders.js';
4
+ export * from './types.js';
5
+ export { HeadersCaption, StyledHeadersProperties, StyledTitle, StyledDescription, } from './styled.js';
6
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,7 @@
1
- import{Title as t}from"../common/OperationItemTitle.js";import{Markdown as e}from"../Markdown/index.js";import{styled as i}from"../../styled-components.js";const n=i.div`
1
+ import { Title } from '../common/OperationItemTitle.js';
2
+ import { Markdown } from '../Markdown/index.js';
3
+ import { styled } from '../../styled-components.js';
4
+ export const HeadersCaption = styled.div `
2
5
  position: relative;
3
6
  display: flex;
4
7
  align-items: center;
@@ -8,15 +11,20 @@ import{Title as t}from"../common/OperationItemTitle.js";import{Markdown as e}fro
8
11
  font-weight: var(--font-weight-semibold);
9
12
  color: var(--text-color-primary);
10
13
  padding: var(--spacing-xxs) 0;
11
- `,s=i.div`
14
+ `;
15
+ export const StyledHeadersProperties = styled.div `
12
16
  margin-top: var(--spacing-md);
13
- `,p=i.div`
17
+ `;
18
+ export const Row = styled.div `
14
19
  display: flex;
15
20
  align-items: center;
16
21
  margin-top: var(--spacing-base);
17
- `,l=i(t)`
22
+ `;
23
+ export const StyledTitle = styled(Title) `
18
24
  margin: 0 var(--spacing-sm) 0 0;
19
25
  position: relative;
20
- `,g=i(e)`
26
+ `;
27
+ export const StyledDescription = styled(Markdown) `
21
28
  margin-top: var(--spacing-xs);
22
- `;export{n as HeadersCaption,p as Row,g as StyledDescription,s as StyledHeadersProperties,l as StyledTitle};
29
+ `;
30
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1,21 @@
1
- import{jsx as e,Fragment as c,jsxs as g}from"react/jsx-runtime";import{useAtomValue as t}from"jotai";import{Panel as o}from"@redocly/theme/components/Panel/Panel";import{Markdown as f}from"@redocly/theme/components/Markdown/Markdown";import{DownloadSpecification as v}from"../Download/index.js";import{Overview as h}from"../Overview/index.js";import{LanguageList as u}from"../Language/index.js";import{ServerList as w}from"../ServerList/index.js";import{globalStoreAtom as x}from"../../jotai/store.js";import{normalizeServers as S}from"../../utils/index.js";import{mergeInMockServer as L}from"../../models/operation.js";import{languageAtom as b}from"../../jotai/app.js";import{useTranslate as j}from"../../hooks/index.js";const R=({item:{infoDefinition:r}})=>{const a=j(),{options:{hideDownloadButtons:i,mockServer:l},parser:{definition:m,definitionUrl:p}}=t(x),{languages:n,activeLanguage:d}=t(b),s=S(p,L(m.servers||[],l));return g(c,{children:[!i&&e(o,{className:"panel-download",header:a("openapi.download.description.title","Download OpenAPI description"),isExpandable:!1,children:e(v,{})}),(r?.license||r?.contact||r?.termsOfService)&&e(o,{className:"panel-overview",header:a("openapi.info.title","Overview"),isExpandable:!1,children:e(f,{children:e(h,{info:r,translate:a})})}),!!n?.length&&e(o,{className:"panel-language-list",header:a("openapi.languages.title","Languages"),isExpandable:!1,children:e(u,{languages:n,activeLanguage:d})}),!!s.length&&e(o,{className:"panel-servers-list",header:a("openapi.servers.title","Servers"),isExpandable:!1,children:e(w,{servers:s,path:"/",translate:a})})]})};export{R as RightPanel};
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAtomValue } from 'jotai';
3
+ import { Panel } from '@redocly/theme/components/Panel/Panel';
4
+ import { Markdown as MarkdownWrapper } from '@redocly/theme/components/Markdown/Markdown';
5
+ import { DownloadSpecification } from '../Download/index.js';
6
+ import { Overview } from '../Overview/index.js';
7
+ import { LanguageList } from '../Language/index.js';
8
+ import { ServerList } from '../ServerList/index.js';
9
+ import { globalStoreAtom } from '../../jotai/store.js';
10
+ import { normalizeServers } from '../../utils/index.js';
11
+ import { mergeInMockServer } from '../../models/operation.js';
12
+ import { languageAtom } from '../../jotai/app.js';
13
+ import { useTranslate } from '../../hooks/index.js';
14
+ export const RightPanel = ({ item: { infoDefinition: info }, }) => {
15
+ const translate = useTranslate();
16
+ const { options: { hideDownloadButtons, mockServer }, parser: { definition, definitionUrl }, } = useAtomValue(globalStoreAtom);
17
+ const { languages, activeLanguage } = useAtomValue(languageAtom);
18
+ const servers = normalizeServers(definitionUrl, mergeInMockServer(definition.servers || [], mockServer));
19
+ return (_jsxs(_Fragment, { children: [!hideDownloadButtons && (_jsx(Panel, { className: "panel-download", header: translate('openapi.download.description.title', 'Download OpenAPI description'), isExpandable: false, children: _jsx(DownloadSpecification, {}) })), (info?.license || info?.contact || info?.termsOfService) && (_jsx(Panel, { className: "panel-overview", header: translate('openapi.info.title', 'Overview'), isExpandable: false, children: _jsx(MarkdownWrapper, { children: _jsx(Overview, { info: info, translate: translate }) }) })), !!languages?.length && (_jsx(Panel, { className: "panel-language-list", header: translate('openapi.languages.title', 'Languages'), isExpandable: false, children: _jsx(LanguageList, { languages: languages, activeLanguage: activeLanguage }) })), !!servers.length && (_jsx(Panel, { className: "panel-servers-list", header: translate('openapi.servers.title', 'Servers'), isExpandable: false, children: _jsx(ServerList, { servers: servers, path: "/", translate: translate }) }))] }));
20
+ };
21
+ //# sourceMappingURL=RightPanel.js.map
@@ -1 +1,2 @@
1
- import{RightPanel as r}from"./RightPanel.js";export{r as RightPanel};
1
+ export { RightPanel } from './RightPanel.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1,33 @@
1
- import{jsx as n}from"react/jsx-runtime";import{useState as f,useEffect as h}from"react";import{MimeLabel as x,Container as v,Select as b}from"../common/index.js";import{SelectOrLabel as y}from"../SelectOrLabel/index.js";import{normalizeText as S}from"../../utils/index.js";import{useTelemetry as g}from"../../hooks/index.js";const I=({exampleKey:a,examples:s,onChange:m,className:c})=>{const i=g(),t=Object.keys(s),o=a?t.indexOf(a):0,[p,l]=f(o>-1?o:0);h(()=>l(o>-1?o:0),[a,o]);const r=t.map((e,d)=>({value:S(s[e].summary)||e,idx:d})),u=({idx:e})=>{i.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:t[e],numberOfExamples:t.length}}),l(e),m(t[e])};return r.length<2?null:n(v,{"data-testid":"example-switch",className:c,children:n(y,{Select:b,Label:x,variant:"dark",fullWidth:!0,options:r,value:r[p]?.value,onChange:u})})};export{I as ExampleSwitch};
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { MimeLabel, Container, Select } from '../common/index.js';
4
+ import { SelectOrLabel } from '../SelectOrLabel/index.js';
5
+ import { normalizeText } from '../../utils/index.js';
6
+ import { useTelemetry } from '../../hooks/index.js';
7
+ export const ExampleSwitch = ({ exampleKey, examples, onChange, className, }) => {
8
+ const telemetry = useTelemetry();
9
+ const examplesKeys = Object.keys(examples);
10
+ const defaultIdx = exampleKey ? examplesKeys.indexOf(exampleKey) : 0;
11
+ const [activeIdx, setActiveIdx] = useState(defaultIdx > -1 ? defaultIdx : 0);
12
+ useEffect(() => setActiveIdx(defaultIdx > -1 ? defaultIdx : 0), [exampleKey, defaultIdx]);
13
+ const options = examplesKeys.map((name, idx) => ({
14
+ value: normalizeText(examples[name].summary) || name,
15
+ idx,
16
+ }));
17
+ const handleChange = ({ idx }) => {
18
+ telemetry.send({
19
+ type: 'openapi_docs.examples_switcher.clicked',
20
+ payload: {
21
+ example: examplesKeys[idx],
22
+ numberOfExamples: examplesKeys.length,
23
+ },
24
+ });
25
+ setActiveIdx(idx);
26
+ onChange(examplesKeys[idx]);
27
+ };
28
+ if (options.length < 2) {
29
+ return null;
30
+ }
31
+ return (_jsx(Container, { "data-testid": "example-switch", className: className, children: _jsx(SelectOrLabel, { Select: Select, Label: MimeLabel, variant: "dark", fullWidth: true, options: options, value: options[activeIdx]?.value, onChange: handleChange }) }));
32
+ };
33
+ //# sourceMappingURL=ExampleSwitch.js.map
@@ -1 +1,3 @@
1
- export*from"./ExampleSwitch.js";export*from"./use-example-key.js";
1
+ export * from './ExampleSwitch.js';
2
+ export * from './use-example-key.js';
3
+ //# sourceMappingURL=index.js.map
@@ -1 +1,12 @@
1
- import{useAtomValue as a}from"jotai";import{operationStore as m}from"../../jotai/operation.js";function i({pointer:o}={},t){const r=a(m(o)),{activeExampleName:e}=r;return{exampleKey:e&&t[e]?e:Object.keys(t)[0]}}export{i as useExampleKey};
1
+ import { useAtomValue } from 'jotai';
2
+ import { operationStore } from '../../jotai/operation.js';
3
+ export function useExampleKey({ pointer } = {}, examples) {
4
+ const operationState = useAtomValue(operationStore(pointer));
5
+ const { activeExampleName } = operationState;
6
+ return {
7
+ exampleKey: activeExampleName && examples[activeExampleName]
8
+ ? activeExampleName
9
+ : Object.keys(examples)[0],
10
+ };
11
+ }
12
+ //# sourceMappingURL=use-example-key.js.map
@@ -1 +1,45 @@
1
- import{jsx as n,Fragment as b,jsxs as C}from"react/jsx-runtime";import{memo as T,useCallback as k}from"react";import{useAtomValue as F}from"jotai";import{TypeName as L}from"../common/index.js";import{Schema as j}from"./Schema.js";import{ObjectSchema as S}from"./ObjectSchema.js";import{humanizeConstraints as B}from"../../utils/index.js";import{SubSchema as D}from"./SubSchema.js";import{globalOptionsAtom as R}from"../../jotai/store.js";import{getExpandByDefault as W}from"./helpers.js";import{ArrayLabel as _,LabelValue as m,ArrayClosingLabel as q}from"../common/styled.js";function E({schema:r,schema:{minItems:c,maxItems:h,items:a},fieldParentsName:l,...e}){const{schemasExpansionLevel:u}=F(R),p=Array.isArray(e.parentType)?e.parentType:[e.parentType],o=p.includes("array")&&p.length===1,t=o?(e.level||0)+1:e.level,O=c===void 0&&h===void 0?"":`(${B(r)})`;let d=l&&[...l.slice(0,-1),l[l.length-1]+"[]"];const s=k(y=>e.skipReadOnly||e.skipWriteOnly?y?.filter(f=>!(e.skipReadOnly&&f.schema.readOnly||e.skipWriteOnly&&f.schema.writeOnly)):y,[e.skipReadOnly,e.skipWriteOnly]);if(r?.fields)return n(S,{...e,shouldCloseArray:o,level:t,schema:r,fieldParentsName:d,onOneOfChange:e.onOneOfChange});if(r.displayType&&!a&&!O.length)return n("div",{children:n(L,{children:r.displayType})});const g=s(a?.fields),A=s(a?.oneOf?.[0]?.fields),v=g?.length||A?.length,i=e.level===1,x=W({level:e.level,required:e.required,schemasExpansionLevel:u});return n(D,{...e,propertyLength:v,isNestedArray:o,level:t,isArray:!0,expandable:!i,expandByDefault:x,operationPointer:r.operationPointer,children:C(b,{children:[i&&n(_,{children:n(m,{children:"Array ["})}),n(j,{...e,parentType:i?void 0:r.type,level:t,schema:a,shouldCloseArray:o,fieldParentsName:d,expandable:!1,onOneOfChange:e.onOneOfChange}),i&&n(q,{className:"array-closing-label",children:n(m,{children:"]"})})]})})}const K=T(E);export{K as ArraySchema};
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useCallback } from 'react';
3
+ import { useAtomValue } from 'jotai';
4
+ import { TypeName } from '../common/index.js';
5
+ import { Schema } from './Schema.js';
6
+ import { ObjectSchema } from './ObjectSchema.js';
7
+ import { humanizeConstraints } from '../../utils/index.js';
8
+ import { SubSchema } from './SubSchema.js';
9
+ import { globalOptionsAtom } from '../../jotai/store.js';
10
+ import { getExpandByDefault } from './helpers.js';
11
+ import { ArrayLabel, LabelValue, ArrayClosingLabel } from '../common/styled.js';
12
+ function ArraySchemaComponent({ schema, schema: { minItems, maxItems, items: itemsSchema }, fieldParentsName, ...rest }) {
13
+ const { schemasExpansionLevel } = useAtomValue(globalOptionsAtom);
14
+ const parentSchemaTypes = Array.isArray(rest.parentType) ? rest.parentType : [rest.parentType];
15
+ const isNestedArray = parentSchemaTypes.includes('array') && parentSchemaTypes.length === 1;
16
+ const level = isNestedArray ? (rest.level || 0) + 1 : rest.level;
17
+ const minMaxItems = minItems === undefined && maxItems === undefined
18
+ ? ''
19
+ : `(${humanizeConstraints(schema)})`;
20
+ let updatedParentsArray = fieldParentsName
21
+ ? [...fieldParentsName.slice(0, -1), fieldParentsName[fieldParentsName.length - 1] + '[]']
22
+ : fieldParentsName;
23
+ const getFilteredFields = useCallback((items) => rest.skipReadOnly || rest.skipWriteOnly
24
+ ? items?.filter((item) => !((rest.skipReadOnly && item.schema.readOnly) ||
25
+ (rest.skipWriteOnly && item.schema.writeOnly)))
26
+ : items, [rest.skipReadOnly, rest.skipWriteOnly]);
27
+ if (schema?.fields) {
28
+ return (_jsx(ObjectSchema, { ...rest, shouldCloseArray: isNestedArray, level: level, schema: schema, fieldParentsName: updatedParentsArray, onOneOfChange: rest.onOneOfChange }));
29
+ }
30
+ if (schema.displayType && !itemsSchema && !minMaxItems.length) {
31
+ return (_jsx("div", { children: _jsx(TypeName, { children: schema.displayType }) }));
32
+ }
33
+ const filteredFields = getFilteredFields(itemsSchema?.fields);
34
+ const filteredOneOfFields = getFilteredFields(itemsSchema?.oneOf?.[0]?.fields);
35
+ const propertyLength = filteredFields?.length || filteredOneOfFields?.length;
36
+ const isFirstLevel = rest.level === 1;
37
+ const expandByDefault = getExpandByDefault({
38
+ level: rest.level,
39
+ required: rest.required,
40
+ schemasExpansionLevel,
41
+ });
42
+ return (_jsx(SubSchema, { ...rest, propertyLength: propertyLength, isNestedArray: isNestedArray, level: level, isArray: true, expandable: !isFirstLevel, expandByDefault: expandByDefault, operationPointer: schema.operationPointer, children: _jsxs(_Fragment, { children: [isFirstLevel && (_jsx(ArrayLabel, { children: _jsx(LabelValue, { children: "Array [" }) })), _jsx(Schema, { ...rest, parentType: !isFirstLevel ? schema.type : undefined, level: level, schema: itemsSchema, shouldCloseArray: isNestedArray, fieldParentsName: updatedParentsArray, expandable: false, onOneOfChange: rest.onOneOfChange }), isFirstLevel && (_jsx(ArrayClosingLabel, { className: "array-closing-label", children: _jsx(LabelValue, { children: "]" }) }))] }) }));
43
+ }
44
+ export const ArraySchema = memo(ArraySchemaComponent);
45
+ //# sourceMappingURL=ArraySchema.js.map
@@ -1 +1,29 @@
1
- import{jsx as a,Fragment as C,jsxs as p}from"react/jsx-runtime";import{memo as P}from"react";import{useAtomValue as F}from"jotai";import{PropertiesTableCaption as N}from"../common/index.js";import{Discriminator as v}from"../Discriminator/index.js";import{globalOptionsAtom as A}from"../../jotai/store.js";import{PropertyDetails as B}from"../PropertyDetails/index.js";import{SubSchema as _}from"./SubSchema.js";import{getExpandByDefault as w}from"./helpers.js";import{useTranslate as E}from"../../hooks/index.js";import{ArrayClosingLabel as I,LabelValue as T}from"../common/styled.js";function V({schema:m,showTitle:s,discriminator:t,level:n,skipWriteOnly:r,skipReadOnly:o,fieldParentsName:c,expandable:f,deepLink:h,required:d,disableDeepLinks:u,shouldCloseArray:g,oneOfLevel:x,slug:b,onOneOfChange:O}){const{fields:i=[],title:y}=m,D=E(),{schemasExpansionLevel:L}=F(A),l=o||r?i.filter(e=>!(o&&e.schema.readOnly||r&&e.schema.writeOnly)):i,S=w({required:d,level:n,schemasExpansionLevel:L});return p(_,{expandable:f,expandByDefault:S,level:n,propertyLength:l.length,deepLink:h,operationPointer:m.operationPointer,children:[p(C,{children:[s&&a(N,{children:y}),l.map((e,j)=>a(B,{isFirst:j===0,field:e,fieldParentsName:Number(n)>1?c:[],renderDiscriminatorSwitch:t?.fieldName===e.name&&t?.parentSchema?()=>a(v,{parent:t.parentSchema,onChange:t?.onChange,activeOneOfIdx:t.activeOneOfIdx,translate:D}):void 0,skipReadOnly:o,skipWriteOnly:r,showTitle:s,level:n,disableDeepLinks:u,oneOfLevel:x,slug:b,onOneOfChange:O},e.name))]}),g&&a(I,{className:"array-closing-label",children:a(T,{children:"]"})})]})}const Y=P(V);export{Y as ObjectSchema};
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { useAtomValue } from 'jotai';
4
+ import { PropertiesTableCaption } from '../common/index.js';
5
+ import { Discriminator } from '../Discriminator/index.js';
6
+ import { globalOptionsAtom } from '../../jotai/store.js';
7
+ import { PropertyDetails } from '../PropertyDetails/index.js';
8
+ import { SubSchema } from './SubSchema.js';
9
+ import { getExpandByDefault } from './helpers.js';
10
+ import { useTranslate } from '../../hooks/index.js';
11
+ import { ArrayClosingLabel, LabelValue } from '../common/styled.js';
12
+ function ObjectSchemaComponent({ schema, showTitle, discriminator, level, skipWriteOnly, skipReadOnly, fieldParentsName, expandable, deepLink, required, disableDeepLinks, shouldCloseArray, oneOfLevel, slug, onOneOfChange, }) {
13
+ const { fields = [], title } = schema;
14
+ const translate = useTranslate();
15
+ const { schemasExpansionLevel } = useAtomValue(globalOptionsAtom);
16
+ const filteredFields = skipReadOnly || skipWriteOnly
17
+ ? fields.filter((item) => !((skipReadOnly && item.schema.readOnly) || (skipWriteOnly && item.schema.writeOnly)))
18
+ : fields;
19
+ const expandByDefault = getExpandByDefault({
20
+ required,
21
+ level,
22
+ schemasExpansionLevel,
23
+ });
24
+ return (_jsxs(SubSchema, { expandable: expandable, expandByDefault: expandByDefault, level: level, propertyLength: filteredFields.length, deepLink: deepLink, operationPointer: schema.operationPointer, children: [_jsxs(_Fragment, { children: [showTitle && _jsx(PropertiesTableCaption, { children: title }), filteredFields.map((field, index) => (_jsx(PropertyDetails, { isFirst: index === 0, field: field, fieldParentsName: Number(level) > 1 ? fieldParentsName : [], renderDiscriminatorSwitch: discriminator?.fieldName === field.name && discriminator?.parentSchema
25
+ ? () => (_jsx(Discriminator, { parent: discriminator.parentSchema, onChange: discriminator?.onChange, activeOneOfIdx: discriminator.activeOneOfIdx, translate: translate }))
26
+ : undefined, skipReadOnly: skipReadOnly, skipWriteOnly: skipWriteOnly, showTitle: showTitle, level: level, disableDeepLinks: disableDeepLinks, oneOfLevel: oneOfLevel, slug: slug, onOneOfChange: onOneOfChange }, field.name)))] }), shouldCloseArray && (_jsx(ArrayClosingLabel, { className: "array-closing-label", children: _jsx(LabelValue, { children: "]" }) }))] }));
27
+ }
28
+ export const ObjectSchema = memo(ObjectSchemaComponent);
29
+ //# sourceMappingURL=ObjectSchema.js.map
@@ -1,10 +1,54 @@
1
- import{jsxs as c,jsx as n}from"react/jsx-runtime";import{memo as S}from"react";import{useAtom as g}from"jotai";import{StyledBadge as y,SelectionTitle as I}from"../common/index.js";import{Markdown as j}from"../Markdown/index.js";import{ConstraintsView as C}from"../common/ConstraintsView.js";import{Schema as T}from"./Schema.js";import{operationStore as b}from"../../jotai/operation.js";import{SchemaSelection as w}from"../common/SchemaSelection/index.js";import{useOneOfLocationIdx as P}from"./useOneOfLocationIdx.js";import{useTranslate as z}from"../../hooks/index.js";import{styled as d}from"../../styled-components.js";function D({schema:{oneOf:i},schema:e,onChange:m,oneOfLevel:r=1,...f}){const l=z(),[a,O]=g(b(e.operationPointer)),p=P(i,r),s=p===-1?0:p,x=a.activeOneOf?.[e.pointer]!==void 0?a.activeOneOf[e.pointer]:s,o=i[x];if(!o)return null;const u=i.map((t,v)=>({label:t.title||t.typePrefix+t.displayType,value:v})),h=t=>{m?.({pointer:e.pointer,index:t}),O({activeExampleName:e.oneOf?.[t]?.title,activeOneOf:{[e.pointer]:t},requestValues:{body:null}})};return c(V,{children:[c(I,{children:[e.oneOfType,":"]}),n(w,{options:u,onChange:h,pointer:e.operationPointer,schema:e,defaultOneOfIdx:s}),o.deprecated&&n(y,{deprecated:!0,children:l("openapi.badges.deprecated","Deprecated")}),o.description&&n(L,{source:o.description}),n(C,{constraints:o.constraints}),n(T,{...f,schema:o,oneOfLevel:r+1})]})}const J=S(D),L=d(j)`
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { useAtom } from 'jotai';
4
+ import { StyledBadge, SelectionTitle } from '../common/index.js';
5
+ import { Markdown } from '../Markdown/index.js';
6
+ import { ConstraintsView } from '../common/ConstraintsView.js';
7
+ import { Schema } from './Schema.js';
8
+ import { operationStore } from '../../jotai/operation.js';
9
+ import { SchemaSelection } from '../common/SchemaSelection/index.js';
10
+ import { useOneOfLocationIdx } from './useOneOfLocationIdx.js';
11
+ import { useTranslate } from '../../hooks/index.js';
12
+ import { styled } from '../../styled-components.js';
13
+ function OneOfSchemaComponent({ schema: { oneOf }, schema, onChange, oneOfLevel = 1, ...rest }) {
14
+ const translate = useTranslate();
15
+ const [store, setOperationStore] = useAtom(operationStore(schema.operationPointer));
16
+ const oneOfIdxLocation = useOneOfLocationIdx(oneOf, oneOfLevel);
17
+ const activeOneOfIdx = oneOfIdxLocation === -1 ? 0 : oneOfIdxLocation;
18
+ const activeSchemaIndex = store.activeOneOf?.[schema.pointer] !== undefined
19
+ ? store.activeOneOf[schema.pointer]
20
+ : activeOneOfIdx;
21
+ const activeSchema = oneOf[activeSchemaIndex];
22
+ if (!activeSchema) {
23
+ return null;
24
+ }
25
+ const options = oneOf.map((subSchema, idx) => ({
26
+ label: subSchema.title || subSchema.typePrefix + subSchema.displayType,
27
+ value: idx,
28
+ }));
29
+ const handleChange = (value) => {
30
+ onChange?.({
31
+ pointer: schema.pointer,
32
+ index: value,
33
+ });
34
+ setOperationStore({
35
+ activeExampleName: schema.oneOf?.[value]?.title,
36
+ activeOneOf: { [schema.pointer]: value },
37
+ requestValues: { body: null },
38
+ });
39
+ };
40
+ return (_jsxs(Wrapper, { children: [_jsxs(SelectionTitle, { children: [schema.oneOfType, ":"] }), _jsx(SchemaSelection, { options: options, onChange: handleChange, pointer: schema.operationPointer, schema: schema, defaultOneOfIdx: activeOneOfIdx }), activeSchema.deprecated && (_jsx(StyledBadge, { deprecated: true, children: translate('openapi.badges.deprecated', 'Deprecated') })), activeSchema.description && _jsx(StyledDescription, { source: activeSchema.description }), _jsx(ConstraintsView, { constraints: activeSchema.constraints }), _jsx(Schema, { ...rest, schema: activeSchema, oneOfLevel: oneOfLevel + 1 })] }));
41
+ }
42
+ export const OneOfSchema = memo(OneOfSchemaComponent);
43
+ const StyledDescription = styled(Markdown) `
2
44
  margin-top: var(--spacing-xs);
3
45
  font-size: var(--font-size-base);
4
46
  line-height: var(--line-height-base);
5
- `,V=d.div`
47
+ `;
48
+ const Wrapper = styled.div `
6
49
  display: flex;
7
50
  flex-direction: column;
8
51
  align-items: flex-start;
9
52
  width: 100%;
10
- `;export{J as OneOfSchema};
53
+ `;
54
+ //# sourceMappingURL=OneOfSchema.js.map
@@ -1 +1,10 @@
1
- import{jsx as t,jsxs as r}from"react/jsx-runtime";import{memo as s}from"react";import{RecursiveLabel as o,TypeName as n,TypeTitle as c}from"../common/index.js";import{useTranslate as m}from"../../hooks/index.js";function p({schema:e}){const i=m();return r("div",{children:[t(n,{children:e.displayType}),e.title&&r(c,{children:[" ",e.title," "]}),r(o,{children:[" ",i("openapi.recursive","Recursive")," "]})]})}const v=s(p);export{v as RecursiveSchema};
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { RecursiveLabel, TypeName, TypeTitle } from '../common/index.js';
4
+ import { useTranslate } from '../../hooks/index.js';
5
+ function RecursiveSchemaComponent({ schema }) {
6
+ const translate = useTranslate();
7
+ return (_jsxs("div", { children: [_jsx(TypeName, { children: schema.displayType }), schema.title && _jsxs(TypeTitle, { children: [" ", schema.title, " "] }), _jsxs(RecursiveLabel, { children: [" ", translate('openapi.recursive', 'Recursive'), " "] })] }));
8
+ }
9
+ export const RecursiveSchema = memo(RecursiveSchemaComponent);
10
+ //# sourceMappingURL=RecursiveSchema.js.map