@redocly/openapi-docs 3.12.0-rc.7 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/dist/redocly-openapi-docs.min.js +2153 -1963
  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 +17 -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.d.ts +1 -4
  51. package/lib/components/OperationItem/Description.js +9 -1
  52. package/lib/components/OperationItem/OperationItem.js +70 -5
  53. package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
  54. package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
  55. package/lib/components/OperationItem/index.js +2 -1
  56. package/lib/components/OperationItem/types.js +2 -0
  57. package/lib/components/Overlay.js +48 -3
  58. package/lib/components/Overview/Overview.js +20 -1
  59. package/lib/components/Overview/index.js +2 -1
  60. package/lib/components/PageFooter/PageFooter.js +19 -1
  61. package/lib/components/PageFooter/index.js +2 -1
  62. package/lib/components/Panel/ResponsePanel.js +12 -6
  63. package/lib/components/Panel/Trigger.js +4 -2
  64. package/lib/components/Panel/index.js +3 -1
  65. package/lib/components/PanelItem/PanelItem.js +6 -1
  66. package/lib/components/PanelItem/index.js +3 -1
  67. package/lib/components/PanelItem/styled.js +20 -10
  68. package/lib/components/PayloadSamples/Example.js +6 -1
  69. package/lib/components/PayloadSamples/ExampleValue.js +30 -1
  70. package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
  71. package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
  72. package/lib/components/PayloadSamples/index.js +7 -1
  73. package/lib/components/PayloadSamples/styled.js +9 -4
  74. package/lib/components/PayloadSamples/types.js +2 -0
  75. package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
  76. package/lib/components/PropertyDetails/EnumValues.js +37 -1
  77. package/lib/components/PropertyDetails/Examples.js +26 -1
  78. package/lib/components/PropertyDetails/Extensions.js +17 -2
  79. package/lib/components/PropertyDetails/FieldDetail.js +15 -2
  80. package/lib/components/PropertyDetails/FieldDetails.js +51 -6
  81. package/lib/components/PropertyDetails/Pattern.js +21 -1
  82. package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
  83. package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
  84. package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
  85. package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
  86. package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
  87. package/lib/components/PropertyDetails/index.js +4 -1
  88. package/lib/components/PropertyDetails/styled.js +15 -7
  89. package/lib/components/PropertyDetails/types.js +2 -0
  90. package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
  91. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
  92. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
  93. package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
  94. package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
  95. package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
  96. package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
  97. package/lib/components/RenderHook/RenderHook.js +17 -1
  98. package/lib/components/RenderHook/index.js +2 -1
  99. package/lib/components/Replay/EmbeddedReplay.js +41 -3
  100. package/lib/components/Replay/Replay.js +99 -1
  101. package/lib/components/Replay/index.js +3 -1
  102. package/lib/components/Replay/utils.js +208 -1
  103. package/lib/components/Request/RequestDetails.js +33 -2
  104. package/lib/components/Request/types.js +2 -0
  105. package/lib/components/RequestParameters/Body.js +8 -1
  106. package/lib/components/RequestParameters/ParametersGroup.js +19 -4
  107. package/lib/components/RequestParameters/RequestParameters.js +40 -1
  108. package/lib/components/RequestParameters/index.js +4 -1
  109. package/lib/components/RequestSamples/CodeSample.js +55 -2
  110. package/lib/components/RequestSamples/Example.js +37 -1
  111. package/lib/components/RequestSamples/RequestSamples.js +89 -5
  112. package/lib/components/RequestSamples/index.js +3 -1
  113. package/lib/components/RequestSamples/useCodeSamples.js +92 -1
  114. package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
  115. package/lib/components/ResponseSamples/Summary.js +9 -1
  116. package/lib/components/ResponseSamples/index.js +2 -1
  117. package/lib/components/Responses/OperationResponseList.js +42 -2
  118. package/lib/components/Responses/ResponseDetails.js +18 -1
  119. package/lib/components/Responses/ResponseHeaders.js +15 -1
  120. package/lib/components/Responses/index.js +6 -1
  121. package/lib/components/Responses/styled.js +14 -6
  122. package/lib/components/Responses/types.js +2 -0
  123. package/lib/components/RightPanel/RightPanel.js +21 -1
  124. package/lib/components/RightPanel/index.js +2 -1
  125. package/lib/components/Samples/ExampleSwitch.js +33 -1
  126. package/lib/components/Samples/index.js +3 -1
  127. package/lib/components/Samples/use-example-key.js +12 -1
  128. package/lib/components/Schema/ArraySchema.js +45 -1
  129. package/lib/components/Schema/ObjectSchema.js +29 -1
  130. package/lib/components/Schema/OneOfSchema.js +47 -3
  131. package/lib/components/Schema/RecursiveSchema.js +10 -1
  132. package/lib/components/Schema/Schema.js +63 -2
  133. package/lib/components/Schema/SubSchema.js +20 -1
  134. package/lib/components/Schema/helpers.js +16 -1
  135. package/lib/components/Schema/index.js +5 -1
  136. package/lib/components/Schema/types.js +2 -0
  137. package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
  138. package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
  139. package/lib/components/SchemaDefinition/index.js +2 -1
  140. package/lib/components/SectionContent/SectionContent.js +49 -6
  141. package/lib/components/SectionContent/index.js +2 -1
  142. package/lib/components/SectionItem/SectionItem.js +14 -1
  143. package/lib/components/SectionItem/index.js +2 -1
  144. package/lib/components/Security/Divider.js +9 -2
  145. package/lib/components/Security/OAuthFlow.js +11 -1
  146. package/lib/components/Security/OAuthScopes.js +59 -9
  147. package/lib/components/Security/Security.js +15 -1
  148. package/lib/components/Security/SecurityButton.js +31 -7
  149. package/lib/components/Security/SecurityFlow.js +28 -4
  150. package/lib/components/Security/SecurityModal.js +34 -5
  151. package/lib/components/Security/SecuritySchemeItem.js +15 -4
  152. package/lib/components/Security/helper.js +16 -1
  153. package/lib/components/Security/index.js +11 -1
  154. package/lib/components/Security/styled.js +6 -3
  155. package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
  156. package/lib/components/SelectOrLabel/index.js +2 -1
  157. package/lib/components/ServerList/ServerList.js +36 -10
  158. package/lib/components/ServerList/index.js +2 -1
  159. package/lib/components/ServerList/types.js +2 -0
  160. package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
  161. package/lib/components/ServerListDropdown/index.js +2 -1
  162. package/lib/components/ServerListDropdown/styled.js +15 -6
  163. package/lib/components/SideMenu/SideMenu.js +13 -2
  164. package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
  165. package/lib/components/SideMenu/index.js +2 -1
  166. package/lib/components/SideMenu/types.js +2 -0
  167. package/lib/components/StickySidebar/SidebarActions.js +14 -2
  168. package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
  169. package/lib/components/StickySidebar/index.js +2 -1
  170. package/lib/components/Tabs/Tabs.js +16 -5
  171. package/lib/components/Tabs/index.js +3 -1
  172. package/lib/components/Tabs/useTabsState.js +22 -1
  173. package/lib/components/TagItem/OperationNavigationItems.js +18 -4
  174. package/lib/components/TagItem/OperationsNavigation.js +46 -2
  175. package/lib/components/TagItem/TagItem.js +41 -8
  176. package/lib/components/TagItem/index.js +2 -1
  177. package/lib/components/TagItem/styled.js +5 -2
  178. package/lib/components/TagItem/types.js +2 -0
  179. package/lib/components/ViewNested/ViewNested.js +42 -9
  180. package/lib/components/ViewNested/index.js +2 -1
  181. package/lib/components/common/Badges.js +21 -5
  182. package/lib/components/common/BodyContent/BodyContent.js +31 -4
  183. package/lib/components/common/BodyContent/index.js +2 -1
  184. package/lib/components/common/ClearButton/ClearButton.js +5 -1
  185. package/lib/components/common/ClearButton/index.js +3 -1
  186. package/lib/components/common/ClearButton/styled.js +5 -2
  187. package/lib/components/common/ClearButton/types.js +2 -0
  188. package/lib/components/common/CodeBlockPanel.js +7 -3
  189. package/lib/components/common/ConstraintsView.js +14 -2
  190. package/lib/components/common/Dropdown/Dropdown.js +22 -4
  191. package/lib/components/common/Dropdown/index.js +2 -1
  192. package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
  193. package/lib/components/common/ExpandableExample/index.js +2 -1
  194. package/lib/components/common/Extensions.js +17 -2
  195. package/lib/components/common/Fields/fields-layout.js +76 -51
  196. package/lib/components/common/Fields/fields.js +39 -17
  197. package/lib/components/common/Fields/index.js +3 -1
  198. package/lib/components/common/LinkToField.js +33 -6
  199. package/lib/components/common/OperationItemTitle.d.ts +1 -0
  200. package/lib/components/common/OperationItemTitle.js +16 -5
  201. package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
  202. package/lib/components/common/SchemaSelection/index.js +2 -1
  203. package/lib/components/common/Select/Select.js +21 -1
  204. package/lib/components/common/Select/index.js +3 -1
  205. package/lib/components/common/Select/styled.js +17 -9
  206. package/lib/components/common/Select/types.js +2 -0
  207. package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
  208. package/lib/components/common/Skeleton/Skeleton.js +15 -5
  209. package/lib/components/common/Skeleton/index.js +3 -1
  210. package/lib/components/common/headers.js +4 -2
  211. package/lib/components/common/index.js +14 -1
  212. package/lib/components/common/linkify.js +28 -4
  213. package/lib/components/common/mixins.js +4 -2
  214. package/lib/components/common/panels.js +58 -33
  215. package/lib/components/common/schema.js +16 -8
  216. package/lib/components/common/styled.js +15 -7
  217. package/lib/components/index.js +25 -1
  218. package/lib/components/pluggable/RedocExample.js +20 -1
  219. package/lib/components/pluggable/RedocSchema.js +22 -1
  220. package/lib/components/pluggable/index.js +3 -1
  221. package/lib/components/pluggable/styled.components.js +9 -4
  222. package/lib/constants.js +30 -1
  223. package/lib/empty.js +7 -1
  224. package/lib/events/codeSampleCopy.js +19 -1
  225. package/lib/events/creator.js +5 -1
  226. package/lib/events/index.js +8 -1
  227. package/lib/events/languageSwitch.js +18 -1
  228. package/lib/events/panelToggle.js +16 -1
  229. package/lib/events/serverSwitch.js +13 -1
  230. package/lib/events/tryItOpen.js +12 -1
  231. package/lib/events/tryItSent.js +12 -1
  232. package/lib/events/types.js +11 -1
  233. package/lib/hoc/types.js +2 -0
  234. package/lib/hoc/utils.js +4 -1
  235. package/lib/hoc/withRouter.js +17 -1
  236. package/lib/hoc/withStore.js +28 -1
  237. package/lib/hooks/index.js +9 -1
  238. package/lib/hooks/useActivateExample.js +35 -1
  239. package/lib/hooks/useActiveWithFallback.js +12 -1
  240. package/lib/hooks/useContentItems.js +10 -1
  241. package/lib/hooks/useLicense.js +17 -1
  242. package/lib/hooks/usePerformanceMetrics.js +26 -1
  243. package/lib/hooks/useRouter.js +17 -1
  244. package/lib/hooks/useTelemetry.js +5 -1
  245. package/lib/hooks/useTranslate.js +6 -1
  246. package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
  247. package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
  248. package/lib/icons/CSharpIcon/index.js +2 -1
  249. package/lib/icons/CurlIcon/CurlIcon.js +8 -2
  250. package/lib/icons/CurlIcon/index.js +2 -1
  251. package/lib/icons/GOIcon/GOIcon.js +7 -1
  252. package/lib/icons/GOIcon/index.js +2 -1
  253. package/lib/icons/JavaIcon/JavaIcon.js +7 -1
  254. package/lib/icons/JavaIcon/index.js +2 -1
  255. package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
  256. package/lib/icons/JavaScriptIcon/index.js +2 -1
  257. package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
  258. package/lib/icons/NodeJSIcon/index.js +2 -1
  259. package/lib/icons/PHPIcon/PHPIcon.js +7 -1
  260. package/lib/icons/PHPIcon/index.js +2 -1
  261. package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
  262. package/lib/icons/PayloadIcon/index.js +2 -1
  263. package/lib/icons/PythonIcon/PythonIcon.js +7 -1
  264. package/lib/icons/PythonIcon/index.js +2 -1
  265. package/lib/icons/RIcon/RIcon.js +7 -1
  266. package/lib/icons/RIcon/index.js +2 -1
  267. package/lib/icons/RubyIcon/RubyIcon.js +7 -1
  268. package/lib/icons/RubyIcon/index.js +2 -1
  269. package/lib/index.js +49 -1
  270. package/lib/jotai/app.js +113 -1
  271. package/lib/jotai/operation.js +28 -1
  272. package/lib/jotai/replay.js +5 -1
  273. package/lib/jotai/store.js +8 -1
  274. package/lib/jotai/use-write-atom.js +9 -1
  275. package/lib/models/callback.js +28 -1
  276. package/lib/models/code-sample-options.js +2 -0
  277. package/lib/models/example.js +17 -1
  278. package/lib/models/field.js +109 -1
  279. package/lib/models/group.js +38 -1
  280. package/lib/models/index.js +14 -1
  281. package/lib/models/mediaContent.js +26 -1
  282. package/lib/models/mediaType.js +153 -1
  283. package/lib/models/operation.js +166 -1
  284. package/lib/models/request.js +25 -1
  285. package/lib/models/response.js +46 -1
  286. package/lib/models/schema.js +474 -2
  287. package/lib/models/security.js +84 -1
  288. package/lib/models/tab.js +2 -0
  289. package/lib/models/types.js +2 -0
  290. package/lib/services/OpenAPIParser.js +321 -1
  291. package/lib/services/check.js +104 -1
  292. package/lib/services/code-samples/constants.js +16 -1
  293. package/lib/services/code-samples/generator.js +540 -1
  294. package/lib/services/code-samples/httpsnippet/helpers/code-builder.d.ts +5 -1
  295. package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
  296. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +2 -2
  297. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
  298. package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
  299. package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
  300. package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
  301. package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
  302. package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
  303. package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
  304. package/lib/services/code-samples/httpsnippet/index.js +166 -1
  305. package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
  306. package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
  307. package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
  308. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
  309. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
  310. package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
  311. package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
  312. package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
  313. package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
  314. package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
  315. package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
  316. package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
  317. package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
  318. package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
  319. package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
  320. package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
  321. package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
  322. package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
  323. package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
  324. package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
  325. package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
  326. package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
  327. package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
  328. package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
  329. package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
  330. package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
  331. package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
  332. package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
  333. package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
  334. package/lib/services/code-samples/index.js +3 -1
  335. package/lib/services/code-samples/types.js +2 -0
  336. package/lib/services/config-options/helpers.js +49 -1
  337. package/lib/services/config-options/index.js +3 -1
  338. package/lib/services/config-options/normalizeOptions.js +83 -1
  339. package/lib/services/config-options/types.js +2 -0
  340. package/lib/services/history/helpers.js +63 -1
  341. package/lib/services/history/index.js +2 -1
  342. package/lib/services/index.js +9 -1
  343. package/lib/services/menu/builder.js +47 -1
  344. package/lib/services/menu/index.js +2 -1
  345. package/lib/services/menu/markdown.js +93 -1
  346. package/lib/services/menu/operation.js +50 -1
  347. package/lib/services/menu/tags.js +166 -1
  348. package/lib/services/types.d.ts +0 -3
  349. package/lib/services/types.js +2 -0
  350. package/lib/services/utils.js +83 -1
  351. package/lib/standalone.js +68 -1
  352. package/lib/styled-components.js +6 -1
  353. package/lib/types/app.js +2 -0
  354. package/lib/types/index.js +4 -1
  355. package/lib/types/open-api.d.ts +1 -0
  356. package/lib/types/open-api.js +2 -0
  357. package/lib/types/security.js +2 -0
  358. package/lib/utils/JsonPointer.js +84 -1
  359. package/lib/utils/areArraysEqual.js +4 -1
  360. package/lib/utils/argValuesHelpers.js +35 -1
  361. package/lib/utils/compose.js +2 -1
  362. package/lib/utils/configure-helpers.js +223 -1
  363. package/lib/utils/convertSwagger2OpenAPI.js +14 -1
  364. package/lib/utils/cookies.js +73 -1
  365. package/lib/utils/debounce.js +22 -1
  366. package/lib/utils/debug.js +11 -1
  367. package/lib/utils/dom.js +65 -1
  368. package/lib/utils/environments.js +13 -1
  369. package/lib/utils/helpers.js +222 -12
  370. package/lib/utils/index.js +25 -1
  371. package/lib/utils/isMobile.js +13 -1
  372. package/lib/utils/loadAndBundleSpec.js +32 -1
  373. package/lib/utils/local-storage.js +12 -1
  374. package/lib/utils/object.js +31 -1
  375. package/lib/utils/openapi.js +592 -1
  376. package/lib/utils/parameters.js +13 -1
  377. package/lib/utils/path.js +22 -1
  378. package/lib/utils/queryString.js +60 -1
  379. package/lib/utils/replaceVariables.js +14 -1
  380. package/lib/utils/saveTextBeforeHeading.js +35 -1
  381. package/lib/utils/security-details.js +49 -1
  382. package/lib/utils/session-storage.js +12 -1
  383. package/lib/utils/simplifyAstStructure.js +22 -1
  384. package/lib/utils/sort.js +21 -1
  385. package/lib/utils/string.js +65 -1
  386. package/lib/utils/telemetry.js +7 -1
  387. package/lib/utils/test-utils.js +26 -1
  388. package/lib/utils/theme-helpers.js +24 -3
  389. package/lib/utils/url.js +38 -1
  390. package/package.json +5 -5
