@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,592 @@
1
- import{dirname as y}from"path";import f from"url-template";import{IS_BROWSER as M}from"@redocly/theme/core/openapi";import{deleteEmptyArrayItem as E,isArrayOfObjects as T,isNumeric as S,removeQueryStringAndHash as z,resolveUrl as D,sanitizeItemId as m,normalizeText as b,getValueFromMdParsedExtension as g,isAbsoluteUrl as N}from"./helpers.js";import{DEFAULT_TAG_SLUG as R,MediaTypes as j}from"../constants.js";import{JsonPointer as $}from"./JsonPointer.js";import{joinWithSeparator as _}from"../services/index.js";import{tryDecodeURIComponent as F}from"./string.js";import{getUrlDirname as U}from"./url.js";function P(e){return typeof e=="string"&&/\dxx/i.test(e)}function ne(e){return e==="default"||S(e)||P(e)}function ie(e,r=!1){if(e==="default")return r?"error":"success";let t=typeof e=="string"?parseInt(e,10):e;if(P(e)&&(t*=100),t<100||t>599)throw new Error("invalid HTTP code");let n="success";return t>=300&&t<400?n="redirect":t>=400?n="error":t<200&&(n="info"),n}const L={get:!0,post:!0,put:!0,head:!0,patch:!0,delete:!0,options:!0,$ref:!0};function oe(e){return e in L}function ue(e){const{operationId:r,pathName:t}=e,n=b(g(e,"description"));return b(g(e,"summary"))||r||n&&n.substring(0,50)||t||"<no summary>"}function se(e,r){return r?.id?_(r.id,m(e.operationId?e.operationId:d(e.pointer))).toLowerCase():e.tags?.length?m(e.operationId?e.operationId:d(e.pointer)):m(e.operationId?_(R,e.operationId):d(e.pointer))}function d(e){return e?.startsWith("/")?e.slice(1,e.length):e}const h={multipleOf:"number",maximum:"number",exclusiveMaximum:"number",minimum:"number",exclusiveMinimum:"number",maxLength:"string",minLength:"string",pattern:"string",contentEncoding:"string",contentMediaType:"string",items:"array",maxItems:"array",minItems:"array",uniqueItems:"array",maxProperties:"object",minProperties:"object",required:"object",additionalProperties:"object",unevaluatedProperties:"object",patternProperties:"object",properties:"object"};function ae(e){if(e.type!==void 0&&!Array.isArray(e.type))return e.type;const r=Object.keys(h);for(const t of r){const n=h[t];if(e[t]!==void 0)return n}return"any"}function k(e,r=e.type){if(e["x-circular-ref"]||e["x-complex"])return!0;if(e.oneOf!==void 0||e.anyOf!==void 0||e.if&&e.then||e.if&&e.else)return!1;let t=!0;const n=Array.isArray(r);return(r==="object"||n&&r?.includes("object"))&&(t=e.properties!==void 0?Object.keys(e.properties).length===0:e.additionalProperties===void 0&&e.unevaluatedProperties===void 0&&e.patternProperties===void 0),Array.isArray(e.items)||Array.isArray(e.prefixItems)?!1:(e.items!==void 0&&typeof e.items!="boolean"&&(r==="array"||n&&r?.includes("array"))&&(t=k(e.items,e.items.type)),t)}function q(e){return e.search(/json/i)!==-1}function ce(e){return e?.search(/xml/i)!==-1}function pe(e){return e===j.URL_ENCODED}function fe(e){return e===j.MULTIPART}function c(e,r,t){return Array.isArray(e)?e.map(n=>n.toString()).join(t):typeof e=="object"?Object.keys(e).map(n=>`${n}${t}${e[n]}`).join(t):r+"="+e.toString()}function w(e,r){return Array.isArray(e)?(console.warn("deepObject style cannot be used with array value:"+e.toString()),""):typeof e=="object"?Object.keys(e).map(t=>e[t]?`${r}[${t}]=${e[t]}`:void 0).filter(Boolean).join("&"):(console.warn("deepObject style cannot be used with non-object value:"+e.toString()),"")}function a(e,r,t){const n="__redoc_param_name__",i=r?"*":"";return f.parse(`{?${n}${i}}`).expand({[n]:t}).substring(1).replace(/__redoc_param_name__/g,e)}function O(e,r){const t=e?"*":"",n="__redoc_param_name__",i=f.parse(`{${n}${t}}`);return F(i.expand({[n]:r}))}function me(e,r={}){if(Array.isArray(e))throw new Error("Payload must have fields: "+e.toString());return Object.keys(e).map(t=>{const n=e[t],{style:i="form",explode:o=!0}=r[t]||{};switch(i){case"form":return a(t,o,n);case"spaceDelimited":return c(n,t,"%20");case"pipeDelimited":return c(n,t,"|");case"deepObject":return w(n,t);default:return console.warn("Incorrect or unsupported encoding style: "+i),""}}).join("&")}function W(e,r,t,n){const i=t?"*":"";let o="";r==="label"?o=".":r==="matrix"&&(o=";");const s="__redoc_param_name__";return f.parse(`{${o}${s}${i}}`).expand({[s]:n}).replace(/__redoc_param_name__/g,e)}function H(e,r,t,n){const i=o=>{switch(r){case"form":return a(e,t,o);case"spaceDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style spaceDelimited is applicable to arrays or objects"),""):t?a(e,t,o):c(n,e,"%20");case"pipeDelimited":return!Array.isArray(o)&&typeof o!="object"?(console.warn("The style pipeDelimited is applicable to arrays or objects"),""):t?a(e,t,o):c(n,e,"|");case"deepObject":return!t||Array.isArray(o)||typeof o!="object"?(console.warn("The style deepObject is only applicable for objects with explode=true"),""):w(o,e);case"simple":return O(t,n);default:return console.warn("Unexpected style for query: "+r),""}};return T(n)&&(n=E(n).map(o=>i(o))),i(n)}function C(e,r,t){switch(e){case"simple":return O(r,t);default:return console.warn("Unexpected style for header: "+e),""}}function B(e,r,t,n){switch(r){case"form":return a(e,t,n);default:return console.warn("Unexpected style for cookie: "+r),""}}function A(e,r){return q(r)?JSON.stringify(e):(console.warn(`Parameter serialization as ${r} is not supported`),"")}function de(e,r){const{name:t,style:n,explode:i=!1,serializationMime:o}=e;if(o)switch(e.in){case"path":case"header":return A(r,o);case"cookie":case"query":return`${t}=${A(r,o)}`;default:return console.warn("Unexpected parameter location: "+e.in),""}if(!n)return console.warn(`Missing style attribute or content for parameter ${t}`),"";switch(e.in){case"path":return W(t,n,i,r);case"query":return H(t,n,i,r);case"header":return C(n,i,r);case"cookie":return B(t,n,i,r);default:return console.warn("Unexpected parameter location: "+e.in),""}}function le(e){return e.search(/xml/i)!==-1?"xml":"clike"}const I=/^#\/components\/(schemas|pathItems)\/([^/]+)$/;function xe(e){return I.test(e||"")}function ye(e){return e?.match(I)?.pop()}function G(e){if(e===void 0)return;const r=e.toString(10);return/^0\.0*1$/.test(r)?`decimal places <= ${r.split(".")[1].length}`:`multiple of ${r}`}function l(e,r,t){let n;return r!==void 0&&t!==void 0?r===t?n=`= ${r} ${e}`:n=`[ ${r} .. ${t} ] ${e}`:t!==void 0?n=`<= ${t} ${e}`:r!==void 0&&(r===1?n="non-empty":n=`>= ${r} ${e}`),n}function J(e){const r=typeof e.exclusiveMinimum=="number"?Math.min(e.exclusiveMinimum,e.minimum??1/0):e.minimum,t=typeof e.exclusiveMaximum=="number"?Math.max(e.exclusiveMaximum,e.maximum??-1/0):e.maximum,n=typeof e.exclusiveMinimum=="number"||e.exclusiveMinimum,i=typeof e.exclusiveMaximum=="number"||e.exclusiveMaximum;if(r!==void 0&&t!==void 0)return`${n?"( ":"[ "}${r} .. ${t}${i?" )":" ]"}`;if(t!==void 0)return`${i?"< ":"<= "}${t}`;if(r!==void 0)return`${n?"> ":">= "}${r}`}function be(e){const r=[],t=l("characters",e.minLength,e.maxLength);t!==void 0&&r.push(t);const n=l("items",e.minItems,e.maxItems);n!==void 0&&r.push(n);const i=l(e.minProperties===1&&e.maxProperties===1?"property":"properties",e.minProperties,e.maxProperties);i!==void 0&&r.push(i);const o=G(e.multipleOf);o!==void 0&&r.push(o);const s=J(e);return s!==void 0&&r.push(s),e.uniqueItems&&r.push("unique"),r}function ge(e,r=[]){const t=[],n=[],i=[];return e.forEach(o=>{o.required?r.includes(o.name)?n.push(o):i.push(o):t.push(o)}),n.sort((o,s)=>r.indexOf(o.name)-r.indexOf(s.name)),[...n,...i,...t]}function je(e){return e.sort((r,t)=>Number(r.deprecated)-Number(t.deprecated))}function $e(e,r=[],t=[],{pathPointer:n,operationPointer:i}){const o={};t.forEach(u=>{({resolved:u}=e.deref(u)),o[u.name+"_"+u.in]=!0});const s=r.map((u,p)=>({paramOrRef:u,pointer:$.join(n,["parameters",String(p)])})).filter(({paramOrRef:u})=>({resolved:u}=e.deref(u),!o[u.name+"_"+u.in])),x=t.map((u,p)=>({paramOrRef:u,pointer:$.join(i,["parameters",String(p)])}));return[...s,...x]}function _e(e,r){const n=e===void 0?z((()=>{if(!M)return globalThis.SSR_HOSTNAME||"";const i=window.location.href;return i.endsWith(".html")?y(i):i})()):N(e)?U(e):y(e);return r.length===0&&(r=[{url:"/"}]),r.map(i=>({...i,url:n?D(n,i.url):i.url,description:i.description||""}))}const Pe=e=>({delete:"del",options:"opts"})[e]||e;function Q(e){return e in{"x-circular-ref":!0,"x-complex":!0,"x-parentRefs":!0,"x-refsStack":!0,"x-codeSamples":!0,"x-displayName":!0,"x-examples":!0,"x-logo":!0,"x-nullable":!0,"x-servers":!0,"x-tagGroups":!0,"x-traitTag":!0,"x-additionalPropertiesName":!0,"x-explicitMappingOnly":!0,"x-enumDescriptions":!0,"x-hideReplay":!0,"x-feedback":!0,"x-badges":!0,"x-assertionType":!0,"x-rbac":!0}||e.startsWith("x-parsed-md-")}function he(e,r){return Object.keys(e).filter(t=>r===!0?t.startsWith("x-")&&!Q(t):t.startsWith("x-")&&r.indexOf(t)>-1).reduce((t,n)=>(t[n]=e[n],t),{})}function we(e){return e.split(" or ").map(r=>r.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/,"$1s$2")).join(" or ")}function Oe(e){let r=e.content;const t=e["x-examples"],n=e["x-example"];if(t){r={...r};for(const i of Object.keys(t)){const o=t[i];r[i]={...r[i],examples:o}}}else if(n){r={...r};for(const i of Object.keys(n)){const o=n[i];r[i]={...r[i],example:o}}}return r}export{ae as detectType,he as extractExtensions,Oe as getContentWithLegacyExamples,ye as getDefinitionName,se as getOperationId,ue as getOperationName,ie as getStatusCodeType,be as humanizeConstraints,J as humanizeNumberRange,pe as isFormUrlEncoded,q as isJsonLike,fe as isMultipartFormData,xe as isNamedDefinition,oe as isOperationName,k as isPrimitiveType,Q as isRedocExtension,ne as isStatusCode,ce as isXmlLike,le as langFromMime,$e as mergeParams,_e as normalizeServers,we as pluralizeType,de as serializeParameterValue,A as serializeParameterValueWithMime,H as serializeQueryParameter,Pe as shortenHTTPVerb,je as sortByDeprecated,ge as sortByRequired,me as urlFormEncodePayload};
1
+ import { dirname } from 'path';
2
+ import UrlTemplate from 'url-template';
3
+ import { IS_BROWSER } from '@redocly/theme/core/openapi';
4
+ import { deleteEmptyArrayItem, isArrayOfObjects, isNumeric, removeQueryStringAndHash, resolveUrl, sanitizeItemId, normalizeText, getValueFromMdParsedExtension, isAbsoluteUrl, } from './helpers.js';
5
+ import { DEFAULT_TAG_SLUG, MediaTypes } from '../constants.js';
6
+ import { JsonPointer } from './JsonPointer.js';
7
+ import { joinWithSeparator } from '../services/index.js';
8
+ import { tryDecodeURIComponent } from './string.js';
9
+ import { getUrlDirname } from './url.js';
10
+ function isWildcardStatusCode(statusCode) {
11
+ return typeof statusCode === 'string' && /\dxx/i.test(statusCode);
12
+ }
13
+ export function isStatusCode(statusCode) {
14
+ return statusCode === 'default' || isNumeric(statusCode) || isWildcardStatusCode(statusCode);
15
+ }
16
+ export function getStatusCodeType(statusCode, defaultAsError = false) {
17
+ if (statusCode === 'default') {
18
+ return defaultAsError ? 'error' : 'success';
19
+ }
20
+ let code = typeof statusCode === 'string' ? parseInt(statusCode, 10) : statusCode;
21
+ if (isWildcardStatusCode(statusCode)) {
22
+ code *= 100; // parseInt('2xx') parses to 2
23
+ }
24
+ if (code < 100 || code > 599) {
25
+ throw new Error('invalid HTTP code');
26
+ }
27
+ let res = 'success';
28
+ if (code >= 300 && code < 400) {
29
+ res = 'redirect';
30
+ }
31
+ else if (code >= 400) {
32
+ res = 'error';
33
+ }
34
+ else if (code < 200) {
35
+ res = 'info';
36
+ }
37
+ return res;
38
+ }
39
+ const operationNames = {
40
+ get: true,
41
+ post: true,
42
+ put: true,
43
+ head: true,
44
+ patch: true,
45
+ delete: true,
46
+ options: true,
47
+ $ref: true,
48
+ };
49
+ export function isOperationName(key) {
50
+ return key in operationNames;
51
+ }
52
+ export function getOperationName(operation) {
53
+ const { operationId, pathName } = operation;
54
+ const _description = normalizeText(getValueFromMdParsedExtension(operation, 'description'));
55
+ return (normalizeText(getValueFromMdParsedExtension(operation, 'summary')) ||
56
+ operationId ||
57
+ (_description && _description.substring(0, 50)) ||
58
+ pathName ||
59
+ '<no summary>');
60
+ }
61
+ export function getOperationId(operation, parent) {
62
+ if (parent?.id) {
63
+ return joinWithSeparator(parent.id, sanitizeItemId(operation.operationId ? operation.operationId : pointerToId(operation.pointer))).toLowerCase();
64
+ }
65
+ if (!operation.tags?.length) {
66
+ return sanitizeItemId(operation.operationId
67
+ ? joinWithSeparator(DEFAULT_TAG_SLUG, operation.operationId)
68
+ : pointerToId(operation.pointer));
69
+ }
70
+ return sanitizeItemId(operation.operationId ? operation.operationId : pointerToId(operation.pointer));
71
+ }
72
+ function pointerToId(pointer) {
73
+ return pointer?.startsWith('/') ? pointer.slice(1, pointer.length) : pointer;
74
+ }
75
+ const schemaKeywordTypes = {
76
+ multipleOf: 'number',
77
+ maximum: 'number',
78
+ exclusiveMaximum: 'number',
79
+ minimum: 'number',
80
+ exclusiveMinimum: 'number',
81
+ maxLength: 'string',
82
+ minLength: 'string',
83
+ pattern: 'string',
84
+ contentEncoding: 'string',
85
+ contentMediaType: 'string',
86
+ items: 'array',
87
+ maxItems: 'array',
88
+ minItems: 'array',
89
+ uniqueItems: 'array',
90
+ maxProperties: 'object',
91
+ minProperties: 'object',
92
+ required: 'object',
93
+ additionalProperties: 'object',
94
+ unevaluatedProperties: 'object',
95
+ patternProperties: 'object',
96
+ properties: 'object',
97
+ };
98
+ export function detectType(schema) {
99
+ if (schema.type !== undefined && !Array.isArray(schema.type)) {
100
+ return schema.type;
101
+ }
102
+ const keywords = Object.keys(schemaKeywordTypes);
103
+ for (const keyword of keywords) {
104
+ const type = schemaKeywordTypes[keyword];
105
+ if (schema[keyword] !== undefined) {
106
+ return type;
107
+ }
108
+ }
109
+ return 'any';
110
+ }
111
+ export function isPrimitiveType(schema, type = schema.type) {
112
+ if (schema['x-circular-ref']) {
113
+ return true;
114
+ }
115
+ if (schema['x-complex']) {
116
+ return true;
117
+ }
118
+ if (schema.oneOf !== undefined || schema.anyOf !== undefined) {
119
+ return false;
120
+ }
121
+ if ((schema.if && schema.then) || (schema.if && schema.else)) {
122
+ return false;
123
+ }
124
+ let isPrimitive = true;
125
+ const isArray = Array.isArray(type);
126
+ if (type === 'object' || (isArray && type?.includes('object'))) {
127
+ isPrimitive =
128
+ schema.properties !== undefined
129
+ ? Object.keys(schema.properties).length === 0
130
+ : schema.additionalProperties === undefined &&
131
+ schema.unevaluatedProperties === undefined &&
132
+ schema.patternProperties === undefined;
133
+ }
134
+ if (Array.isArray(schema.items) || Array.isArray(schema.prefixItems)) {
135
+ return false;
136
+ }
137
+ if (schema.items !== undefined &&
138
+ typeof schema.items !== 'boolean' &&
139
+ (type === 'array' || (isArray && type?.includes('array')))) {
140
+ isPrimitive = isPrimitiveType(schema.items, schema.items.type);
141
+ }
142
+ return isPrimitive;
143
+ }
144
+ export function isJsonLike(contentType) {
145
+ return contentType.search(/json/i) !== -1;
146
+ }
147
+ export function isXmlLike(contentType) {
148
+ return contentType?.search(/xml/i) !== -1;
149
+ }
150
+ export function isFormUrlEncoded(contentType) {
151
+ return contentType === MediaTypes.URL_ENCODED;
152
+ }
153
+ export function isMultipartFormData(contentType) {
154
+ return contentType === MediaTypes.MULTIPART;
155
+ }
156
+ function delimitedEncodeField(fieldVal, fieldName, delimiter) {
157
+ if (Array.isArray(fieldVal)) {
158
+ return fieldVal.map((v) => v.toString()).join(delimiter);
159
+ }
160
+ else if (typeof fieldVal === 'object') {
161
+ return Object.keys(fieldVal)
162
+ .map((k) => `${k}${delimiter}${fieldVal[k]}`)
163
+ .join(delimiter);
164
+ }
165
+ else {
166
+ return fieldName + '=' + fieldVal.toString();
167
+ }
168
+ }
169
+ function deepObjectEncodeField(fieldVal, fieldName) {
170
+ if (Array.isArray(fieldVal)) {
171
+ console.warn('deepObject style cannot be used with array value:' + fieldVal.toString());
172
+ return '';
173
+ }
174
+ else if (typeof fieldVal === 'object') {
175
+ return Object.keys(fieldVal)
176
+ .map((k) => (fieldVal[k] ? `${fieldName}[${k}]=${fieldVal[k]}` : undefined))
177
+ .filter(Boolean)
178
+ .join('&');
179
+ }
180
+ else {
181
+ console.warn('deepObject style cannot be used with non-object value:' + fieldVal.toString());
182
+ return '';
183
+ }
184
+ }
185
+ function serializeFormValue(name, explode, value) {
186
+ // Use RFC6570 safe name ([a-zA-Z0-9_]) and replace with our name later
187
+ // e.g. URI.template doesn't parse names with hyphen (-) which are valid query param names
188
+ const safeName = '__redoc_param_name__';
189
+ const suffix = explode ? '*' : '';
190
+ const template = UrlTemplate.parse(`{?${safeName}${suffix}}`);
191
+ return template
192
+ .expand({ [safeName]: value })
193
+ .substring(1)
194
+ .replace(/__redoc_param_name__/g, name);
195
+ }
196
+ function serializeSimpleValue(explode, value) {
197
+ const suffix = explode ? '*' : '';
198
+ // name is not important here, so use RFC6570 safe name ([a-zA-Z0-9_])
199
+ const name = '__redoc_param_name__';
200
+ const template = UrlTemplate.parse(`{${name}${suffix}}`);
201
+ return tryDecodeURIComponent(template.expand({ [name]: value }));
202
+ }
203
+ /*
204
+ * Should be used only for url-form-encoded body payloads
205
+ * To be used for parameters should be extended with other style values
206
+ */
207
+ export function urlFormEncodePayload(payload, encoding = {}) {
208
+ if (Array.isArray(payload)) {
209
+ throw new Error('Payload must have fields: ' + payload.toString());
210
+ }
211
+ else {
212
+ return Object.keys(payload)
213
+ .map((fieldName) => {
214
+ const fieldVal = payload[fieldName];
215
+ const { style = 'form', explode = true } = encoding[fieldName] || {};
216
+ switch (style) {
217
+ case 'form':
218
+ return serializeFormValue(fieldName, explode, fieldVal);
219
+ case 'spaceDelimited':
220
+ return delimitedEncodeField(fieldVal, fieldName, '%20');
221
+ case 'pipeDelimited':
222
+ return delimitedEncodeField(fieldVal, fieldName, '|');
223
+ case 'deepObject':
224
+ return deepObjectEncodeField(fieldVal, fieldName);
225
+ default:
226
+ // TODO implement rest of styles for path parameters
227
+ console.warn('Incorrect or unsupported encoding style: ' + style);
228
+ return '';
229
+ }
230
+ })
231
+ .join('&');
232
+ }
233
+ }
234
+ function serializePathParameter(name, style, explode, value) {
235
+ const suffix = explode ? '*' : '';
236
+ let prefix = '';
237
+ if (style === 'label') {
238
+ prefix = '.';
239
+ }
240
+ else if (style === 'matrix') {
241
+ prefix = ';';
242
+ }
243
+ // Use RFC6570 safe name ([a-zA-Z0-9_]) and replace with our name later
244
+ // e.g. URI.template doesn't parse names with hyphen (-) which are valid query param names
245
+ const safeName = '__redoc_param_name__';
246
+ const template = UrlTemplate.parse(`{${prefix}${safeName}${suffix}}`);
247
+ return template.expand({ [safeName]: value }).replace(/__redoc_param_name__/g, name);
248
+ }
249
+ export function serializeQueryParameter(name, style, explode, value) {
250
+ const serializationByStyle = (val) => {
251
+ switch (style) {
252
+ case 'form':
253
+ return serializeFormValue(name, explode, val);
254
+ case 'spaceDelimited':
255
+ if (!Array.isArray(val) && typeof val !== 'object') {
256
+ console.warn('The style spaceDelimited is applicable to arrays or objects');
257
+ return '';
258
+ }
259
+ if (explode) {
260
+ return serializeFormValue(name, explode, val);
261
+ }
262
+ return delimitedEncodeField(value, name, '%20');
263
+ case 'pipeDelimited':
264
+ if (!Array.isArray(val) && typeof val !== 'object') {
265
+ console.warn('The style pipeDelimited is applicable to arrays or objects');
266
+ return '';
267
+ }
268
+ if (explode) {
269
+ return serializeFormValue(name, explode, val);
270
+ }
271
+ return delimitedEncodeField(value, name, '|');
272
+ case 'deepObject':
273
+ if (!explode || Array.isArray(val) || typeof val !== 'object') {
274
+ console.warn('The style deepObject is only applicable for objects with explode=true');
275
+ return '';
276
+ }
277
+ return deepObjectEncodeField(val, name);
278
+ case 'simple': {
279
+ return serializeSimpleValue(explode, value);
280
+ }
281
+ default:
282
+ console.warn('Unexpected style for query: ' + style);
283
+ return '';
284
+ }
285
+ };
286
+ if (isArrayOfObjects(value)) {
287
+ value = deleteEmptyArrayItem(value).map((value) => serializationByStyle(value));
288
+ }
289
+ return serializationByStyle(value);
290
+ }
291
+ function serializeHeaderParameter(style, explode, value) {
292
+ switch (style) {
293
+ case 'simple': {
294
+ return serializeSimpleValue(explode, value);
295
+ }
296
+ default:
297
+ console.warn('Unexpected style for header: ' + style);
298
+ return '';
299
+ }
300
+ }
301
+ function serializeCookieParameter(name, style, explode, value) {
302
+ switch (style) {
303
+ case 'form':
304
+ return serializeFormValue(name, explode, value);
305
+ default:
306
+ console.warn('Unexpected style for cookie: ' + style);
307
+ return '';
308
+ }
309
+ }
310
+ export function serializeParameterValueWithMime(value, mime) {
311
+ if (isJsonLike(mime)) {
312
+ return JSON.stringify(value);
313
+ }
314
+ else {
315
+ console.warn(`Parameter serialization as ${mime} is not supported`);
316
+ return '';
317
+ }
318
+ }
319
+ export function serializeParameterValue(parameter, value) {
320
+ const { name, style, explode = false, serializationMime } = parameter;
321
+ if (serializationMime) {
322
+ switch (parameter.in) {
323
+ case 'path':
324
+ case 'header':
325
+ return serializeParameterValueWithMime(value, serializationMime);
326
+ case 'cookie':
327
+ case 'query':
328
+ return `${name}=${serializeParameterValueWithMime(value, serializationMime)}`;
329
+ default:
330
+ console.warn('Unexpected parameter location: ' + parameter.in);
331
+ return '';
332
+ }
333
+ }
334
+ if (!style) {
335
+ console.warn(`Missing style attribute or content for parameter ${name}`);
336
+ return '';
337
+ }
338
+ switch (parameter.in) {
339
+ case 'path':
340
+ return serializePathParameter(name, style, explode, value);
341
+ case 'query':
342
+ return serializeQueryParameter(name, style, explode, value);
343
+ case 'header':
344
+ return serializeHeaderParameter(style, explode, value);
345
+ case 'cookie':
346
+ return serializeCookieParameter(name, style, explode, value);
347
+ default:
348
+ console.warn('Unexpected parameter location: ' + parameter.in);
349
+ return '';
350
+ }
351
+ }
352
+ export function langFromMime(contentType) {
353
+ if (contentType.search(/xml/i) !== -1) {
354
+ return 'xml';
355
+ }
356
+ return 'clike';
357
+ }
358
+ const DEFINITION_NAME_REGEX = /^#\/components\/(schemas|pathItems)\/([^/]+)$/;
359
+ export function isNamedDefinition(pointer) {
360
+ return DEFINITION_NAME_REGEX.test(pointer || '');
361
+ }
362
+ export function getDefinitionName(pointer) {
363
+ return pointer?.match(DEFINITION_NAME_REGEX)?.pop();
364
+ }
365
+ function humanizeMultipleOfConstraint(multipleOf) {
366
+ if (multipleOf === undefined) {
367
+ return;
368
+ }
369
+ const strigifiedMultipleOf = multipleOf.toString(10);
370
+ if (!/^0\.0*1$/.test(strigifiedMultipleOf)) {
371
+ return `multiple of ${strigifiedMultipleOf}`;
372
+ }
373
+ return `decimal places <= ${strigifiedMultipleOf.split('.')[1].length}`;
374
+ }
375
+ function humanizeRangeConstraint(description, min, max) {
376
+ let stringRange;
377
+ if (min !== undefined && max !== undefined) {
378
+ if (min === max) {
379
+ stringRange = `= ${min} ${description}`;
380
+ }
381
+ else {
382
+ stringRange = `[ ${min} .. ${max} ] ${description}`;
383
+ }
384
+ }
385
+ else if (max !== undefined) {
386
+ stringRange = `<= ${max} ${description}`;
387
+ }
388
+ else if (min !== undefined) {
389
+ if (min === 1) {
390
+ stringRange = 'non-empty';
391
+ }
392
+ else {
393
+ stringRange = `>= ${min} ${description}`;
394
+ }
395
+ }
396
+ return stringRange;
397
+ }
398
+ export function humanizeNumberRange(schema) {
399
+ const minimum = typeof schema.exclusiveMinimum === 'number'
400
+ ? Math.min(schema.exclusiveMinimum, schema.minimum ?? Infinity)
401
+ : schema.minimum;
402
+ const maximum = typeof schema.exclusiveMaximum === 'number'
403
+ ? Math.max(schema.exclusiveMaximum, schema.maximum ?? -Infinity)
404
+ : schema.maximum;
405
+ const exclusiveMinimum = typeof schema.exclusiveMinimum === 'number' || schema.exclusiveMinimum;
406
+ const exclusiveMaximum = typeof schema.exclusiveMaximum === 'number' || schema.exclusiveMaximum;
407
+ if (minimum !== undefined && maximum !== undefined) {
408
+ return `${exclusiveMinimum ? '( ' : '[ '}${minimum} .. ${maximum}${exclusiveMaximum ? ' )' : ' ]'}`;
409
+ }
410
+ else if (maximum !== undefined) {
411
+ return `${exclusiveMaximum ? '< ' : '<= '}${maximum}`;
412
+ }
413
+ else if (minimum !== undefined) {
414
+ return `${exclusiveMinimum ? '> ' : '>= '}${minimum}`;
415
+ }
416
+ }
417
+ export function humanizeConstraints(schema) {
418
+ const res = [];
419
+ const stringRange = humanizeRangeConstraint('characters', schema.minLength, schema.maxLength);
420
+ if (stringRange !== undefined) {
421
+ res.push(stringRange);
422
+ }
423
+ const arrayRange = humanizeRangeConstraint('items', schema.minItems, schema.maxItems);
424
+ if (arrayRange !== undefined) {
425
+ res.push(arrayRange);
426
+ }
427
+ const propertiesRange = humanizeRangeConstraint(schema.minProperties === 1 && schema.maxProperties === 1 ? 'property' : 'properties', schema.minProperties, schema.maxProperties);
428
+ if (propertiesRange !== undefined) {
429
+ res.push(propertiesRange);
430
+ }
431
+ const multipleOfConstraint = humanizeMultipleOfConstraint(schema.multipleOf);
432
+ if (multipleOfConstraint !== undefined) {
433
+ res.push(multipleOfConstraint);
434
+ }
435
+ const numberRange = humanizeNumberRange(schema);
436
+ if (numberRange !== undefined) {
437
+ res.push(numberRange);
438
+ }
439
+ if (schema.uniqueItems) {
440
+ res.push('unique');
441
+ }
442
+ return res;
443
+ }
444
+ export function sortByRequired(fields, order = []) {
445
+ const unrequiredFields = [];
446
+ const orderedFields = [];
447
+ const unorderedFields = [];
448
+ fields.forEach((field) => {
449
+ if (field.required) {
450
+ if (order.includes(field.name)) {
451
+ orderedFields.push(field);
452
+ }
453
+ else {
454
+ unorderedFields.push(field);
455
+ }
456
+ }
457
+ else {
458
+ unrequiredFields.push(field);
459
+ }
460
+ });
461
+ orderedFields.sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name));
462
+ return [...orderedFields, ...unorderedFields, ...unrequiredFields];
463
+ }
464
+ export function sortByDeprecated(fields) {
465
+ return fields.sort((a, b) => Number(a.deprecated) - Number(b.deprecated));
466
+ }
467
+ export function mergeParams(parser, pathParams = [], operationParams = [], { pathPointer, operationPointer }) {
468
+ const operationParamNames = {};
469
+ operationParams.forEach((param) => {
470
+ ({ resolved: param } = parser.deref(param));
471
+ operationParamNames[param.name + '_' + param.in] = true;
472
+ });
473
+ const pathParamsPointer = pathParams
474
+ .map((paramOrRef, index) => ({
475
+ paramOrRef,
476
+ pointer: JsonPointer.join(pathPointer, ['parameters', String(index)]),
477
+ }))
478
+ // filter out path params overridden by operation ones with the same name
479
+ .filter(({ paramOrRef }) => {
480
+ ({ resolved: paramOrRef } = parser.deref(paramOrRef));
481
+ return !operationParamNames[paramOrRef.name + '_' + paramOrRef.in];
482
+ });
483
+ const operationParamsPointer = operationParams.map((paramOrRef, index) => ({
484
+ paramOrRef,
485
+ pointer: JsonPointer.join(operationPointer, ['parameters', String(index)]),
486
+ }));
487
+ return [...pathParamsPointer, ...operationParamsPointer];
488
+ }
489
+ export function normalizeServers(specUrl, servers) {
490
+ const getHref = () => {
491
+ if (!IS_BROWSER) {
492
+ return globalThis.SSR_HOSTNAME || '';
493
+ }
494
+ const href = window.location.href;
495
+ return href.endsWith('.html') ? dirname(href) : href;
496
+ };
497
+ const baseUrl = specUrl === undefined
498
+ ? removeQueryStringAndHash(getHref())
499
+ : isAbsoluteUrl(specUrl)
500
+ ? getUrlDirname(specUrl)
501
+ : dirname(specUrl);
502
+ if (servers.length === 0) {
503
+ // Behaviour defined in OpenAPI spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object
504
+ servers = [
505
+ {
506
+ url: '/',
507
+ },
508
+ ];
509
+ }
510
+ return servers.map((server) => {
511
+ return {
512
+ ...server,
513
+ url: baseUrl ? resolveUrl(baseUrl, server.url) : server.url,
514
+ description: server.description || '',
515
+ };
516
+ });
517
+ }
518
+ export const shortenHTTPVerb = (verb) => ({
519
+ delete: 'del',
520
+ options: 'opts',
521
+ })[verb] || verb;
522
+ export function isRedocExtension(key) {
523
+ const redocExtensions = {
524
+ 'x-circular-ref': true,
525
+ 'x-complex': true,
526
+ 'x-parentRefs': true,
527
+ 'x-refsStack': true,
528
+ 'x-codeSamples': true,
529
+ 'x-displayName': true,
530
+ 'x-examples': true,
531
+ 'x-logo': true,
532
+ 'x-nullable': true,
533
+ 'x-servers': true,
534
+ 'x-tagGroups': true,
535
+ 'x-traitTag': true,
536
+ 'x-additionalPropertiesName': true,
537
+ 'x-explicitMappingOnly': true,
538
+ 'x-enumDescriptions': true,
539
+ 'x-hideReplay': true,
540
+ 'x-feedback': true,
541
+ 'x-badges': true,
542
+ 'x-assertionType': true,
543
+ 'x-rbac': true,
544
+ };
545
+ return key in redocExtensions || key.startsWith('x-parsed-md-');
546
+ }
547
+ export function extractExtensions(obj, showExtensions) {
548
+ return Object.keys(obj)
549
+ .filter((key) => {
550
+ if (showExtensions === true) {
551
+ return key.startsWith('x-') && !isRedocExtension(key);
552
+ }
553
+ return key.startsWith('x-') && showExtensions.indexOf(key) > -1;
554
+ })
555
+ .reduce((acc, key) => {
556
+ acc[key] = obj[key];
557
+ return acc;
558
+ }, {});
559
+ }
560
+ export function pluralizeType(displayType) {
561
+ return displayType
562
+ .split(' or ')
563
+ .map((type) => type.replace(/^(string|object|number|integer|array|boolean)s?( ?.*)/, '$1s$2'))
564
+ .join(' or ');
565
+ }
566
+ export function getContentWithLegacyExamples(info) {
567
+ let mediaContent = info.content;
568
+ const xExamples = info['x-examples']; // converted from OAS2 body param
569
+ const xExample = info['x-example']; // converted from OAS2 body param
570
+ if (xExamples) {
571
+ mediaContent = { ...mediaContent };
572
+ for (const mime of Object.keys(xExamples)) {
573
+ const examples = xExamples[mime];
574
+ mediaContent[mime] = {
575
+ ...mediaContent[mime],
576
+ examples,
577
+ };
578
+ }
579
+ }
580
+ else if (xExample) {
581
+ mediaContent = { ...mediaContent };
582
+ for (const mime of Object.keys(xExample)) {
583
+ const example = xExample[mime];
584
+ mediaContent[mime] = {
585
+ ...mediaContent[mime],
586
+ example,
587
+ };
588
+ }
589
+ }
590
+ return mediaContent;
591
+ }
592
+ //# sourceMappingURL=openapi.js.map
@@ -1 +1,13 @@
1
- import{fromSessionStorage as o,toSessionStorage as a}from"./session-storage.js";function i(r,e){try{return JSON.parse(o(`${r}.${e}`))}catch{return null}}function s(r,e,t){a(`${r}.${e}`,JSON.stringify(t))}export{i as getParameterValue,s as setParameterValue};
1
+ import { fromSessionStorage, toSessionStorage } from './session-storage.js';
2
+ export function getParameterValue(_in, name) {
3
+ try {
4
+ return JSON.parse(fromSessionStorage(`${_in}.${name}`));
5
+ }
6
+ catch {
7
+ return null;
8
+ }
9
+ }
10
+ export function setParameterValue(_in, name, value) {
11
+ toSessionStorage(`${_in}.${name}`, JSON.stringify(value));
12
+ }
13
+ //# sourceMappingURL=parameters.js.map
package/lib/utils/path.js CHANGED
@@ -1 +1,22 @@
1
- import{tryDecodeURIComponent as n}from"./string.js";function o(e,r){return r?n(e.pathname+e.hash).includes(n(r.toLowerCase())):!1}function a(e,r=""){const t=n(r.toLowerCase());return n(e.pathname)===t||n(e.hash)===t||n(e.pathname+e.hash)===t}function h(e){return e.startsWith("/")||(e="/"+e),e.endsWith("/")&&(e=e.slice(0,-1)),e}export{h as normalizePath,o as pathIncludesLink,a as pathMatchedLink};
1
+ import { tryDecodeURIComponent } from './string.js';
2
+ export function pathIncludesLink(location, link) {
3
+ return link
4
+ ? tryDecodeURIComponent(location.pathname + location.hash).includes(tryDecodeURIComponent(link.toLowerCase()))
5
+ : false;
6
+ }
7
+ export function pathMatchedLink(location, link = '') {
8
+ const lowercaseLink = tryDecodeURIComponent(link.toLowerCase());
9
+ return (tryDecodeURIComponent(location.pathname) === lowercaseLink ||
10
+ tryDecodeURIComponent(location.hash) === lowercaseLink ||
11
+ tryDecodeURIComponent(location.pathname + location.hash) === lowercaseLink);
12
+ }
13
+ export function normalizePath(path) {
14
+ if (!path.startsWith('/')) {
15
+ path = '/' + path;
16
+ }
17
+ if (path.endsWith('/')) {
18
+ path = path.slice(0, -1);
19
+ }
20
+ return path;
21
+ }
22
+ //# sourceMappingURL=path.js.map