@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,111 @@
1
- import{CodeBuilder as k}from"../../helpers/code-builder.js";import{buildUrlExpression as x,printUrlVariablesDeclarations as D}from"../../helpers/code-helpers.js";import{Lang as v}from"../../helpers/constants.js";import{HTTPSnippet as j}from"../../index.js";import{normalizeMimeType as w}from"../../../../utils.js";import{MediaTypes as p}from"../../../../../constants.js";import{postDataToRListBody as h,objectToRString as b}from"./utils.js";const o=1,P=function(a,f,{target:m,client:c}){const r=Object.assign({indent:" ",showBoilerplate:!0,printBody:!0},f),t=new k({indentation:r.indent,variablesPrefix:r.variablesPrefix,lang:v.R}),u=a.method.toUpperCase(),l=a.securityOAuth2ExtraCalls?.[0];if(r.showBoilerplate&&t.push("library(httr)").blank(),l){const e="oauth2_",i=new j(l).convert(m,c,{...r,variablesPrefix:e,showBoilerplate:!1}),y=`${e}data_req`;t.push(i).push(`access_token = content(${y}, "parsed")$access_token`).blank(),a.allHeaders.Authorization='paste("Bearer", access_token)'}let n,s="";if(a?.postData)switch(w(a?.postData?.mimeType)){case p.URL_ENCODED:{n="form",s=t.var("body");const e=h(a.postData.params,r);t.push(`${s} <- list(${e})`).blank();break}case p.JSON:{n="json",s=t.var("body");const e=b(a.postData.jsonObj,r);t.push(`${s} = '${e}'`).blank();break}case p.MULTIPART:{n="multipart",s=t.var("body");const e=h(a.postData.params,r);t.push(`${s} <- list(${e})`).blank();break}default:a.postData?.text&&(s=t.var("body"),n="raw",t.push(`${s} = ${b(a.postData?.text)}`).blank())}D(a,t),Object.keys({...a.pathParameters,...a.serverVariables}).length&&t.blank().push("# create you own operator").push('"%&%" <- function(x, y)paste0(x,y)').blank();const $=x(a,t);t.push(`url = ${$}`).blank();const d=t.var("data_req");if(t.push(`${d} <- ${u}(`),t.push(o,"url,"),a.basicAuth){const{username:e,password:i}=a.basicAuth;t.push(o,`authenticate("${e}", "${i}")`)}if(Object.keys(a.allHeaders).length){const e=`${Object.keys(a.allHeaders).map(i=>`"${i}" = ${a.allHeaders[i].startsWith("paste")?a.allHeaders[i]:`"${a.allHeaders[i]}"`}`).join(", ")}`;e&&t.push(o,`add_headers(${e}),`)}return s&&(t.push(o,`body = ${s},`),t.push(o,`encode = "${n}",`)),t.push(o,"verbose()"),t.push(")"),r.printBody&&t.blank().push(`content(${d}${n==="raw"?', "text"':""})`),t.join()};var H=P;export{H as default};
1
+ import { CodeBuilder } from '../../helpers/code-builder.js';
2
+ import { buildUrlExpression, printUrlVariablesDeclarations } from '../../helpers/code-helpers.js';
3
+ import { Lang } from '../../helpers/constants.js';
4
+ import { HTTPSnippet } from '../../index.js';
5
+ import { normalizeMimeType } from '../../../../utils.js';
6
+ import { MediaTypes } from '../../../../../constants.js';
7
+ import { postDataToRListBody, objectToRString } from './utils.js';
8
+ const indent = 1;
9
+ const handler = function (source, originalOptions, { target, client }) {
10
+ const options = Object.assign({ indent: ' ', showBoilerplate: true, printBody: true }, originalOptions);
11
+ const code = new CodeBuilder({
12
+ indentation: options.indent,
13
+ variablesPrefix: options.variablesPrefix,
14
+ lang: Lang.R,
15
+ });
16
+ const reqMethod = source.method.toUpperCase();
17
+ const securityOAuth2ExtraCalls = source.securityOAuth2ExtraCalls?.[0];
18
+ if (options.showBoilerplate) {
19
+ code.push('library(httr)').blank();
20
+ }
21
+ if (securityOAuth2ExtraCalls) {
22
+ const prefix = 'oauth2_';
23
+ const oAuth2PrefixCode = new HTTPSnippet(securityOAuth2ExtraCalls).convert(target, client, {
24
+ ...options,
25
+ variablesPrefix: prefix,
26
+ showBoilerplate: false,
27
+ });
28
+ const responseVariable = `${prefix}data_req`;
29
+ code
30
+ .push(oAuth2PrefixCode)
31
+ .push(`access_token = content(${responseVariable}, "parsed")$access_token`)
32
+ .blank();
33
+ source.allHeaders.Authorization = `paste("Bearer", access_token)`;
34
+ }
35
+ // Print all the post data
36
+ let encode;
37
+ let bodyVariableName = '';
38
+ if (source?.postData) {
39
+ switch (normalizeMimeType(source?.postData?.mimeType)) {
40
+ case MediaTypes.URL_ENCODED: {
41
+ encode = 'form';
42
+ bodyVariableName = code.var('body');
43
+ const stringifiedPostData = postDataToRListBody(source.postData.params, options);
44
+ code.push(`${bodyVariableName} <- list(${stringifiedPostData})`).blank();
45
+ break;
46
+ }
47
+ case MediaTypes.JSON: {
48
+ encode = 'json';
49
+ bodyVariableName = code.var('body');
50
+ const stringifiedPostData = objectToRString(source.postData.jsonObj, options);
51
+ code.push(`${bodyVariableName} = '${stringifiedPostData}'`).blank();
52
+ break;
53
+ }
54
+ case MediaTypes.MULTIPART: {
55
+ encode = 'multipart';
56
+ bodyVariableName = code.var('body');
57
+ const stringifiedPostData = postDataToRListBody(source.postData.params, options);
58
+ code.push(`${bodyVariableName} <- list(${stringifiedPostData})`).blank();
59
+ break;
60
+ }
61
+ default:
62
+ if (source.postData?.text) {
63
+ bodyVariableName = code.var('body');
64
+ encode = 'raw';
65
+ code.push(`${bodyVariableName} = ${objectToRString(source.postData?.text)}`).blank();
66
+ }
67
+ }
68
+ }
69
+ // print option parameter
70
+ printUrlVariablesDeclarations(source, code);
71
+ if (Object.keys({ ...source.pathParameters, ...source.serverVariables }).length) {
72
+ code
73
+ .blank()
74
+ .push('# create you own operator')
75
+ .push('"%&%" <- function(x, y)paste0(x,y)')
76
+ .blank();
77
+ }
78
+ const url = buildUrlExpression(source, code);
79
+ code.push(`url = ${url}`).blank();
80
+ // make request
81
+ const requestVariableName = code.var('data_req');
82
+ code.push(`${requestVariableName} <- ${reqMethod}(`);
83
+ code.push(indent, 'url,');
84
+ if (source.basicAuth) {
85
+ const { username, password } = source.basicAuth;
86
+ code.push(indent, `authenticate("${username}", "${password}")`);
87
+ }
88
+ if (Object.keys(source.allHeaders).length) {
89
+ const headersCode = `${Object.keys(source.allHeaders)
90
+ .map((key) => `"${key}" = ${source.allHeaders[key].startsWith('paste')
91
+ ? source.allHeaders[key]
92
+ : `"${source.allHeaders[key]}"`}`)
93
+ .join(', ')}`;
94
+ if (headersCode) {
95
+ code.push(indent, `add_headers(${headersCode}),`);
96
+ }
97
+ }
98
+ if (bodyVariableName) {
99
+ code.push(indent, `body = ${bodyVariableName},`);
100
+ code.push(indent, `encode = "${encode}",`);
101
+ }
102
+ code.push(indent, 'verbose()');
103
+ code.push(')');
104
+ // Print code that makes response
105
+ if (options.printBody) {
106
+ code.blank().push(`content(${requestVariableName}${encode === 'raw' ? ', "text"' : ''})`);
107
+ }
108
+ return code.join();
109
+ };
110
+ export default handler;
111
+ //# sourceMappingURL=httr.js.map
@@ -1 +1,11 @@
1
- import t from"./httr.js";var r={info:{key:"r",title:"R",extname:".r",default:"httr"},httr:t};export{r as default};
1
+ import httr from './httr.js';
2
+ export default {
3
+ info: {
4
+ key: 'r',
5
+ title: 'R',
6
+ extname: '.r',
7
+ default: 'httr',
8
+ },
9
+ httr,
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,18 @@
1
- function e(n,t){return n?typeof n=="string"?JSON.stringify(n):JSON.stringify(n,null,1).split(`
2
- `).map((o,r,i)=>r===i.length-1?o:(t?.indent||" ")+o).join(`
3
- `).trim():""}function f(n,t){return`
4
- `+n.map(({name:r,value:i})=>(t?.indent||"")+`${r} = "${i}"`).join(`,
5
- `)+`
6
- `}export{e as objectToRString,f as postDataToRListBody};
1
+ export function objectToRString(input, options) {
2
+ if (!input)
3
+ return '';
4
+ if (typeof input === 'string')
5
+ return JSON.stringify(input);
6
+ return JSON.stringify(input, null, 1)
7
+ .split('\n')
8
+ .map((line, index, arr) => index === arr.length - 1 ? line : (options?.indent || ' ') + line)
9
+ .join('\n')
10
+ .trim();
11
+ }
12
+ export function postDataToRListBody(input, options) {
13
+ const body = input
14
+ .map(({ name, value }) => (options?.indent || '') + `${name} = "${value}"`)
15
+ .join(',\n');
16
+ return '\n' + body + '\n';
17
+ }
18
+ //# sourceMappingURL=utils.js.map
@@ -1 +1,11 @@
1
- import e from"./native.js";var a={info:{key:"ruby",title:"Ruby",extname:".rb",default:"native"},native:e};export{a as default};
1
+ import native from './native.js';
2
+ export default {
3
+ info: {
4
+ key: 'ruby',
5
+ title: 'Ruby',
6
+ extname: '.rb',
7
+ default: 'native',
8
+ },
9
+ native,
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -1 +1,169 @@
1
- import l from"stringify-object";import{CodeBuilder as c}from"../../helpers/code-builder.js";import{HTTPSnippet as $}from"../../index.js";import{Lang as T}from"../../helpers/constants.js";import{buildUrlExpression as O,printUrlVariablesDeclarations as v}from"../../helpers/code-helpers.js";import{normalizeMimeType as u}from"../../../../utils.js";import{MediaTypes as i}from"../../../../../constants.js";const y=1;function E(t={},p){return u(t.mimeType)===p}const H=function(t,p,{target:d,client:f}){const n=t.method.toUpperCase(),o=t.securityOAuth2ExtraCalls?.[0],r={capitalize:!0,showBoilerplate:!0,indent:" ",...p},e=new c({indentation:r.indent,variablesPrefix:r.variablesPrefix,capitalize:r.capitalize,lang:T.RUBY});r.showBoilerplate&&(e.push("require 'uri'").push("require 'net/http'"),t.uriObj.protocol==="https:"&&e.push("require 'openssl'"),(E(t.postData,i.JSON)||o)&&e.unshift("require 'json'"),e.blank()),Object.keys(t.allHeaders).length&&Object.keys(t.allHeaders).forEach(a=>{t.allHeaders[a]=`'${t.allHeaders[a]}'`});const b=["GET","POST","HEAD","DELETE","PATCH","PUT","OPTIONS","COPY","LOCK","UNLOCK","MOVE","TRACE"],h=n.charAt(0)+n.substring(1).toLowerCase();if(b.indexOf(n)<0&&e.push("class Net::HTTP::%s < Net::HTTPRequest",h).push(" METHOD = '%s'",n.toUpperCase()).push(" REQUEST_HAS_BODY = '%s'",t.postData?.text?"true":"false").push(" RESPONSE_HAS_BODY = true").push("end").blank(),o){const a="oAuth2",s=new $(o).convert(d,f,{...r,variablesPrefix:a,showBoilerplate:!1}),m=`${a}${r.capitalize?"Response":"response"}`;e.push(s).push(`access_token = JSON.parse(${m}.body)['access_token']`).blank(),t.allHeaders.Authorization='"Bearer " + access_token'}if(v(t,e),e.push(`${e.var("url")} = URI(${O(t,e)})`),Object.getOwnPropertyNames(t.queryObj).length&&(e.push(`${e.var("params")} = ${l(t.queryObj,{indent:r.indent,inlineCharacterLimit:25})}`),e.push(`${e.var("url")}.query = URI.encode_www_form(${e.var("params")})`)),e.blank().push(`${e.var("http")} = Net::HTTP.new(${e.var("url")}.host, ${e.var("url")}.port)`),t.uriObj.protocol==="https:"&&e.push(`${e.var("http")}.use_ssl = true`),e.blank().push(`${e.var("request")} = Net::HTTP::%s.new(${e.var("url")})`,h),Object.keys(t.allHeaders).length&&Object.keys(t.allHeaders).forEach(a=>{t.allHeaders[a]!==`'${i.MULTIPART}'`&&e.push(`${e.var("request")}['%s'] = %s`,a,t.allHeaders[a])}),t?.postData){const a={};switch(u(t?.postData?.mimeType)){case i.URL_ENCODED:t.postData.params.forEach(s=>{a[s.name]=s.value}),e.push(`${e.var("request")}.body = URI.encode_www_form(${l(a,{indent:r.indent,inlineCharacterLimit:25})})`);break;case i.JSON:e.push(`${e.var("request")}.body = ${l(t.postData.jsonObj,{indent:r.indent,inlineCharacterLimit:25}).replace(/null/g,"nil")}.to_json`);break;case i.MULTIPART:t.postData.params&&(e.push(`${e.var("form_data")} = [`),t.postData.params.forEach(s=>{e.push(y,`['${s.name}', '${s.value}'],`)}),e.push("]")),e.push(`${e.var("request")}.set_form(${e.var("form_data")}, '${i.MULTIPART}')`);break;default:t.postData?.text&&e.push(`${e.var("request")}.body = ${JSON.stringify(t.postData?.text)}`)}}if(t.basicAuth){const{username:a,password:s}=t.basicAuth;e.push(`${e.var("request")}.basic_auth('${a}', '${s}')`)}return e.blank().push(`${e.var("response")} = ${e.var("http")}.request(${e.var("request")})`).push(`puts ${e.var("response")}.read_body`).blank(),e.join()},C={key:"native",title:"net::http",link:"http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html",description:"Ruby HTTP client"};var U=H;export{U as default,C as info};
1
+ import stringifyObject from 'stringify-object';
2
+ import { CodeBuilder } from '../../helpers/code-builder.js';
3
+ import { HTTPSnippet } from '../../index.js';
4
+ import { Lang } from '../../helpers/constants.js';
5
+ import { buildUrlExpression, printUrlVariablesDeclarations } from '../../helpers/code-helpers.js';
6
+ import { normalizeMimeType } from '../../../../utils.js';
7
+ import { MediaTypes } from '../../../../../constants.js';
8
+ const indent = 1;
9
+ function hasMimeType(postData = {}, mimeType) {
10
+ return normalizeMimeType(postData.mimeType) === mimeType;
11
+ }
12
+ const handler = function (source, originalOptions, { target, client }) {
13
+ const reqMethod = source.method.toUpperCase();
14
+ const securityOAuth2ExtraCalls = source.securityOAuth2ExtraCalls?.[0];
15
+ const options = {
16
+ capitalize: true,
17
+ showBoilerplate: true,
18
+ indent: ' ',
19
+ ...originalOptions,
20
+ };
21
+ const code = new CodeBuilder({
22
+ indentation: options.indent,
23
+ variablesPrefix: options.variablesPrefix,
24
+ capitalize: options.capitalize,
25
+ lang: Lang.RUBY,
26
+ });
27
+ // Print boilerplate with packages initialization:
28
+ if (options.showBoilerplate) {
29
+ code.push(`require 'uri'`).push(`require 'net/http'`);
30
+ if (source.uriObj.protocol === 'https:') {
31
+ code.push(`require 'openssl'`);
32
+ }
33
+ if (hasMimeType(source.postData, MediaTypes.JSON) || securityOAuth2ExtraCalls) {
34
+ code.unshift(`require 'json'`);
35
+ }
36
+ code.blank();
37
+ }
38
+ // Put headers values into quotation marks
39
+ if (Object.keys(source.allHeaders).length) {
40
+ Object.keys(source.allHeaders).forEach((key) => {
41
+ source.allHeaders[key] = `'${source.allHeaders[key]}'`;
42
+ });
43
+ }
44
+ // To support custom methods we check for the supported methods
45
+ // and if doesn't exist then we build a custom class for it
46
+ const methods = [
47
+ 'GET',
48
+ 'POST',
49
+ 'HEAD',
50
+ 'DELETE',
51
+ 'PATCH',
52
+ 'PUT',
53
+ 'OPTIONS',
54
+ 'COPY',
55
+ 'LOCK',
56
+ 'UNLOCK',
57
+ 'MOVE',
58
+ 'TRACE',
59
+ ];
60
+ const capMethod = reqMethod.charAt(0) + reqMethod.substring(1).toLowerCase();
61
+ if (methods.indexOf(reqMethod) < 0) {
62
+ code
63
+ .push('class Net::HTTP::%s < Net::HTTPRequest', capMethod)
64
+ .push(" METHOD = '%s'", reqMethod.toUpperCase())
65
+ .push(" REQUEST_HAS_BODY = '%s'", source.postData?.text ? 'true' : 'false')
66
+ .push(' RESPONSE_HAS_BODY = true')
67
+ .push('end')
68
+ .blank();
69
+ }
70
+ // If we have extra OAuth calls - print code for that
71
+ if (securityOAuth2ExtraCalls) {
72
+ const prefix = 'oAuth2';
73
+ const oAuth2PrefixCode = new HTTPSnippet(securityOAuth2ExtraCalls).convert(target, client, {
74
+ ...options,
75
+ variablesPrefix: prefix,
76
+ showBoilerplate: false,
77
+ });
78
+ const responseVariable = `${prefix}${options.capitalize ? 'Response' : 'response'}`;
79
+ code
80
+ .push(oAuth2PrefixCode)
81
+ .push(`access_token = JSON.parse(${responseVariable}.body)['access_token']`)
82
+ .blank();
83
+ source.allHeaders.Authorization = `"Bearer " + access_token`;
84
+ }
85
+ // Print the URL with path variables if present
86
+ printUrlVariablesDeclarations(source, code);
87
+ code.push(`${code.var('url')} = URI(${buildUrlExpression(source, code)})`);
88
+ // Print query variables if present
89
+ const hasQueryVariables = Object.getOwnPropertyNames(source.queryObj).length;
90
+ if (hasQueryVariables) {
91
+ code.push(`${code.var('params')} = ${stringifyObject(source.queryObj, {
92
+ indent: options.indent,
93
+ inlineCharacterLimit: 25,
94
+ })}`);
95
+ code.push(`${code.var('url')}.query = URI.encode_www_form(${code.var('params')})`);
96
+ }
97
+ // Print code with client initialization
98
+ code
99
+ .blank()
100
+ .push(`${code.var('http')} = Net::HTTP.new(${code.var('url')}.host, ${code.var('url')}.port)`);
101
+ if (source.uriObj.protocol === 'https:') {
102
+ code.push(`${code.var('http')}.use_ssl = true`);
103
+ }
104
+ code.blank().push(`${code.var('request')} = Net::HTTP::%s.new(${code.var('url')})`, capMethod);
105
+ // Print headers
106
+ if (Object.keys(source.allHeaders).length) {
107
+ Object.keys(source.allHeaders).forEach((key) => {
108
+ if (source.allHeaders[key] !== `'${MediaTypes.MULTIPART}'`) {
109
+ // we'll set multipart/form-data later
110
+ code.push(`${code.var('request')}['%s'] = %s`, key, source.allHeaders[key]);
111
+ }
112
+ });
113
+ }
114
+ // Print all the post data
115
+ if (source?.postData) {
116
+ const paramsObj = {};
117
+ switch (normalizeMimeType(source?.postData?.mimeType)) {
118
+ case MediaTypes.URL_ENCODED:
119
+ source.postData.params.forEach((param) => {
120
+ paramsObj[param.name] = param.value;
121
+ });
122
+ code.push(`${code.var('request')}.body = URI.encode_www_form(${stringifyObject(paramsObj, {
123
+ indent: options.indent,
124
+ inlineCharacterLimit: 25,
125
+ })})`);
126
+ break;
127
+ case MediaTypes.JSON:
128
+ code.push(`${code.var('request')}.body = ${stringifyObject(source.postData.jsonObj, {
129
+ indent: options.indent,
130
+ inlineCharacterLimit: 25,
131
+ }).replace(/null/g, 'nil')}.to_json`);
132
+ break;
133
+ case MediaTypes.MULTIPART:
134
+ if (source.postData.params) {
135
+ code.push(`${code.var('form_data')} = [`);
136
+ source.postData.params.forEach((param) => {
137
+ code.push(indent, `['${param.name}', '${param.value}'],`);
138
+ });
139
+ code.push(']');
140
+ }
141
+ code.push(`${code.var('request')}.set_form(${code.var('form_data')}, '${MediaTypes.MULTIPART}')`);
142
+ break;
143
+ default:
144
+ if (source.postData?.text) {
145
+ code.push(`${code.var('request')}.body = ${JSON.stringify(source.postData?.text)}`);
146
+ }
147
+ }
148
+ }
149
+ // Print basic auth code if present
150
+ if (source.basicAuth) {
151
+ const { username, password } = source.basicAuth;
152
+ code.push(`${code.var('request')}.basic_auth('${username}', '${password}')`);
153
+ }
154
+ // Print code that makes response
155
+ code
156
+ .blank()
157
+ .push(`${code.var('response')} = ${code.var('http')}.request(${code.var('request')})`)
158
+ .push(`puts ${code.var('response')}.read_body`)
159
+ .blank();
160
+ return code.join();
161
+ };
162
+ export const info = {
163
+ key: 'native',
164
+ title: 'net::http',
165
+ link: 'http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html',
166
+ description: 'Ruby HTTP client',
167
+ };
168
+ export default handler;
169
+ //# sourceMappingURL=native.js.map
@@ -1,6 +1,94 @@
1
- import{format as i}from"util";import{CodeBuilder as u}from"../../helpers/code-builder.js";import n from"../../helpers/shell.js";import{addIndentation as d,buildUrlExpression as b}from"../../helpers/code-helpers.js";import{normalizeMimeType as c}from"../../../../utils.js";import{HTTPSnippet as y}from"../../index.js";import{MediaTypes as r}from"../../../../../constants.js";const x=function(t,p,{target:h,client:f}){const e=Object.assign({indent:" ",short:!1,binary:!1},p),s=new u({indentation:e.indent,lineJoin:e.indent?` \\
2
- `+e.indent:" "}),l=t.securityOAuth2ExtraCalls?.length?new y(t.securityOAuth2ExtraCalls?.[0]).convert(h,f,{...e,withComments:!1}):"";s.push(0,"curl -i %s %s",e.short?"-X":"--request",t.method.toUpperCase()),t.basicAuth&&s.push(i("-u %s:%s",t.basicAuth.username,t.basicAuth.password));const m=b(t,s);if(s.push(i("%s%s",e.short?"":"--url ",n.quote(m))),t.httpVersion==="HTTP/1.0"&&s.push(e.short?"-0":"--http1.0"),Object.keys(t.headersObj).sort().forEach(function(a){const o=i("%s: %s",a,t.headersObj[a]);s.push("%s %s",e.short?"-H":"--header",n.quote(o))}),t.allHeaders.cookie&&s.push("%s %s",e.short?"-b":"--cookie",n.quote(t.allHeaders.cookie)),t.postData)switch(c(t.postData.mimeType)){case r.MULTIPART:t.postData.params.map(function(a){let o;a.fileName?o=i("%s=@%s",a.name,a.fileName):o=i("%s=%s",a.name,a.value),s.push("%s %s",e.short?"-F":"--form",n.quote(o))});break;case r.URL_ENCODED:t.postData.params?t.postData.params.map(function(a){s.push("%s %s",e.binary?"--data-binary":e.short?"-d":"--data",n.quote(i("%s=%s",a.name,a.value)))}):s.push("%s %s",e.binary?"--data-binary":e.short?"-d":"--data",n.quote(t.postData.text));break;case r.JSON:t.postData.jsonObj&&s.push("%s %s",e.binary?"--data-binary":e.short?"-d":"--data",d(n.quote(JSON.stringify(t.postData.jsonObj,null,e.indent)),{level:1,indent:e.indent,firstLine:!1}));break;default:t.postData.text&&s.push("%s %s",e.binary?"--data-binary":e.short?"-d":"--data",d(n.quote(t.postData.text),{level:1,indent:e.indent,firstLine:!1}))}return(e.withComments?`# Requires curl >= 7.2
3
-
4
- `:"")+(l?l+`
5
-
6
- `+s.join():s.join())},A={key:"curl",title:"curl",link:"http://curl.haxx.se/",description:"cURL is a command line tool and library for transferring data with URL syntax"};var L=x;export{L as default,A as info};
1
+ import { format } from 'util';
2
+ import { CodeBuilder } from '../../helpers/code-builder.js';
3
+ import shellHelpers from '../../helpers/shell.js';
4
+ import { addIndentation, buildUrlExpression } from '../../helpers/code-helpers.js';
5
+ import { normalizeMimeType } from '../../../../utils.js';
6
+ import { HTTPSnippet } from '../../index.js';
7
+ import { MediaTypes } from '../../../../../constants.js';
8
+ const handler = function (source, originalOptions, { target, client }) {
9
+ const options = Object.assign({
10
+ indent: ' ',
11
+ short: false,
12
+ binary: false,
13
+ }, originalOptions);
14
+ const code = new CodeBuilder({
15
+ indentation: options.indent,
16
+ lineJoin: options.indent ? ' \\\n' + options.indent : ' ',
17
+ });
18
+ const oAuth2PrefixCode = source.securityOAuth2ExtraCalls?.length
19
+ ? new HTTPSnippet(source.securityOAuth2ExtraCalls?.[0]).convert(target, client, {
20
+ ...options,
21
+ withComments: false,
22
+ })
23
+ : '';
24
+ code.push(0, 'curl -i %s %s', options.short ? '-X' : '--request', source.method.toUpperCase());
25
+ if (source.basicAuth) {
26
+ code.push(format('-u %s:%s', source.basicAuth.username, source.basicAuth.password));
27
+ }
28
+ const URL = buildUrlExpression(source, code);
29
+ code.push(format('%s%s', options.short ? '' : '--url ', shellHelpers.quote(URL)));
30
+ if (source.httpVersion === 'HTTP/1.0') {
31
+ code.push(options.short ? '-0' : '--http1.0');
32
+ }
33
+ // construct headers
34
+ Object.keys(source.headersObj)
35
+ .sort()
36
+ .forEach(function (key) {
37
+ const header = format('%s: %s', key, source.headersObj[key]);
38
+ code.push('%s %s', options.short ? '-H' : '--header', shellHelpers.quote(header));
39
+ });
40
+ if (source.allHeaders.cookie) {
41
+ code.push('%s %s', options.short ? '-b' : '--cookie', shellHelpers.quote(source.allHeaders.cookie));
42
+ }
43
+ // construct post params
44
+ if (source.postData) {
45
+ switch (normalizeMimeType(source.postData.mimeType)) {
46
+ case MediaTypes.MULTIPART:
47
+ source.postData.params.map(function (param) {
48
+ let post;
49
+ if (param.fileName) {
50
+ post = format('%s=@%s', param.name, param.fileName);
51
+ }
52
+ else {
53
+ post = format('%s=%s', param.name, param.value);
54
+ }
55
+ code.push('%s %s', options.short ? '-F' : '--form', shellHelpers.quote(post));
56
+ });
57
+ break;
58
+ case MediaTypes.URL_ENCODED:
59
+ if (source.postData.params) {
60
+ source.postData.params.map(function (param) {
61
+ code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', shellHelpers.quote(format('%s=%s', param.name, param.value)));
62
+ });
63
+ }
64
+ else {
65
+ code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', shellHelpers.quote(source.postData.text));
66
+ }
67
+ break;
68
+ case MediaTypes.JSON:
69
+ if (source.postData.jsonObj) {
70
+ code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', addIndentation(shellHelpers.quote(JSON.stringify(source.postData.jsonObj, null, options.indent)), { level: 1, indent: options.indent, firstLine: false }));
71
+ }
72
+ break;
73
+ default:
74
+ // raw request body
75
+ if (source.postData.text) {
76
+ code.push('%s %s', options.binary ? '--data-binary' : options.short ? '-d' : '--data', addIndentation(shellHelpers.quote(source.postData.text), {
77
+ level: 1,
78
+ indent: options.indent,
79
+ firstLine: false,
80
+ }));
81
+ }
82
+ }
83
+ }
84
+ const commentPrefixCode = options.withComments ? '# Requires curl >= 7.2\n\n' : '';
85
+ return (commentPrefixCode + (oAuth2PrefixCode ? oAuth2PrefixCode + '\n\n' + code.join() : code.join()));
86
+ };
87
+ export const info = {
88
+ key: 'curl',
89
+ title: 'curl',
90
+ link: 'http://curl.haxx.se/',
91
+ description: 'cURL is a command line tool and library for transferring data with URL syntax',
92
+ };
93
+ export default handler;
94
+ //# sourceMappingURL=curl.js.map
@@ -1 +1,11 @@
1
- import e from"./curl.js";var t={info:{key:"shell",title:"Shell",extname:".sh",default:"curl"},curl:e};export{t as default};
1
+ import curl from './curl.js';
2
+ export default {
3
+ info: {
4
+ key: 'shell',
5
+ title: 'Shell',
6
+ extname: '.sh',
7
+ default: 'curl',
8
+ },
9
+ curl,
10
+ };
11
+ //# sourceMappingURL=index.js.map
@@ -1 +1,3 @@
1
- export*from"./generator.js";export*from"./types.js";
1
+ export * from './generator.js';
2
+ export * from './types.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1,49 @@
1
- import{querySelector as o}from"../../utils/dom.js";import{isNumeric as r}from"../../utils/helpers.js";function i(e){if(typeof e>"u")return!1;if(e==="")return!0;if(typeof e!="string")return e;switch(e){case"true":return!0;case"false":return!1;default:return e.split(",").map(t=>t.trim())}}function u(e){if(typeof e=="string"&&!r(e)){const t=o(e);t||console.warn("scrollYOffset value is a selector to non-existing element. Using offset 0 by default");const n=t&&t.getBoundingClientRect().bottom||0;return()=>n}else{if(typeof e=="number"||r(e))return()=>typeof e=="number"?e:parseFloat(e);if(typeof e=="function")return()=>{const t=e();return typeof t!="number"&&console.warn(`scrollYOffset should return number but returned value "${t}" of type ${typeof t}`),t};e!==void 0&&console.warn("Wrong value for scrollYOffset ReDoc option: should be string, number or function")}return()=>0}export{u as normalizeScrollYOffset,i as normalizeShowExtensions};
1
+ import { querySelector } from '../../utils/dom.js';
2
+ import { isNumeric } from '../../utils/helpers.js';
3
+ export function normalizeShowExtensions(value) {
4
+ if (typeof value === 'undefined') {
5
+ return false;
6
+ }
7
+ if (value === '') {
8
+ return true;
9
+ }
10
+ if (typeof value !== 'string') {
11
+ return value;
12
+ }
13
+ switch (value) {
14
+ case 'true':
15
+ return true;
16
+ case 'false':
17
+ return false;
18
+ default:
19
+ return value.split(',').map((ext) => ext.trim());
20
+ }
21
+ }
22
+ export function normalizeScrollYOffset(value) {
23
+ // just number is not valid selector and leads to crash so checking if isNumeric here
24
+ if (typeof value === 'string' && !isNumeric(value)) {
25
+ const el = querySelector(value);
26
+ if (!el) {
27
+ console.warn('scrollYOffset value is a selector to non-existing element. Using offset 0 by default');
28
+ }
29
+ const bottom = (el && el.getBoundingClientRect().bottom) || 0;
30
+ return () => bottom;
31
+ }
32
+ else if (typeof value === 'number' || isNumeric(value)) {
33
+ return () => (typeof value === 'number' ? value : parseFloat(value));
34
+ }
35
+ else if (typeof value === 'function') {
36
+ return () => {
37
+ const res = value();
38
+ if (typeof res !== 'number') {
39
+ console.warn(`scrollYOffset should return number but returned value "${res}" of type ${typeof res}`);
40
+ }
41
+ return res;
42
+ };
43
+ }
44
+ else if (value !== undefined) {
45
+ console.warn('Wrong value for scrollYOffset ReDoc option: should be string, number or function');
46
+ }
47
+ return () => 0;
48
+ }
49
+ //# sourceMappingURL=helpers.js.map
@@ -1 +1,3 @@
1
- export*from"./normalizeOptions.js";export*from"./types.js";
1
+ export * from './normalizeOptions.js';
2
+ export * from './types.js';
3
+ //# sourceMappingURL=index.js.map
@@ -1 +1,83 @@
1
- import{LayoutVariant as d}from"@redocly/config";import{isUndefined as m,addTrailingSlash as r}from"@redocly/theme/core/openapi";import{WindowReferenceOptions as i}from"../../constants.js";import{argValueToBoolean as o,argValueToExpandLevel as a,argValueToInt as p,argValueToNumber as c,getWindowReferenceOptions as t,normalizePath as h}from"../../utils/index.js";import{normalizeShowExtensions as u,normalizeScrollYOffset as f}from"./helpers.js";import{Languages as S}from"../code-samples/constants.js";function v(e,s){e={...s,...e,markdocOptions:{...e?.markdocOptions,components:{...s?.markdocOptions?.components,...e?.markdocOptions?.components},tags:{...s?.markdocOptions?.tags,...e?.markdocOptions?.tags},nodes:{...s?.markdocOptions?.nodes,...e?.markdocOptions?.nodes,heading:s?.markdocOptions?.nodes?.heading||e?.markdocOptions?.nodes.heading}}};const l=Array.isArray(e.ignoreNamedSchemas)?e.ignoreNamedSchemas:e.ignoreNamedSchemas?.split(",").map(n=>n.trim());return{downloadUrls:e.downloadUrls,schemaDefinitionsTagName:e.schemaDefinitionsTagName,corsProxyUrl:e.corsProxyUrl&&r(e.corsProxyUrl),hideSidebar:o(e.hideSidebar,!1),jsonSamplesExpandLevel:a(e.jsonSamplesExpandLevel,2),generatedSamplesMaxDepth:p(e.generatedSamplesMaxDepth,8),hideDownloadButtons:o(e.hideDownloadButtons,!1),hideInfoMetadata:o(e.hideInfoMetadata,!1),hideLoading:o(e.hideLoading,!1),hideSchemaTitles:o(e.hideSchemaTitles,!1),maxDisplayedEnumValues:c(e.maxDisplayedEnumValues),mockServer:e.mockServer?.url?{url:e.mockServer.url,position:e.mockServer.position||"first",description:e.mockServer.description||"Mock server"}:void 0,hideReplay:o(e.hideReplay,!1),oAuth2RedirectURI:e.oAuth2RedirectURI||null,onlyRequiredInSamples:o(e.onlyRequiredInSamples,!1),onDeepLinkClick:e.onDeepLinkClick||t(i.ON_DEEP_LINK_CLICK),requestInterceptor:e.requestInterceptor||t(i.REQUEST_INTERCEPTOR),routingBasePath:m(e.disableRouter)?"":e.routingBasePath&&h(e.routingBasePath)||"",schemasExpansionLevel:a(e.schemasExpansionLevel),feedback:e.feedback||{hide:!1},sortRequiredPropsFirst:o(e.sortRequiredPropsFirst,!1),scrollYOffset:f(e.scrollYOffset),showExtensions:u(e.showExtensions),sanitize:o(e.sanitize,!1),skipBundle:o(e.skipBundle,!1),ignoreNamedSchemas:new Set(l),markdocOptions:e?.markdocOptions,codeSamples:e.codeSamples||{languages:Object.values(S).map(n=>({lang:n}))},layout:e.layout||d.THREE_PANEL,events:e.events||{},unstable_hooks:e.unstable_hooks||t(i.HOOKS)||{},unstable_skipSamples:o(e.unstable_skipSamples,!1),unstable_externalCodeSamples:e.unstable_externalCodeSamples||[],hidePropertiesPrefix:o(e?.hidePropertiesPrefix,!1)}}export{v as normalizeOptions};
1
+ import { LayoutVariant } from '@redocly/config';
2
+ import { isUndefined, addTrailingSlash } from '@redocly/theme/core/openapi';
3
+ import { WindowReferenceOptions } from '../../constants.js';
4
+ import { argValueToBoolean, argValueToExpandLevel, argValueToInt, argValueToNumber, getWindowReferenceOptions, normalizePath, } from '../../utils/index.js';
5
+ import { normalizeShowExtensions, normalizeScrollYOffset } from './helpers.js';
6
+ import { Languages } from '../code-samples/constants.js';
7
+ export function normalizeOptions(raw, defaultOptions) {
8
+ raw = {
9
+ ...defaultOptions,
10
+ ...raw,
11
+ markdocOptions: {
12
+ ...raw?.markdocOptions,
13
+ components: {
14
+ ...defaultOptions?.markdocOptions?.components,
15
+ ...raw?.markdocOptions?.components,
16
+ },
17
+ tags: {
18
+ ...defaultOptions?.markdocOptions?.tags,
19
+ ...raw?.markdocOptions?.tags,
20
+ },
21
+ nodes: {
22
+ ...defaultOptions?.markdocOptions?.nodes,
23
+ ...raw?.markdocOptions?.nodes,
24
+ heading: (defaultOptions?.markdocOptions?.nodes?.heading ||
25
+ raw?.markdocOptions?.nodes.heading),
26
+ },
27
+ },
28
+ };
29
+ const ignoreNamedSchemas = Array.isArray(raw.ignoreNamedSchemas)
30
+ ? raw.ignoreNamedSchemas
31
+ : raw.ignoreNamedSchemas?.split(',').map((s) => s.trim());
32
+ const normalizedOptions = {
33
+ downloadUrls: raw.downloadUrls,
34
+ schemaDefinitionsTagName: raw.schemaDefinitionsTagName,
35
+ // TODO: validate URL and error here
36
+ corsProxyUrl: raw.corsProxyUrl && addTrailingSlash(raw.corsProxyUrl),
37
+ hideSidebar: argValueToBoolean(raw.hideSidebar, false),
38
+ jsonSamplesExpandLevel: argValueToExpandLevel(raw.jsonSamplesExpandLevel, 2),
39
+ generatedSamplesMaxDepth: argValueToInt(raw.generatedSamplesMaxDepth, 8),
40
+ hideDownloadButtons: argValueToBoolean(raw.hideDownloadButtons, false),
41
+ hideInfoMetadata: argValueToBoolean(raw.hideInfoMetadata, false),
42
+ hideLoading: argValueToBoolean(raw.hideLoading, false),
43
+ hideSchemaTitles: argValueToBoolean(raw.hideSchemaTitles, false),
44
+ maxDisplayedEnumValues: argValueToNumber(raw.maxDisplayedEnumValues),
45
+ mockServer: raw.mockServer?.url
46
+ ? {
47
+ url: raw.mockServer.url,
48
+ position: raw.mockServer.position || 'first',
49
+ description: raw.mockServer.description || 'Mock server',
50
+ }
51
+ : undefined,
52
+ hideReplay: argValueToBoolean(raw.hideReplay, false),
53
+ oAuth2RedirectURI: raw.oAuth2RedirectURI || null,
54
+ onlyRequiredInSamples: argValueToBoolean(raw.onlyRequiredInSamples, false),
55
+ onDeepLinkClick: raw.onDeepLinkClick || getWindowReferenceOptions(WindowReferenceOptions.ON_DEEP_LINK_CLICK),
56
+ requestInterceptor: raw.requestInterceptor ||
57
+ getWindowReferenceOptions(WindowReferenceOptions.REQUEST_INTERCEPTOR),
58
+ routingBasePath: isUndefined(raw.disableRouter)
59
+ ? ''
60
+ : (raw.routingBasePath && normalizePath(raw.routingBasePath)) || '',
61
+ schemasExpansionLevel: argValueToExpandLevel(raw.schemasExpansionLevel),
62
+ feedback: raw.feedback || { hide: false },
63
+ sortRequiredPropsFirst: argValueToBoolean(raw.sortRequiredPropsFirst, false),
64
+ scrollYOffset: normalizeScrollYOffset(raw.scrollYOffset),
65
+ showExtensions: normalizeShowExtensions(raw.showExtensions),
66
+ sanitize: argValueToBoolean(raw.sanitize, false),
67
+ skipBundle: argValueToBoolean(raw.skipBundle, false),
68
+ ignoreNamedSchemas: new Set(ignoreNamedSchemas),
69
+ markdocOptions: raw?.markdocOptions,
70
+ codeSamples: raw.codeSamples || {
71
+ languages: Object.values(Languages).map((lang) => ({ lang })),
72
+ },
73
+ layout: raw.layout || LayoutVariant.THREE_PANEL,
74
+ events: raw.events || {},
75
+ unstable_hooks: raw.unstable_hooks || getWindowReferenceOptions(WindowReferenceOptions.HOOKS) || {},
76
+ unstable_skipSamples: argValueToBoolean(raw.unstable_skipSamples, false),
77
+ unstable_externalCodeSamples: raw.unstable_externalCodeSamples || [],
78
+ // New options
79
+ hidePropertiesPrefix: argValueToBoolean(raw?.hidePropertiesPrefix, false),
80
+ };
81
+ return normalizedOptions;
82
+ }
83
+ //# sourceMappingURL=normalizeOptions.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map