@@ -1 +1,208 @@
1
- import{isPrimitive as x}from"@redocly/theme/core/openapi";import{getOperation as h}from"../../models/index.js";import{normalizeOptions as v,OpenAPIParser as b}from"../../services/index.js";import{JsonPointer as E}from"../../utils/index.js";function O(t,a,n,r,e,c){if(!n)return;const i=new b(n),s=i.definition.paths?.[t],d=s?.[a],m=h(i,{...d,pathName:t,httpVerb:a,pathParameters:s.parameters||[],pathServers:s.servers||[]},void 0,v({}),"",{isCallback:!1},r);if(!m)return;const f=c?.activeMimeName||"application/json";return{id:m.id,name:m.name,method:m.httpVerb,operationId:m.operationId,parameters:N(m.parameters,e?.requestValues),body:w(m.requestBody,n,e?.requestValues?.body?{activeExampleName:e?.activeExampleName,[f]:e?.requestValues?.body}:e?.activeExampleName?{activeExampleName:e?.activeExampleName}:void 0),path:m.path,href:m.href,servers:m.servers,security:y(m.security),responses:Object.fromEntries(m.responses.map(u=>[u.code,{code:u.code,description:u.description,mediaTypes:u.content?.mediaTypes.reduce((l,o)=>(l[o.name]={name:o.name,schema:p(o.schema?.rawSchema,n)},l),{})}]))}}function P(t){return function(a,n,r){const e=O(a,n,r,t);if(e)return{...e,operationId:e.operationId||E.compile(["paths",e.path,e.method])}}}function N(t,a){const n=new Set,r=t.map(e=>(n.add(e.in+":"+e.name),{name:e.name,in:e.in,required:e.required,description:e.description,example:a?.[String(e.in)]?.[e.name]||e.example,schema:e.schema}));for(const[e,c]of Object.entries(a||{}))for(const[i,s]of Object.entries(c||{}))n.has(e+":"+i)||r.push({name:i,in:e,required:!1,description:"",example:String(s),schema:void 0});return r}function V({type:t,format:a,enum:n}){return t==="string"&&(a==="binary"||a==="base64")?"file":t==="object"?"multiline":n.length>0?"select":"text"}function g(t,a){const n=t[0]?.example||t[0]?.examples;if(n)return n;if(t.schema?.example)return t.schema.example;const r=a?.default?.value||a?.default?.rawValue;return r?.[t.name]?x(r?.[t.name])?String(r?.[t.name]):JSON.stringify(r?.[t.name]):""}function w(t,a,n){if(!t||!t.content?.mediaTypes){if(!n)return;const{activeExampleName:r,...e}=n;return{activeExampleName:r,mediaTypes:Object.fromEntries(Object.entries(e).map(([c,i])=>[c,{name:c,examples:{default:{value:i}},schema:{},parameters:[]}]))}}return{required:t.required,activeExampleName:n?.activeExampleName,mediaTypes:t.content.mediaTypes.reduce((r,e)=>{const c=e.schema,i=n?.[e.name]?{default:{value:n?.[e.name],rawValue:n?.[e.name],mime:e.name}}:e.examples||e.formExamples;return r[e.name]={name:e.name,examples:i,schema:p(e.schema?.rawSchema,a),parameters:c?.fields?.map(s=>({inputType:V(s.schema),name:s.name,example:g(s,i)}))},r},{})}}function p(t,a){if(!(!t||!a))return{...t,components:a?.components||{}}}function y(t){if(t)return t.map(({schemes:a})=>a.map(n=>{const r={id:n.id,type:n.type,in:n.in,openIdConnectUrl:n.openIdConnectUrl,scopes:n.scopes,scheme:n.scheme,name:n.name,flows:n.flows,"x-defaultAccessToken":n["x-defaultAccessToken"],"x-defaultTokenType":n["x-defaultTokenType"],"x-defaultClientId":n["x-defaultClientId"],"x-defaultClientSecret":n["x-defaultClientSecret"],"x-defaultUsername":n["x-defaultUsername"],"x-defaultPassword":n["x-defaultPassword"]};return Object.keys(r).forEach(e=>r[e]===void 0&&delete r[e]),r}))}export{O as convertOperationToReplayValue,P as convertOperationToReplayValueForRedoc,y as convertRequestSecurity};
1
+ import { isPrimitive } from '@redocly/theme/core/openapi';
2
+ import { getOperation, } from '../../models/index.js';
3
+ import { normalizeOptions, OpenAPIParser } from '../../services/index.js';
4
+ import { JsonPointer } from '../../utils/index.js';
5
+ export function convertOperationToReplayValue(path, method, openAPI, userClaims, operationState, appState) {
6
+ if (!openAPI) {
7
+ return undefined;
8
+ }
9
+ const parser = new OpenAPIParser(openAPI);
10
+ const pathItem = parser.definition.paths?.[path];
11
+ const opItem = pathItem?.[method];
12
+ const operation = getOperation(parser, {
13
+ ...opItem,
14
+ pathName: path,
15
+ httpVerb: method,
16
+ pathParameters: pathItem.parameters || [],
17
+ pathServers: pathItem.servers || [],
18
+ }, undefined, normalizeOptions({}), '', { isCallback: false }, userClaims);
19
+ if (!operation) {
20
+ return undefined;
21
+ }
22
+ const activeMime = appState?.activeMimeName || 'application/json';
23
+ const value = {
24
+ id: operation.id,
25
+ name: operation.name,
26
+ method: operation.httpVerb,
27
+ operationId: operation.operationId,
28
+ parameters: convertParameters(operation.parameters, operationState?.requestValues),
29
+ body: convertRequestBody(operation.requestBody, openAPI, operationState?.requestValues?.body
30
+ ? {
31
+ activeExampleName: operationState?.activeExampleName,
32
+ [activeMime]: operationState?.requestValues?.body,
33
+ }
34
+ : operationState?.activeExampleName
35
+ ? { activeExampleName: operationState?.activeExampleName }
36
+ : undefined),
37
+ path: operation.path,
38
+ href: operation.href,
39
+ servers: operation.servers,
40
+ security: convertRequestSecurity(operation.security),
41
+ responses: Object.fromEntries(operation.responses.map((response) => [
42
+ response.code,
43
+ {
44
+ code: response.code,
45
+ description: response.description,
46
+ mediaTypes: response.content?.mediaTypes.reduce((acc, mediaType) => {
47
+ acc[mediaType.name] = {
48
+ name: mediaType.name,
49
+ schema: getBodySchema(mediaType.schema?.rawSchema, openAPI),
50
+ };
51
+ return acc;
52
+ }, {}),
53
+ },
54
+ ])),
55
+ };
56
+ return value;
57
+ }
58
+ export function convertOperationToReplayValueForRedoc(userClaims) {
59
+ return function (path, method, openAPI) {
60
+ const replayValues = convertOperationToReplayValue(path, method, openAPI, userClaims);
61
+ if (!replayValues) {
62
+ return undefined;
63
+ }
64
+ return {
65
+ ...replayValues,
66
+ operationId: replayValues.operationId ||
67
+ JsonPointer.compile(['paths', replayValues.path, replayValues.method]),
68
+ };
69
+ };
70
+ }
71
+ function convertParameters(params, state) {
72
+ const seenParams = new Set();
73
+ const allParams = params.map((param) => {
74
+ seenParams.add(param.in + ':' + param.name);
75
+ return {
76
+ name: param.name,
77
+ in: param.in,
78
+ required: param.required,
79
+ description: param.description,
80
+ example: state?.[String(param.in)]?.[param.name] || param.example,
81
+ schema: param.schema,
82
+ };
83
+ });
84
+ // allow to provide extra params (not defined in the operation spec)
85
+ for (const [inValue, param] of Object.entries(state || {})) {
86
+ for (const [name, example] of Object.entries(param || {})) {
87
+ if (!seenParams.has(inValue + ':' + name)) {
88
+ allParams.push({
89
+ name,
90
+ in: inValue,
91
+ required: false,
92
+ description: '',
93
+ example: String(example),
94
+ schema: undefined,
95
+ });
96
+ }
97
+ }
98
+ }
99
+ return allParams;
100
+ }
101
+ function getInputType({ type, format, enum: enumValue, }) {
102
+ if (type === 'string' && (format === 'binary' || format === 'base64')) {
103
+ return 'file';
104
+ }
105
+ if (type === 'object') {
106
+ return 'multiline';
107
+ }
108
+ if (enumValue.length > 0) {
109
+ return 'select';
110
+ }
111
+ return 'text';
112
+ }
113
+ function getFieldExamples(field, examples) {
114
+ const example = field[0]?.example || field[0]?.examples;
115
+ if (example) {
116
+ return example;
117
+ }
118
+ if (field.schema?.example) {
119
+ return field.schema.example;
120
+ }
121
+ const defaultExample = examples?.['default']?.value || examples?.['default']?.rawValue;
122
+ if (defaultExample?.[field.name]) {
123
+ return isPrimitive(defaultExample?.[field.name])
124
+ ? String(defaultExample?.[field.name])
125
+ : JSON.stringify(defaultExample?.[field.name]);
126
+ }
127
+ return '';
128
+ }
129
+ function convertRequestBody(requestBody, fullOpenApi, state) {
130
+ if (!requestBody || !requestBody.content?.mediaTypes) {
131
+ if (!state)
132
+ return undefined;
133
+ const { activeExampleName, ...rest } = state;
134
+ return {
135
+ activeExampleName,
136
+ mediaTypes: Object.fromEntries(Object.entries(rest).map(([key, value]) => [
137
+ key,
138
+ { name: key, examples: { default: { value } }, schema: {}, parameters: [] },
139
+ ])),
140
+ };
141
+ }
142
+ return {
143
+ required: requestBody.required,
144
+ activeExampleName: state?.activeExampleName,
145
+ mediaTypes: requestBody.content.mediaTypes.reduce((acc, mediaType) => {
146
+ const schemaModel = mediaType.schema;
147
+ const examples = state?.[mediaType.name]
148
+ ? {
149
+ default: {
150
+ value: state?.[mediaType.name],
151
+ rawValue: state?.[mediaType.name],
152
+ mime: mediaType.name,
153
+ },
154
+ }
155
+ : mediaType.examples || mediaType.formExamples;
156
+ acc[mediaType.name] = {
157
+ name: mediaType.name,
158
+ examples: examples,
159
+ schema: getBodySchema(mediaType.schema?.rawSchema, fullOpenApi),
160
+ parameters: schemaModel?.fields?.map((field) => {
161
+ // www-form-urlencoded and form-data
162
+ return {
163
+ inputType: getInputType(field.schema),
164
+ name: field.name,
165
+ example: getFieldExamples(field, examples),
166
+ };
167
+ }),
168
+ };
169
+ return acc;
170
+ }, {}),
171
+ };
172
+ }
173
+ function getBodySchema(schema, rootDefinition) {
174
+ if (!schema || !rootDefinition)
175
+ return undefined;
176
+ return {
177
+ ...schema,
178
+ components: rootDefinition?.components || {}, // add components to schema in case there are $refs in the original schema
179
+ };
180
+ }
181
+ export function convertRequestSecurity(security) {
182
+ if (!security) {
183
+ return undefined;
184
+ }
185
+ return security.map(({ schemes }) => {
186
+ return schemes.map((s) => {
187
+ const securityScheme = {
188
+ id: s.id,
189
+ type: s.type,
190
+ in: s.in,
191
+ openIdConnectUrl: s.openIdConnectUrl,
192
+ scopes: s.scopes,
193
+ scheme: s.scheme,
194
+ name: s.name,
195
+ flows: s.flows,
196
+ 'x-defaultAccessToken': s['x-defaultAccessToken'],
197
+ 'x-defaultTokenType': s['x-defaultTokenType'],
198
+ 'x-defaultClientId': s['x-defaultClientId'],
199
+ 'x-defaultClientSecret': s['x-defaultClientSecret'],
200
+ 'x-defaultUsername': s['x-defaultUsername'],
201
+ 'x-defaultPassword': s['x-defaultPassword'],
202
+ };
203
+ Object.keys(securityScheme).forEach((key) => securityScheme[key] === undefined && delete securityScheme[key]);
204
+ return securityScheme;
205
+ });
206
+ });
207
+ }
208
+ //# sourceMappingURL=utils.js.map
@@ -1,3 +1,34 @@
1
- import{jsx as e,jsxs as s,Fragment as q}from"react/jsx-runtime";import{memo as v,useMemo as P}from"react";import{useAtomValue as A}from"jotai";import{Row as N}from"../common/index.js";import{Title as j}from"../common/OperationItemTitle.js";import{LinkToField as k}from"../common/LinkToField.js";import{makeDeepLink as y}from"../../services/index.js";import{Description as D}from"../OperationItem/Description.js";import{Security as M}from"../Security/index.js";import{ExpandAllButton as T}from"../ExpandAllButton/index.js";import{RequestParameters as w}from"../RequestParameters/index.js";import{activeMimeNameAtom as C}from"../../jotai/app.js";import{getActiveMediaType as F}from"../../models/mediaContent.js";import{styled as _}from"../../styled-components.js";function b({operation:{id:r,description:m,externalDocs:n,parameters:i,requestBody:o,pointer:c,security:l,extensions:u,callbackId:d},title:f,translate:h,onPanelToggle:x}){const a=A(C),R=P(()=>{const p=i.some(({schema:t})=>!t.isPrimitive&&!t.isCircular);if(!o?.content||p)return p;const{schema:g}=F(o.content,a)||{};return g?.fields?.some(({schema:t})=>!t.isPrimitive&&!t.isCircular)},[a,i,o?.content]);return s(q,{children:[e(N,{children:s(E,{children:[s(j,{children:[r&&e(k,{to:y(r,"request")}),f||h?.("openapi.request","Request"),R&&e(T,{operationPointer:c,type:"request",onPanelToggle:x})]}),e(D,{description:m||n?m:void 0,externalDocs:n,extensions:u}),e(M,{securities:l})]})}),e(w,{parameters:i,body:o,operationId:r,callbackId:d})]})}const E=_.div`
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { memo, useMemo } from 'react';
3
+ import { useAtomValue } from 'jotai';
4
+ import { Row } from '../common/index.js';
5
+ import { Title } from '../common/OperationItemTitle.js';
6
+ import { LinkToField } from '../common/LinkToField.js';
7
+ import { makeDeepLink } from '../../services/index.js';
8
+ import { Description } from '../OperationItem/Description.js';
9
+ import { Security } from '../Security/index.js';
10
+ import { ExpandAllButton } from '../ExpandAllButton/index.js';
11
+ import { RequestParameters } from '../RequestParameters/index.js';
12
+ import { activeMimeNameAtom } from '../../jotai/app.js';
13
+ import { getActiveMediaType } from '../../models/mediaContent.js';
14
+ import { styled } from '../../styled-components.js';
15
+ import { Extensions } from '../common/Extensions.js';
16
+ function RequestDetailsComponent({ operation: { id, description, externalDocs, parameters, requestBody, pointer, security, extensions, callbackId, }, title, translate, onPanelToggle, }) {
17
+ const activeMimeName = useAtomValue(activeMimeNameAtom);
18
+ const showExpandAllButton = useMemo(() => {
19
+ const hasNestedParameters = parameters.some(({ schema }) => !schema.isPrimitive && !schema.isCircular);
20
+ if (!requestBody?.content || hasNestedParameters) {
21
+ return hasNestedParameters;
22
+ }
23
+ const { schema } = getActiveMediaType(requestBody.content, activeMimeName) || {};
24
+ const hasNestedRequestBody = schema?.fields?.some(({ schema: fieldSchema }) => !fieldSchema.isPrimitive && !fieldSchema.isCircular);
25
+ return hasNestedRequestBody;
26
+ }, [activeMimeName, parameters, requestBody?.content]);
27
+ const hasCustomExtensions = Object.keys(extensions || {}).length > 0;
28
+ return (_jsxs(_Fragment, { children: [_jsx(Row, { children: _jsxs(HeadingWrapper, { children: [_jsxs(Title, { children: [id && _jsx(LinkToField, { to: makeDeepLink(id, 'request') }), title || translate?.('openapi.request', 'Request'), showExpandAllButton && (_jsx(ExpandAllButton, { operationPointer: pointer, type: "request", onPanelToggle: onPanelToggle }))] }), _jsx(Description, { description: description || externalDocs ? description : undefined, externalDocs: externalDocs }), hasCustomExtensions && _jsx(Extensions, { extensions: extensions }), _jsx(Security, { securities: security })] }) }), _jsx(RequestParameters, { parameters: parameters, body: requestBody, operationId: id, callbackId: callbackId })] }));
29
+ }
30
+ const HeadingWrapper = styled.div `
2
31
  width: 100%;
3
- `,Y=v(b);export{Y as RequestDetails};
32
+ `;
33
+ export const RequestDetails = memo(RequestDetailsComponent);
34
+ //# sourceMappingURL=RequestDetails.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1,8 @@
1
- import{jsx as t}from"react/jsx-runtime";import{memo as p}from"react";import{BodyContent as s}from"../common/BodyContent/index.js";function n({content:e,description:o,required:i,deepLink:r}){return t(s,{content:e,required:i,description:o,skipReadOnly:e.isRequestType,skipWriteOnly:!e.isRequestType,deepLink:r})}const u=p(n);export{u as Body};
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { BodyContent } from '../common/BodyContent/index.js';
4
+ function BodyComponent({ content, description, required, deepLink, }) {
5
+ return (_jsx(BodyContent, { content: content, required: required, description: description, skipReadOnly: content.isRequestType, skipWriteOnly: !content.isRequestType, deepLink: deepLink }));
6
+ }
7
+ export const Body = memo(BodyComponent);
8
+ //# sourceMappingURL=Body.js.map
@@ -1,4 +1,17 @@
1
- import{jsx as o,jsxs as t}from"react/jsx-runtime";import{memo as p}from"react";import{LinkIcon as m}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{PropertyDetails as l}from"../PropertyDetails/index.js";import{LinkToField as c}from"../common/LinkToField.js";import{styled as e}from"../../styled-components.js";function g({title:n,parameters:i,deepLink:s}){return!i||!i.length?null:t(v,{children:[t(f,{children:[o(c,{to:s}),n]}),i.map((r,a)=>o(l,{isFirst:a===0,field:r},r.name))]})}const b=p(g),f=e.span`
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { LinkIcon } from '@redocly/theme/icons/LinkIcon/LinkIcon';
4
+ import { PropertyDetails } from '../PropertyDetails/index.js';
5
+ import { LinkToField } from '../common/LinkToField.js';
6
+ import { styled } from '../../styled-components.js';
7
+ function ParametersGroupComponent({ title, parameters, deepLink, }) {
8
+ if (!parameters || !parameters.length) {
9
+ return null;
10
+ }
11
+ return (_jsxs(Wrapper, { children: [_jsxs(Title, { children: [_jsx(LinkToField, { to: deepLink }), title] }), parameters.map((field, index) => (_jsx(PropertyDetails, { isFirst: index === 0, field: field }, field.name)))] }));
12
+ }
13
+ export const ParametersGroup = memo(ParametersGroupComponent);
14
+ const Title = styled.span `
2
15
  position: relative;
3
16
  display: flex;
4
17
  align-items: center;
@@ -10,11 +23,13 @@ import{jsx as o,jsxs as t}from"react/jsx-runtime";import{memo as p}from"react";i
10
23
  padding: var(--spacing-xxs) 0;
11
24
 
12
25
  :hover {
13
- ${m} {
26
+ ${LinkIcon} {
14
27
  opacity: 1;
15
28
  visibility: visible;
16
29
  }
17
30
  }
18
- `,v=e.div`
31
+ `;
32
+ const Wrapper = styled.div `
19
33
  margin-top: var(--spacing-md);
20
- `;export{b as ParametersGroup};
34
+ `;
35
+ //# sourceMappingURL=ParametersGroup.js.map
@@ -1 +1,40 @@
1
- import{jsx as p,Fragment as A,jsxs as k}from"react/jsx-runtime";import{ParametersGroup as x}from"./ParametersGroup.js";import{Body as y}from"./Body.js";import{makeDeepLink as _}from"../../services/index.js";import{useTranslate as g}from"../../hooks/index.js";const o=["path","query","cookie","header"];function j({body:r,parameters:e=[],operationId:t,callbackId:s}){const i=g();if(!r&&!e.length)return null;const f={[o[0]]:i("openapi.path","Path"),[o[1]]:i("openapi.query","Query"),[o[2]]:i("openapi.cookie","Cookies"),[o[3]]:i("openapi.header","Headers")},d=(n=>{const u={};return n.forEach(m=>{L(u,m.in,m)}),u})(e),h=e.length>0?o:[],{content:a,description:P,required:q}=r||{};return k(A,{children:[h.map(n=>p(x,{title:f[n],parameters:d[n],deepLink:c(t,s,n)},n)),a&&p(y,{content:a,description:P,required:q,deepLink:c(t,s)})]})}function L(r,e="",t){r[e]||(r[e]=[]),r[e].push(t)}function c(r,e,t="body"){const s=`${e?`${e}/request/${t}`:`request/${t}`}`;return _(r,s)}export{j as RequestParameters};
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ParametersGroup } from './ParametersGroup.js';
3
+ import { Body } from './Body.js';
4
+ import { makeDeepLink } from '../../services/index.js';
5
+ import { useTranslate } from '../../hooks/index.js';
6
+ const PARAM_PLACES = ['path', 'query', 'cookie', 'header'];
7
+ export function RequestParameters({ body, parameters = [], operationId, callbackId, }) {
8
+ const translate = useTranslate();
9
+ if (!body && !parameters.length) {
10
+ return null;
11
+ }
12
+ const PARAM_NAMES_MAP = {
13
+ [PARAM_PLACES[0]]: translate('openapi.path', 'Path'),
14
+ [PARAM_PLACES[1]]: translate('openapi.query', 'Query'),
15
+ [PARAM_PLACES[2]]: translate('openapi.cookie', 'Cookies'),
16
+ [PARAM_PLACES[3]]: translate('openapi.header', 'Headers'),
17
+ };
18
+ const orderParams = (params) => {
19
+ const res = {};
20
+ params.forEach((param) => {
21
+ safePush(res, param.in, param);
22
+ });
23
+ return res;
24
+ };
25
+ const paramsMap = orderParams(parameters);
26
+ const paramsPlaces = parameters.length > 0 ? PARAM_PLACES : [];
27
+ const { content: bodyContent, description: bodyDescription, required } = body || {};
28
+ return (_jsxs(_Fragment, { children: [paramsPlaces.map((place) => (_jsx(ParametersGroup, { title: PARAM_NAMES_MAP[place], parameters: paramsMap[place], deepLink: generateDeepLink(operationId, callbackId, place) }, place))), bodyContent && (_jsx(Body, { content: bodyContent, description: bodyDescription, required: required, deepLink: generateDeepLink(operationId, callbackId) }))] }));
29
+ }
30
+ function safePush(obj, prop = '', item) {
31
+ if (!obj[prop]) {
32
+ obj[prop] = [];
33
+ }
34
+ obj[prop].push(item);
35
+ }
36
+ function generateDeepLink(operationId, callbackId, place = 'body') {
37
+ const suffix = `${callbackId ? `${callbackId}/request/${place}` : `request/${place}`}`;
38
+ return makeDeepLink(operationId, suffix);
39
+ }
40
+ //# sourceMappingURL=RequestParameters.js.map
@@ -1 +1,4 @@
1
- import{RequestParameters as o}from"./RequestParameters.js";import{ParametersGroup as m}from"./ParametersGroup.js";import{Body as p}from"./Body.js";export{p as Body,m as ParametersGroup,o as RequestParameters};
1
+ export { RequestParameters } from './RequestParameters.js';
2
+ export { ParametersGroup } from './ParametersGroup.js';
3
+ export { Body } from './Body.js';
4
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,56 @@
1
- import{jsx as r}from"react/jsx-runtime";import{memo as d,useCallback as l}from"react";import{CodeBlock as i}from"@redocly/theme/components/CodeBlock/CodeBlock";import{SelectOrLabel as s}from"../SelectOrLabel/index.js";import{MediaTypesSwitch as u}from"../MediaTypeSwitch/index.js";import{SelectWrapper as S}from"../PayloadSamples/index.js";import{Example as h}from"./Example.js";import{MimeLabel as f,Select as b}from"../common/index.js";import{styled as g}from"../../styled-components.js";function p({onCopyClick:o,...e}){const t=e.operation.requestBody?.content,c=l(a=>(t?.mediaTypes?.length??0)>1?r(S,{children:r(s,{Label:f,Select:b,variant:"dark",fullWidth:!0,...a})}):null,[t]),n=l(a=>e.source?r(m,{lang:e.lang,source:e.source,header:{className:"code-block-header",controls:{copy:{onClick:o}}}}):r(m,{lang:e.lang,externalSource:{sample:e.externalSample,exampleName:a,operation:e.operation,pathParams:e.pathParams,properties:e.properties},header:{className:"code-block-header",controls:{copy:{onClick:o}}}}),[o,e.externalSample,e.lang,e.operation,e.pathParams,e.properties,e.source]);return t===void 0||e.source!=null?n():r(u,{content:t,renderSelect:c,children:a=>r(h,{mediaType:a,mediaContent:t,renderSample:n})})}const M=d(p),m=g(i)`
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo, useCallback } from 'react';
3
+ import { CodeBlock } from '@redocly/theme/components/CodeBlock/CodeBlock';
4
+ import { SelectOrLabel } from '../SelectOrLabel/index.js';
5
+ import { MediaTypesSwitch } from '../MediaTypeSwitch/index.js';
6
+ import { SelectWrapper } from '../PayloadSamples/index.js';
7
+ import { Example } from './Example.js';
8
+ import { MimeLabel, Select } from '../common/index.js';
9
+ import { styled } from '../../styled-components.js';
10
+ function CodeSampleComponent({ onCopyClick, ...props }) {
11
+ const mimeContent = props.operation.requestBody?.content;
12
+ const renderSelect = useCallback((props) => {
13
+ const hasSelect = (mimeContent?.mediaTypes?.length ?? 0) > 1;
14
+ return hasSelect ? (_jsx(SelectWrapper, { children: _jsx(SelectOrLabel, { Label: MimeLabel, Select: Select, variant: "dark", fullWidth: true, ...props }) })) : null;
15
+ }, [mimeContent]);
16
+ const renderSample = useCallback((exampleName) => {
17
+ return props.source ? (_jsx(StyledCodeBlock, { lang: props.lang, source: props.source, header: {
18
+ className: 'code-block-header',
19
+ controls: {
20
+ copy: {
21
+ onClick: onCopyClick,
22
+ },
23
+ },
24
+ } })) : (_jsx(StyledCodeBlock, { lang: props.lang, externalSource: {
25
+ sample: props.externalSample,
26
+ exampleName,
27
+ operation: props.operation,
28
+ pathParams: props.pathParams,
29
+ properties: props.properties,
30
+ }, header: {
31
+ className: 'code-block-header',
32
+ controls: {
33
+ copy: {
34
+ onClick: onCopyClick,
35
+ },
36
+ },
37
+ } }));
38
+ }, [
39
+ onCopyClick,
40
+ props.externalSample,
41
+ props.lang,
42
+ props.operation,
43
+ props.pathParams,
44
+ props.properties,
45
+ props.source,
46
+ ]);
47
+ if (mimeContent === undefined || props.source != undefined) {
48
+ return renderSample();
49
+ }
50
+ return (_jsx(MediaTypesSwitch, { content: mimeContent, renderSelect: renderSelect, children: (mediaType) => (_jsx(Example, { mediaType: mediaType, mediaContent: mimeContent, renderSample: renderSample })) }));
51
+ }
52
+ export const CodeSample = memo(CodeSampleComponent);
53
+ const StyledCodeBlock = styled(CodeBlock) `
2
54
  border: none;
3
55
  margin: 0;
4
56
 
@@ -6,4 +58,5 @@ import{jsx as r}from"react/jsx-runtime";import{memo as d,useCallback as l}from"r
6
58
  border-bottom: 0;
7
59
  padding-right: var(--spacing-sm);
8
60
  }
9
- `;export{M as CodeSample};
61
+ `;
62
+ //# sourceMappingURL=CodeSample.js.map
@@ -1 +1,37 @@
1
- import{jsx as c,Fragment as f,jsxs as h}from"react/jsx-runtime";import{memo as u}from"react";import{useAtom as E}from"jotai";import{ExampleSwitch as g,useExampleKey as _}from"../Samples/index.js";import{useActivateExample as d,useTelemetry as j}from"../../hooks/index.js";import{operationStore as y}from"../../jotai/operation.js";function O({mediaType:o,mediaContent:p,renderSample:n}){const r=j(),m=o.operation.pointer,[l,x]=E(y(m)),a=o.examples||{},e=Object.keys(a),i=d(p),{exampleKey:s}=_(o.operation,a);return!e.length||e.length===1?n():h(f,{children:[c(g,{examples:a,exampleKey:s,onChange:t=>{r.send({type:"openapi_docs.examples_switcher.clicked",payload:{example:t,number_of_examples:e.length}}),x({...l,activeExampleName:t,activeOneOf:{[m]:e.indexOf(t)},requestValues:{body:null}}),i(t)}}),n(s)]})}const N=u(O);export{N as Example};
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { useAtom } from 'jotai';
4
+ import { ExampleSwitch, useExampleKey } from '../Samples/index.js';
5
+ import { useActivateExample, useTelemetry } from '../../hooks/index.js';
6
+ import { operationStore } from '../../jotai/operation.js';
7
+ function ExampleComponent({ mediaType, mediaContent, renderSample }) {
8
+ const telemetry = useTelemetry();
9
+ const pointer = mediaType.operation.pointer;
10
+ const [operation, setOperation] = useAtom(operationStore(pointer));
11
+ const examples = mediaType.examples || {};
12
+ const examplesKeys = Object.keys(examples);
13
+ const setActivateExampleName = useActivateExample(mediaContent);
14
+ const { exampleKey } = useExampleKey(mediaType.operation, examples);
15
+ if (!examplesKeys.length || examplesKeys.length === 1) {
16
+ return renderSample();
17
+ }
18
+ const handleExampleChange = (key) => {
19
+ telemetry.send({
20
+ type: 'openapi_docs.examples_switcher.clicked',
21
+ payload: {
22
+ example: key,
23
+ numberOfExamples: examplesKeys.length,
24
+ },
25
+ });
26
+ setOperation({
27
+ ...operation,
28
+ activeExampleName: key,
29
+ activeOneOf: { [pointer]: examplesKeys.indexOf(key) },
30
+ requestValues: { body: null },
31
+ });
32
+ setActivateExampleName(key);
33
+ };
34
+ return (_jsxs(_Fragment, { children: [_jsx(ExampleSwitch, { examples: examples, exampleKey: exampleKey, onChange: handleExampleChange }), renderSample(exampleKey)] }));
35
+ }
36
+ export const Example = memo(ExampleComponent);
37
+ //# sourceMappingURL=Example.js.map
@@ -1,12 +1,96 @@
1
- import{jsx as o,jsxs as D}from"react/jsx-runtime";import{memo as M,useCallback as k,useMemo as A}from"react";import{useAtomValue as y,useAtom as T}from"jotai";import{PanelHeader as U}from"@redocly/theme/components/Panel/PanelHeader";import{PayloadSamples as W}from"../PayloadSamples/index.js";import{CodeSample as B}from"./CodeSample.js";import{useCodeSamples as F}from"./useCodeSamples.js";import{isPayloadSample as H}from"../../models/index.js";import{createCodeSampleCopyEvent as O,createLanguageSwitchEvent as V}from"../../events/index.js";import{globalStoreAtom as $}from"../../jotai/store.js";import{ServerListDropdown as z}from"../ServerListDropdown/index.js";import{LanguageDropdown as G}from"../Language/index.js";import{activeMimeNameAtom as J,languageAtom as K}from"../../jotai/app.js";import{Replay as L}from"../Replay/index.js";import{CodeBlockPanel as w}from"../common/index.js";import{useActiveWithFallback as Q,useTelemetry as X}from"../../hooks/index.js";import{operationStore as Y}from"../../jotai/operation.js";import{styled as v}from"../../styled-components.js";function Z({operation:a,disableFooter:P,onPanelToggle:S,...p}){const c=X(),[{activeLanguage:q,languages:m},R]=T(K),{samples:n}=F(a),{parser:d,options:{events:s,corsProxyUrl:g,hideReplay:_}}=y($),i=!P&&!a.isWebhook&&!_&&!a.hideReplay,t=!!m?.length,u=Q(n,q),E=e=>{R(e),c.send({type:"openapi_docs.select_language.clicked",payload:{language:e}});const r=m?.find(l=>l.key===e);if(s?.codeSamplesLanguageSwitch&&r){const l=V({operation:a,sample:{lang:r.lang,label:r.title}});s.codeSamplesLanguageSwitch(l)}},h=y(J),{activeExampleName:x}=y(Y(a.pointer)),f=k(({lang:e,title:r})=>()=>{const l=O({operation:a,label:r,lang:e,type:"request",activeMimeName:h,activeExampleName:x});c.send({type:"openapi_docs.copy_code_snippet.clicked",payload:{snippet_type:"request",language:e}}),s?.codeSamplesCopy?.(l)},[a,c,s,h,x]),b=k(e=>{S?.(e,"request-samples")},[S]),C=()=>D(I,{isExpandable:!1,withReplay:!t&&i,children:[o(ee,{operation:a}),t&&o(G,{activeTab:u,samples:n,onChange:E}),!t&&i&&o(L,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})]}),j=A(()=>{if(i&&t)return o(ae,{children:o(L,{operation:a,corsProxyUrl:g,fullOpenApi:d.definition})})},[i,t,a,g,d.definition]),N=A(()=>n.map(e=>e.key===u?o("div",{children:H(e)?o(W,{content:e.requestBodyContent,onCopyClick:f(e),onPanelToggle:b,...p}):o(B,{lang:e.lang,source:e.source,externalSample:e,operation:a,onCopyClick:f(e),...p})},e.key+a.id):null),[u,f,b,a,p,n]);return m&&!n.length?o(w,{className:"panel-request-samples",header:C,isExpandable:!1,expanded:!1}):n.length?o(w,{className:"panel-request-samples",header:C,footer:j,isExpandable:!1,children:N}):null}const xe=M(Z),I=v(U)`
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useCallback, useMemo } from 'react';
3
+ import { useAtomValue, useAtom } from 'jotai';
4
+ import { PanelHeader } from '@redocly/theme/components/Panel/PanelHeader';
5
+ import { PayloadSamples } from '../PayloadSamples/index.js';
6
+ import { CodeSample } from './CodeSample.js';
7
+ import { useCodeSamples } from './useCodeSamples.js';
8
+ import { isPayloadSample } from '../../models/index.js';
9
+ import { createCodeSampleCopyEvent, createLanguageSwitchEvent } from '../../events/index.js';
10
+ import { globalStoreAtom } from '../../jotai/store.js';
11
+ import { ServerListDropdown } from '../ServerListDropdown/index.js';
12
+ import { LanguageDropdown } from '../Language/index.js';
13
+ import { activeMimeNameAtom, languageAtom } from '../../jotai/app.js';
14
+ import { Replay } from '../Replay/index.js';
15
+ import { CodeBlockPanel } from '../common/index.js';
16
+ import { useActiveWithFallback, useTelemetry } from '../../hooks/index.js';
17
+ import { operationStore } from '../../jotai/operation.js';
18
+ import { styled } from '../../styled-components.js';
19
+ function RequestSamplesComponent({ operation, disableFooter, onPanelToggle, ...props }) {
20
+ const telemetry = useTelemetry();
21
+ const [{ activeLanguage, languages }, setLanguage] = useAtom(languageAtom);
22
+ const { samples } = useCodeSamples(operation);
23
+ const { parser, options: { events, corsProxyUrl, hideReplay }, } = useAtomValue(globalStoreAtom);
24
+ const isReplayAvailable = !disableFooter && !operation.isWebhook && !hideReplay && !operation.hideReplay;
25
+ const isLanguagesAvailable = !!languages?.length;
26
+ const localActiveLanguage = useActiveWithFallback(samples, activeLanguage);
27
+ const onSelectLanguage = (selectedItem) => {
28
+ setLanguage(selectedItem);
29
+ telemetry.send({
30
+ type: 'openapi_docs.select_language.clicked',
31
+ payload: { language: selectedItem },
32
+ });
33
+ const selectedSampleDetails = languages?.find((lang) => lang.key === selectedItem);
34
+ if (events?.codeSamplesLanguageSwitch && selectedSampleDetails) {
35
+ const eventPayload = createLanguageSwitchEvent({
36
+ operation: operation,
37
+ sample: {
38
+ lang: selectedSampleDetails.lang,
39
+ label: selectedSampleDetails.title,
40
+ },
41
+ });
42
+ events.codeSamplesLanguageSwitch(eventPayload);
43
+ }
44
+ };
45
+ const activeMimeName = useAtomValue(activeMimeNameAtom);
46
+ const { activeExampleName } = useAtomValue(operationStore(operation.pointer));
47
+ const handleCodeSampleCopy = useCallback(({ lang, title }) => () => {
48
+ const event = createCodeSampleCopyEvent({
49
+ operation: operation,
50
+ label: title,
51
+ lang,
52
+ type: 'request',
53
+ activeMimeName,
54
+ activeExampleName,
55
+ });
56
+ telemetry.send({
57
+ type: 'openapi_docs.copy_code_snippet.clicked',
58
+ payload: { snippetType: 'request', language: lang },
59
+ });
60
+ events?.codeSamplesCopy?.(event);
61
+ }, [operation, telemetry, events, activeMimeName, activeExampleName]);
62
+ const handlePanelToggle = useCallback((isExpanded) => {
63
+ onPanelToggle?.(isExpanded, 'request-samples');
64
+ }, [onPanelToggle]);
65
+ const renderSummary = () => {
66
+ return (_jsxs(StyledPanelHeader, { isExpandable: false, withReplay: !isLanguagesAvailable && isReplayAvailable, children: [_jsx(StyledServerListDropdown, { operation: operation }), isLanguagesAvailable && (_jsx(LanguageDropdown, { activeTab: localActiveLanguage, samples: samples, onChange: onSelectLanguage })), !isLanguagesAvailable && isReplayAvailable && (_jsx(Replay, { operation: operation, corsProxyUrl: corsProxyUrl, fullOpenApi: parser.definition }))] }));
67
+ };
68
+ const renderFooter = useMemo(() => {
69
+ if (isReplayAvailable && isLanguagesAvailable) {
70
+ return (_jsx(ReplayWrapper, { children: _jsx(Replay, { operation: operation, corsProxyUrl: corsProxyUrl, fullOpenApi: parser.definition }) }));
71
+ }
72
+ }, [isReplayAvailable, isLanguagesAvailable, operation, corsProxyUrl, parser.definition]);
73
+ const renderSamples = useMemo(() => samples.map((sample) => {
74
+ return sample.key === localActiveLanguage ? (_jsx("div", { children: isPayloadSample(sample) ? (_jsx(PayloadSamples, { content: sample.requestBodyContent, onCopyClick: handleCodeSampleCopy(sample), onPanelToggle: handlePanelToggle, ...props })) : (_jsx(CodeSample, { lang: sample.lang, source: sample.source, externalSample: sample, operation: operation, onCopyClick: handleCodeSampleCopy(sample), ...props })) }, sample.key + operation.id)) : null;
75
+ }), [localActiveLanguage, handleCodeSampleCopy, handlePanelToggle, operation, props, samples]);
76
+ if (languages && !samples.length) {
77
+ return (_jsx(CodeBlockPanel, { className: "panel-request-samples", header: renderSummary, isExpandable: false, expanded: false }));
78
+ }
79
+ return samples.length ? (_jsx(CodeBlockPanel, { className: "panel-request-samples", header: renderSummary, footer: renderFooter, isExpandable: false, children: renderSamples })) : null;
80
+ }
81
+ export const RequestSamples = memo(RequestSamplesComponent);
82
+ const StyledPanelHeader = styled(PanelHeader) `
2
83
  flex-wrap: nowrap;
3
- ${({withReplay:a})=>a&&"padding: var(--spacing-xs) var(--spacing-sm);"}
4
- `,ee=v(z)`
84
+ ${({ withReplay }) => withReplay && 'padding: var(--spacing-xs) var(--spacing-sm);'}
85
+ `;
86
+ const StyledServerListDropdown = styled(ServerListDropdown) `
5
87
  padding-right: var(--spacing-base);
6
88
  min-width: 0;
7
- `,ae=v.div`
89
+ `;
90
+ const ReplayWrapper = styled.div `
8
91
  display: flex;
9
92
  justify-content: flex-end;
10
93
  border-top: var(--panel-border);
11
94
  padding: var(--spacing-base) var(--spacing-md) var(--spacing-md);
12
- `;export{xe as RequestSamples};
95
+ `;
96
+ //# sourceMappingURL=RequestSamples.js.map
@@ -1 +1,3 @@
1
- import{CodeSample as m}from"./CodeSample.js";import{RequestSamples as r}from"./RequestSamples.js";export{m as CodeSample,r as RequestSamples};
1
+ export { CodeSample } from './CodeSample.js';
2
+ export { RequestSamples } from './RequestSamples.js';
3
+ //# sourceMappingURL=index.js.map