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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/dist/redocly-openapi-docs.min.js +2153 -1963
  2. package/lib/components/ApiInfo/ApiInfo.js +29 -1
  3. package/lib/components/ApiInfo/Metadata.js +29 -1
  4. package/lib/components/ApiInfo/index.js +2 -1
  5. package/lib/components/ApiInfo/styled.js +17 -8
  6. package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
  7. package/lib/components/CallbackSamples/index.js +2 -1
  8. package/lib/components/Callbacks/CallbackDetails.js +17 -3
  9. package/lib/components/Callbacks/CallbackOperation.js +24 -3
  10. package/lib/components/Callbacks/CallbackSummary.js +19 -3
  11. package/lib/components/Callbacks/CallbacksList.js +16 -1
  12. package/lib/components/Callbacks/index.js +4 -1
  13. package/lib/components/Callbacks/styled.js +6 -3
  14. package/lib/components/Content/Content.js +10 -1
  15. package/lib/components/Content/index.js +2 -1
  16. package/lib/components/Content/useAutoScroll.js +50 -1
  17. package/lib/components/ContentItem/ContentItem.js +31 -1
  18. package/lib/components/ContentItem/index.js +2 -1
  19. package/lib/components/ContentItem/useIsExpanded.js +33 -1
  20. package/lib/components/ContentItems/ContentItems.js +19 -1
  21. package/lib/components/ContentItems/Items.js +13 -1
  22. package/lib/components/ContentItems/VirtualList.js +35 -1
  23. package/lib/components/ContentItems/helpers.js +49 -1
  24. package/lib/components/ContentItems/index.js +2 -1
  25. package/lib/components/ContentItems/useScrollOnRender.js +26 -1
  26. package/lib/components/Discriminator/Discriminator.js +27 -2
  27. package/lib/components/Discriminator/index.js +2 -1
  28. package/lib/components/Download/DownloadSpecification.js +46 -4
  29. package/lib/components/Download/index.js +2 -1
  30. package/lib/components/Download/types.js +2 -0
  31. package/lib/components/Download/useDownloadInfo.js +42 -1
  32. package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
  33. package/lib/components/ErrorBoundary/index.js +2 -1
  34. package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
  35. package/lib/components/ExpandAllButton/index.js +2 -1
  36. package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
  37. package/lib/components/ExternalDocumentation/index.js +2 -1
  38. package/lib/components/Language/LanguageDropdown.js +21 -1
  39. package/lib/components/Language/LanguageItem.js +33 -1
  40. package/lib/components/Language/LanguageList.js +93 -1
  41. package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
  42. package/lib/components/Language/constants.js +3 -1
  43. package/lib/components/Language/index.js +4 -1
  44. package/lib/components/Language/styled.js +29 -15
  45. package/lib/components/Markdown/Markdown.js +64 -1
  46. package/lib/components/Markdown/index.js +3 -1
  47. package/lib/components/Markdown/types.js +2 -0
  48. package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
  49. package/lib/components/MediaTypeSwitch/index.js +2 -1
  50. package/lib/components/OperationItem/Description.d.ts +1 -4
  51. package/lib/components/OperationItem/Description.js +9 -1
  52. package/lib/components/OperationItem/OperationItem.js +70 -5
  53. package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
  54. package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
  55. package/lib/components/OperationItem/index.js +2 -1
  56. package/lib/components/OperationItem/types.js +2 -0
  57. package/lib/components/Overlay.js +48 -3
  58. package/lib/components/Overview/Overview.js +20 -1
  59. package/lib/components/Overview/index.js +2 -1
  60. package/lib/components/PageFooter/PageFooter.js +19 -1
  61. package/lib/components/PageFooter/index.js +2 -1
  62. package/lib/components/Panel/ResponsePanel.js +12 -6
  63. package/lib/components/Panel/Trigger.js +4 -2
  64. package/lib/components/Panel/index.js +3 -1
  65. package/lib/components/PanelItem/PanelItem.js +6 -1
  66. package/lib/components/PanelItem/index.js +3 -1
  67. package/lib/components/PanelItem/styled.js +20 -10
  68. package/lib/components/PayloadSamples/Example.js +6 -1
  69. package/lib/components/PayloadSamples/ExampleValue.js +30 -1
  70. package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
  71. package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
  72. package/lib/components/PayloadSamples/index.js +7 -1
  73. package/lib/components/PayloadSamples/styled.js +9 -4
  74. package/lib/components/PayloadSamples/types.js +2 -0
  75. package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
  76. package/lib/components/PropertyDetails/EnumValues.js +37 -1
  77. package/lib/components/PropertyDetails/Examples.js +26 -1
  78. package/lib/components/PropertyDetails/Extensions.js +17 -2
  79. package/lib/components/PropertyDetails/FieldDetail.js +15 -2
  80. package/lib/components/PropertyDetails/FieldDetails.js +51 -6
  81. package/lib/components/PropertyDetails/Pattern.js +21 -1
  82. package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
  83. package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
  84. package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
  85. package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
  86. package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
  87. package/lib/components/PropertyDetails/index.js +4 -1
  88. package/lib/components/PropertyDetails/styled.js +15 -7
  89. package/lib/components/PropertyDetails/types.js +2 -0
  90. package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
  91. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
  92. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
  93. package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
  94. package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
  95. package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
  96. package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
  97. package/lib/components/RenderHook/RenderHook.js +17 -1
  98. package/lib/components/RenderHook/index.js +2 -1
  99. package/lib/components/Replay/EmbeddedReplay.js +41 -3
  100. package/lib/components/Replay/Replay.js +99 -1
  101. package/lib/components/Replay/index.js +3 -1
  102. package/lib/components/Replay/utils.js +208 -1
  103. package/lib/components/Request/RequestDetails.js +33 -2
  104. package/lib/components/Request/types.js +2 -0
  105. package/lib/components/RequestParameters/Body.js +8 -1
  106. package/lib/components/RequestParameters/ParametersGroup.js +19 -4
  107. package/lib/components/RequestParameters/RequestParameters.js +40 -1
  108. package/lib/components/RequestParameters/index.js +4 -1
  109. package/lib/components/RequestSamples/CodeSample.js +55 -2
  110. package/lib/components/RequestSamples/Example.js +37 -1
  111. package/lib/components/RequestSamples/RequestSamples.js +89 -5
  112. package/lib/components/RequestSamples/index.js +3 -1
  113. package/lib/components/RequestSamples/useCodeSamples.js +92 -1
  114. package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
  115. package/lib/components/ResponseSamples/Summary.js +9 -1
  116. package/lib/components/ResponseSamples/index.js +2 -1
  117. package/lib/components/Responses/OperationResponseList.js +42 -2
  118. package/lib/components/Responses/ResponseDetails.js +18 -1
  119. package/lib/components/Responses/ResponseHeaders.js +15 -1
  120. package/lib/components/Responses/index.js +6 -1
  121. package/lib/components/Responses/styled.js +14 -6
  122. package/lib/components/Responses/types.js +2 -0
  123. package/lib/components/RightPanel/RightPanel.js +21 -1
  124. package/lib/components/RightPanel/index.js +2 -1
  125. package/lib/components/Samples/ExampleSwitch.js +33 -1
  126. package/lib/components/Samples/index.js +3 -1
  127. package/lib/components/Samples/use-example-key.js +12 -1
  128. package/lib/components/Schema/ArraySchema.js +45 -1
  129. package/lib/components/Schema/ObjectSchema.js +29 -1
  130. package/lib/components/Schema/OneOfSchema.js +47 -3
  131. package/lib/components/Schema/RecursiveSchema.js +10 -1
  132. package/lib/components/Schema/Schema.js +63 -2
  133. package/lib/components/Schema/SubSchema.js +20 -1
  134. package/lib/components/Schema/helpers.js +16 -1
  135. package/lib/components/Schema/index.js +5 -1
  136. package/lib/components/Schema/types.js +2 -0
  137. package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
  138. package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
  139. package/lib/components/SchemaDefinition/index.js +2 -1
  140. package/lib/components/SectionContent/SectionContent.js +49 -6
  141. package/lib/components/SectionContent/index.js +2 -1
  142. package/lib/components/SectionItem/SectionItem.js +14 -1
  143. package/lib/components/SectionItem/index.js +2 -1
  144. package/lib/components/Security/Divider.js +9 -2
  145. package/lib/components/Security/OAuthFlow.js +11 -1
  146. package/lib/components/Security/OAuthScopes.js +59 -9
  147. package/lib/components/Security/Security.js +15 -1
  148. package/lib/components/Security/SecurityButton.js +31 -7
  149. package/lib/components/Security/SecurityFlow.js +28 -4
  150. package/lib/components/Security/SecurityModal.js +34 -5
  151. package/lib/components/Security/SecuritySchemeItem.js +15 -4
  152. package/lib/components/Security/helper.js +16 -1
  153. package/lib/components/Security/index.js +11 -1
  154. package/lib/components/Security/styled.js +6 -3
  155. package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
  156. package/lib/components/SelectOrLabel/index.js +2 -1
  157. package/lib/components/ServerList/ServerList.js +36 -10
  158. package/lib/components/ServerList/index.js +2 -1
  159. package/lib/components/ServerList/types.js +2 -0
  160. package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
  161. package/lib/components/ServerListDropdown/index.js +2 -1
  162. package/lib/components/ServerListDropdown/styled.js +15 -6
  163. package/lib/components/SideMenu/SideMenu.js +13 -2
  164. package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
  165. package/lib/components/SideMenu/index.js +2 -1
  166. package/lib/components/SideMenu/types.js +2 -0
  167. package/lib/components/StickySidebar/SidebarActions.js +14 -2
  168. package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
  169. package/lib/components/StickySidebar/index.js +2 -1
  170. package/lib/components/Tabs/Tabs.js +16 -5
  171. package/lib/components/Tabs/index.js +3 -1
  172. package/lib/components/Tabs/useTabsState.js +22 -1
  173. package/lib/components/TagItem/OperationNavigationItems.js +18 -4
  174. package/lib/components/TagItem/OperationsNavigation.js +46 -2
  175. package/lib/components/TagItem/TagItem.js +41 -8
  176. package/lib/components/TagItem/index.js +2 -1
  177. package/lib/components/TagItem/styled.js +5 -2
  178. package/lib/components/TagItem/types.js +2 -0
  179. package/lib/components/ViewNested/ViewNested.js +42 -9
  180. package/lib/components/ViewNested/index.js +2 -1
  181. package/lib/components/common/Badges.js +21 -5
  182. package/lib/components/common/BodyContent/BodyContent.js +31 -4
  183. package/lib/components/common/BodyContent/index.js +2 -1
  184. package/lib/components/common/ClearButton/ClearButton.js +5 -1
  185. package/lib/components/common/ClearButton/index.js +3 -1
  186. package/lib/components/common/ClearButton/styled.js +5 -2
  187. package/lib/components/common/ClearButton/types.js +2 -0
  188. package/lib/components/common/CodeBlockPanel.js +7 -3
  189. package/lib/components/common/ConstraintsView.js +14 -2
  190. package/lib/components/common/Dropdown/Dropdown.js +22 -4
  191. package/lib/components/common/Dropdown/index.js +2 -1
  192. package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
  193. package/lib/components/common/ExpandableExample/index.js +2 -1
  194. package/lib/components/common/Extensions.js +17 -2
  195. package/lib/components/common/Fields/fields-layout.js +76 -51
  196. package/lib/components/common/Fields/fields.js +39 -17
  197. package/lib/components/common/Fields/index.js +3 -1
  198. package/lib/components/common/LinkToField.js +33 -6
  199. package/lib/components/common/OperationItemTitle.d.ts +1 -0
  200. package/lib/components/common/OperationItemTitle.js +16 -5
  201. package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
  202. package/lib/components/common/SchemaSelection/index.js +2 -1
  203. package/lib/components/common/Select/Select.js +21 -1
  204. package/lib/components/common/Select/index.js +3 -1
  205. package/lib/components/common/Select/styled.js +17 -9
  206. package/lib/components/common/Select/types.js +2 -0
  207. package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
  208. package/lib/components/common/Skeleton/Skeleton.js +15 -5
  209. package/lib/components/common/Skeleton/index.js +3 -1
  210. package/lib/components/common/headers.js +4 -2
  211. package/lib/components/common/index.js +14 -1
  212. package/lib/components/common/linkify.js +28 -4
  213. package/lib/components/common/mixins.js +4 -2
  214. package/lib/components/common/panels.js +58 -33
  215. package/lib/components/common/schema.js +16 -8
  216. package/lib/components/common/styled.js +15 -7
  217. package/lib/components/index.js +25 -1
  218. package/lib/components/pluggable/RedocExample.js +20 -1
  219. package/lib/components/pluggable/RedocSchema.js +22 -1
  220. package/lib/components/pluggable/index.js +3 -1
  221. package/lib/components/pluggable/styled.components.js +9 -4
  222. package/lib/constants.js +30 -1
  223. package/lib/empty.js +7 -1
  224. package/lib/events/codeSampleCopy.js +19 -1
  225. package/lib/events/creator.js +5 -1
  226. package/lib/events/index.js +8 -1
  227. package/lib/events/languageSwitch.js +18 -1
  228. package/lib/events/panelToggle.js +16 -1
  229. package/lib/events/serverSwitch.js +13 -1
  230. package/lib/events/tryItOpen.js +12 -1
  231. package/lib/events/tryItSent.js +12 -1
  232. package/lib/events/types.js +11 -1
  233. package/lib/hoc/types.js +2 -0
  234. package/lib/hoc/utils.js +4 -1
  235. package/lib/hoc/withRouter.js +17 -1
  236. package/lib/hoc/withStore.js +28 -1
  237. package/lib/hooks/index.js +9 -1
  238. package/lib/hooks/useActivateExample.js +35 -1
  239. package/lib/hooks/useActiveWithFallback.js +12 -1
  240. package/lib/hooks/useContentItems.js +10 -1
  241. package/lib/hooks/useLicense.js +17 -1
  242. package/lib/hooks/usePerformanceMetrics.js +26 -1
  243. package/lib/hooks/useRouter.js +17 -1
  244. package/lib/hooks/useTelemetry.js +5 -1
  245. package/lib/hooks/useTranslate.js +6 -1
  246. package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
  247. package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
  248. package/lib/icons/CSharpIcon/index.js +2 -1
  249. package/lib/icons/CurlIcon/CurlIcon.js +8 -2
  250. package/lib/icons/CurlIcon/index.js +2 -1
  251. package/lib/icons/GOIcon/GOIcon.js +7 -1
  252. package/lib/icons/GOIcon/index.js +2 -1
  253. package/lib/icons/JavaIcon/JavaIcon.js +7 -1
  254. package/lib/icons/JavaIcon/index.js +2 -1
  255. package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
  256. package/lib/icons/JavaScriptIcon/index.js +2 -1
  257. package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
  258. package/lib/icons/NodeJSIcon/index.js +2 -1
  259. package/lib/icons/PHPIcon/PHPIcon.js +7 -1
  260. package/lib/icons/PHPIcon/index.js +2 -1
  261. package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
  262. package/lib/icons/PayloadIcon/index.js +2 -1
  263. package/lib/icons/PythonIcon/PythonIcon.js +7 -1
  264. package/lib/icons/PythonIcon/index.js +2 -1
  265. package/lib/icons/RIcon/RIcon.js +7 -1
  266. package/lib/icons/RIcon/index.js +2 -1
  267. package/lib/icons/RubyIcon/RubyIcon.js +7 -1
  268. package/lib/icons/RubyIcon/index.js +2 -1
  269. package/lib/index.js +49 -1
  270. package/lib/jotai/app.js +113 -1
  271. package/lib/jotai/operation.js +28 -1
  272. package/lib/jotai/replay.js +5 -1
  273. package/lib/jotai/store.js +8 -1
  274. package/lib/jotai/use-write-atom.js +9 -1
  275. package/lib/models/callback.js +28 -1
  276. package/lib/models/code-sample-options.js +2 -0
  277. package/lib/models/example.js +17 -1
  278. package/lib/models/field.js +109 -1
  279. package/lib/models/group.js +38 -1
  280. package/lib/models/index.js +14 -1
  281. package/lib/models/mediaContent.js +26 -1
  282. package/lib/models/mediaType.js +153 -1
  283. package/lib/models/operation.js +166 -1
  284. package/lib/models/request.js +25 -1
  285. package/lib/models/response.js +46 -1
  286. package/lib/models/schema.js +474 -2
  287. package/lib/models/security.js +84 -1
  288. package/lib/models/tab.js +2 -0
  289. package/lib/models/types.js +2 -0
  290. package/lib/services/OpenAPIParser.js +321 -1
  291. package/lib/services/check.js +104 -1
  292. package/lib/services/code-samples/constants.js +16 -1
  293. package/lib/services/code-samples/generator.js +540 -1
  294. package/lib/services/code-samples/httpsnippet/helpers/code-builder.d.ts +5 -1
  295. package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
  296. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.d.ts +2 -2
  297. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
  298. package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
  299. package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
  300. package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
  301. package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
  302. package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
  303. package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
  304. package/lib/services/code-samples/httpsnippet/index.js +166 -1
  305. package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
  306. package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
  307. package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
  308. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
  309. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
  310. package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
  311. package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
  312. package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
  313. package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
  314. package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
  315. package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
  316. package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
  317. package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
  318. package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
  319. package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
  320. package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
  321. package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
  322. package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
  323. package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
  324. package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
  325. package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
  326. package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
  327. package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
  328. package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
  329. package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
  330. package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
  331. package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
  332. package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
  333. package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
  334. package/lib/services/code-samples/index.js +3 -1
  335. package/lib/services/code-samples/types.js +2 -0
  336. package/lib/services/config-options/helpers.js +49 -1
  337. package/lib/services/config-options/index.js +3 -1
  338. package/lib/services/config-options/normalizeOptions.js +83 -1
  339. package/lib/services/config-options/types.js +2 -0
  340. package/lib/services/history/helpers.js +63 -1
  341. package/lib/services/history/index.js +2 -1
  342. package/lib/services/index.js +9 -1
  343. package/lib/services/menu/builder.js +47 -1
  344. package/lib/services/menu/index.js +2 -1
  345. package/lib/services/menu/markdown.js +93 -1
  346. package/lib/services/menu/operation.js +50 -1
  347. package/lib/services/menu/tags.js +166 -1
  348. package/lib/services/types.d.ts +0 -3
  349. package/lib/services/types.js +2 -0
  350. package/lib/services/utils.js +83 -1
  351. package/lib/standalone.js +68 -1
  352. package/lib/styled-components.js +6 -1
  353. package/lib/types/app.js +2 -0
  354. package/lib/types/index.js +4 -1
  355. package/lib/types/open-api.d.ts +1 -0
  356. package/lib/types/open-api.js +2 -0
  357. package/lib/types/security.js +2 -0
  358. package/lib/utils/JsonPointer.js +84 -1
  359. package/lib/utils/areArraysEqual.js +4 -1
  360. package/lib/utils/argValuesHelpers.js +35 -1
  361. package/lib/utils/compose.js +2 -1
  362. package/lib/utils/configure-helpers.js +223 -1
  363. package/lib/utils/convertSwagger2OpenAPI.js +14 -1
  364. package/lib/utils/cookies.js +73 -1
  365. package/lib/utils/debounce.js +22 -1
  366. package/lib/utils/debug.js +11 -1
  367. package/lib/utils/dom.js +65 -1
  368. package/lib/utils/environments.js +13 -1
  369. package/lib/utils/helpers.js +222 -12
  370. package/lib/utils/index.js +25 -1
  371. package/lib/utils/isMobile.js +13 -1
  372. package/lib/utils/loadAndBundleSpec.js +32 -1
  373. package/lib/utils/local-storage.js +12 -1
  374. package/lib/utils/object.js +31 -1
  375. package/lib/utils/openapi.js +592 -1
  376. package/lib/utils/parameters.js +13 -1
  377. package/lib/utils/path.js +22 -1
  378. package/lib/utils/queryString.js +60 -1
  379. package/lib/utils/replaceVariables.js +14 -1
  380. package/lib/utils/saveTextBeforeHeading.js +35 -1
  381. package/lib/utils/security-details.js +49 -1
  382. package/lib/utils/session-storage.js +12 -1
  383. package/lib/utils/simplifyAstStructure.js +22 -1
  384. package/lib/utils/sort.js +21 -1
  385. package/lib/utils/string.js +65 -1
  386. package/lib/utils/telemetry.js +7 -1
  387. package/lib/utils/test-utils.js +26 -1
  388. package/lib/utils/theme-helpers.js +24 -3
  389. package/lib/utils/url.js +38 -1
  390. package/package.json +5 -5
@@ -1 +1,63 @@
1
- import{encodeBackSlashes as o,queryString as s}from"../../utils/index.js";import{getActiveMediaType as r}from"../../models/mediaContent.js";function d(e,n){return e===n||"#"+e===n||e==="#"+n}function p(e,n){if(!e.in){if(e.deps.type==="request"&&e.deps.operation?.requestBody?.content?.mediaTypes)return e.deps.operation?.requestBody?.content?.mediaTypes.length>1?e.deps.operation?.requestBody?.content&&r(e.deps.operation.requestBody.content,n).name:void 0;if(e.deps.type==="response"&&e.deps.response?.content?.mediaTypes)return e.deps.response?.content?.mediaTypes.length>1?e.deps.response?.content&&r(e.deps.response.content,n).name:void 0}}function a(e,n){if(!e)return"";const t={t:e.deps.type,in:e.in||e.deps.in,c:e.deps.type==="response"?e.deps.response?.code:void 0,cb:e.deps.operation?.isCallback?e.deps.operation.callbackId:void 0,ct:p(e,n),path:e.fieldFullPath};return s.stringify(t,{encode:!1,sort:!1})}function c(e="",n="",t="/"){return e.endsWith(t)&&(e=e.slice(0,-t.length)),n.startsWith(t)&&(n=n.slice(t.length)),!e||!n?e+n:e+t+n}function y(e,n){return e=o(e),(`/${e}#`+c(e,n)).toLowerCase()}export{a as constructFieldDeepFragment,d as isSameHash,c as joinWithSeparator,y as makeDeepLink};
1
+ import { encodeBackSlashes, queryString } from '../../utils/index.js';
2
+ import { getActiveMediaType } from '../../models/mediaContent.js';
3
+ export function isSameHash(a, b) {
4
+ return a === b || '#' + a === b || a === '#' + b;
5
+ }
6
+ // TODO: Add tests
7
+ function getContentTypeName(field, activeMimeName) {
8
+ // param in "query" | "header" | "path" | "cookie" - no need for content type in link
9
+ if (field.in) {
10
+ return;
11
+ }
12
+ // Use content type from requestBody
13
+ if (field.deps.type === 'request') {
14
+ if (field.deps.operation?.requestBody?.content?.mediaTypes) {
15
+ return field.deps.operation?.requestBody?.content?.mediaTypes.length > 1
16
+ ? field.deps.operation?.requestBody?.content &&
17
+ getActiveMediaType(field.deps.operation.requestBody.content, activeMimeName).name
18
+ : undefined; // if only one content type present - also no need for content type in link
19
+ }
20
+ }
21
+ // Use content type from response
22
+ if (field.deps.type === 'response') {
23
+ if (field.deps.response?.content?.mediaTypes) {
24
+ return field.deps.response?.content?.mediaTypes.length > 1
25
+ ? field.deps.response?.content &&
26
+ getActiveMediaType(field.deps.response.content, activeMimeName).name
27
+ : undefined; // if only one content type present - also no need for content type in link
28
+ }
29
+ }
30
+ return;
31
+ }
32
+ // TODO: Add tests
33
+ export function constructFieldDeepFragment(field, activeMimeName) {
34
+ if (!field) {
35
+ return '';
36
+ }
37
+ const linkParams = {
38
+ t: field.deps.type, // "request" | "response"
39
+ in: field.in || field.deps.in, // "query" | "header" | "path" | "cookie" // TODO: remove 'in' from deps
40
+ c: field.deps.type === 'response' ? field.deps.response?.code : undefined, // response code: 200 | 201 | 400 | etc
41
+ cb: field.deps.operation?.isCallback ? field.deps.operation.callbackId : undefined, // Callback
42
+ ct: getContentTypeName(field, activeMimeName),
43
+ path: field.fieldFullPath, // Field deep path
44
+ };
45
+ return queryString.stringify(linkParams, { encode: false, sort: false });
46
+ }
47
+ export function joinWithSeparator(base = '', path = '', sep = '/') {
48
+ if (base.endsWith(sep)) {
49
+ base = base.slice(0, -sep.length);
50
+ }
51
+ if (path.startsWith(sep)) {
52
+ path = path.slice(sep.length);
53
+ }
54
+ if (!base || !path) {
55
+ return base + path;
56
+ }
57
+ return base + sep + path;
58
+ }
59
+ export function makeDeepLink(operationId, suffix) {
60
+ operationId = encodeBackSlashes(operationId);
61
+ return (`/${operationId}#` + joinWithSeparator(operationId, suffix)).toLowerCase();
62
+ }
63
+ //# sourceMappingURL=helpers.js.map
@@ -1 +1,2 @@
1
- export*from"./helpers.js";
1
+ export * from './helpers.js'; // TODO: move or remove
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1,9 @@
1
- export*from"./history/index.js";export*from"./code-samples/index.js";export*from"./types.js";import{OpenAPIParser as m}from"./OpenAPIParser.js";import{buildContentItems as x}from"./menu/index.js";export*from"./types.js";export*from"./config-options/index.js";import{deepClone as s}from"./utils.js";export{m as OpenAPIParser,x as buildContentItems,s as deepClone};
1
+ export * from './history/index.js';
2
+ export * from './code-samples/index.js';
3
+ export * from './types.js';
4
+ export { OpenAPIParser } from './OpenAPIParser.js';
5
+ export { buildContentItems } from './menu/index.js';
6
+ export * from './types.js';
7
+ export * from './config-options/index.js';
8
+ export { deepClone } from './utils.js';
9
+ //# sourceMappingURL=index.js.map
@@ -1 +1,47 @@
1
- import{getTagGroupsItems as r,getTagsItems as d,getTagsWithOperations as c}from"./tags.js";import{addMarkdownItems as g}from"./markdown.js";import{flattenByProp as p,getValueFromMdParsedExtension as h}from"../../utils/index.js";import{DEFAULT_WEBHOOKS_TAG_NAME as u}from"../../constants.js";function l(t,n){const{definition:e}=t,{schemaDefinitionsTagName:i}=n,s=[{id:"",name:e?.info?.["x-seo"]?.title||e?.info?.title||"Overview",href:"/",depth:1,level:1,type:"section",infoDefinition:e.info,items:[]}],o=[...e.tags||[]];o.some(a=>a.name===u)||o.push({name:u}),!o.find(a=>a?.name===i)&&i&&o.push({name:i});const f=c(t,o),m=e["x-tagGroups"];return s.push(...g(h(e.info,"description")||"",void 0,1)),m&&m.length>0?s.push(...r(t,void 0,m,f,n)):s.push(...d(t,f,void 0,void 0,n)),s}function E(t,n){const e=l(t,n),i=p(e||[],"items");return{contentItems:e,flatItems:i}}export{E as buildContentItems,l as buildMenuStructure};
1
+ import { getTagGroupsItems, getTagsItems, getTagsWithOperations } from './tags.js';
2
+ import { addMarkdownItems } from './markdown.js';
3
+ import { flattenByProp, getValueFromMdParsedExtension } from '../../utils/index.js';
4
+ import { DEFAULT_WEBHOOKS_TAG_NAME } from '../../constants.js';
5
+ export function buildMenuStructure(parser, options) {
6
+ const { definition } = parser;
7
+ const { schemaDefinitionsTagName } = options;
8
+ const items = [
9
+ {
10
+ id: '',
11
+ name: definition?.info?.['x-seo']?.title || definition?.info?.title || 'Overview',
12
+ href: '/',
13
+ depth: 1, // special case for root item,
14
+ level: 1,
15
+ type: 'section',
16
+ infoDefinition: definition.info,
17
+ items: [],
18
+ },
19
+ ];
20
+ const tags = [...(definition.tags || [])];
21
+ if (!tags.some((tag) => tag.name === DEFAULT_WEBHOOKS_TAG_NAME)) {
22
+ tags.push({ name: DEFAULT_WEBHOOKS_TAG_NAME });
23
+ }
24
+ const hasAutogenerated = tags.find((tag) => tag?.name === schemaDefinitionsTagName);
25
+ if (!hasAutogenerated && schemaDefinitionsTagName) {
26
+ tags.push({ name: schemaDefinitionsTagName });
27
+ }
28
+ const tagsMap = getTagsWithOperations(parser, tags);
29
+ const xTagGroups = definition['x-tagGroups'];
30
+ items.push(...addMarkdownItems(getValueFromMdParsedExtension(definition.info, 'description') || '', undefined, 1));
31
+ if (xTagGroups && xTagGroups.length > 0) {
32
+ items.push(...getTagGroupsItems(parser, undefined, xTagGroups, tagsMap, options));
33
+ }
34
+ else {
35
+ items.push(...getTagsItems(parser, tagsMap, undefined, undefined, options));
36
+ }
37
+ return items;
38
+ }
39
+ export function buildContentItems(parser, options) {
40
+ const contentItems = buildMenuStructure(parser, options);
41
+ const flatItems = flattenByProp(contentItems || [], 'items');
42
+ return {
43
+ contentItems,
44
+ flatItems,
45
+ };
46
+ }
47
+ //# sourceMappingURL=builder.js.map
@@ -1 +1,2 @@
1
- import{buildContentItems as o}from"./builder.js";export{o as buildContentItems};
1
+ export { buildContentItems } from './builder.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1,93 @@
1
- import h from"@markdoc/markdoc";import{isString as T}from"@redocly/theme/core/openapi";import{getTagOrGroup as d}from"../../models/index.js";import{safeSlugify as y,unescapeHTMLChars as A}from"../../utils/index.js";function x(e,n,a){const i=T(e)?h.parse(e):h.Ast.fromJSON(JSON.stringify(e?.result)),s=[];let o;const l=(t,u,g=s,r,p)=>{t=A(t);let f;r.attributes.id?f=r.attributes.id:(f=p?`${p}/${y(t)}`:`section/${y(t)}`,r.attributes.id=f);const b={id:f.toLowerCase(),name:t,level:u,items:[],ast:[r]};return g.push(b),b},c=(t,u)=>{t[t.length-1]?.ast?.push(u)},m=t=>{const u=C(t)||"",r=n&&n.type==="tag"?n.id:void 0;t.type==="heading"&&t.attributes.level===1?o=l(u,t.attributes.level,void 0,t,r):t.attributes.level?l(u,t.attributes.level,o?.items,t,o?.id??r):o?.items?.length?c(o?.items,t):s?.length&&c(s,t)};if(Array.isArray(i))for(const t of i)m(t);else m(i);return v(n,s,a)}function v(e,n,a=1){return n.map(i=>{const s=d("section",i,e);return s.depth=a,i.items&&(s.items=v(s,i.items,a+1)),s})}function C(e){if(typeof e?.attributes?.content=="string")return e.attributes?.content;if(e?.children)return C(e.children[0])}export{x as addMarkdownItems};
1
+ import markdoc from '@markdoc/markdoc';
2
+ import { isString } from '@redocly/theme/core/openapi';
3
+ import { getTagOrGroup } from '../../models/index.js';
4
+ import { safeSlugify, unescapeHTMLChars } from '../../utils/index.js';
5
+ import { simplifyAstStructure } from '../../utils/simplifyAstStructure.js';
6
+ /**
7
+ * extracts items from markdown description
8
+ * @param description - markdown source
9
+ * @param parent
10
+ * @param initialDepth - number of items depth
11
+ */
12
+ export function addMarkdownItems(description, parent, initialDepth) {
13
+ const ast = isString(description)
14
+ ? simplifyAstStructure(markdoc.parse(description))
15
+ : markdoc.Ast.fromJSON(JSON.stringify(description?.result));
16
+ const items = [];
17
+ let currentTopHeading;
18
+ const saveHeading = (name, level, container = items, node, parentId) => {
19
+ name = unescapeHTMLChars(name);
20
+ // use custom id or generate id
21
+ let id;
22
+ if (node.attributes.id) {
23
+ id = node.attributes.id;
24
+ }
25
+ else {
26
+ id = parentId ? `${parentId}/${safeSlugify(name)}` : `section/${safeSlugify(name)}`;
27
+ node.attributes.id = id;
28
+ }
29
+ const item = {
30
+ id: id.toLowerCase(),
31
+ name,
32
+ level,
33
+ items: [],
34
+ ast: [node],
35
+ };
36
+ container.push(item);
37
+ return item;
38
+ };
39
+ const saveContent = (container, node) => {
40
+ container[container.length - 1]?.ast?.push(node);
41
+ };
42
+ const processAst = (node) => {
43
+ const name = getMarkdownContent(node) || '';
44
+ // use tag id as prefix instead of just "section" to avoid identical header ids in different tags
45
+ const isTagContext = parent && parent.type === 'tag';
46
+ const parentId = isTagContext ? parent.id : undefined;
47
+ if (node.type === 'heading' && node.attributes.level === 1) {
48
+ // h1
49
+ currentTopHeading = saveHeading(name, node.attributes.level, undefined, node, parentId);
50
+ }
51
+ else if (node.attributes.level) {
52
+ // h2, h3, h4 etc
53
+ saveHeading(name, node.attributes.level, currentTopHeading?.items, node, currentTopHeading?.id ?? parentId);
54
+ }
55
+ else {
56
+ // text, p, etc
57
+ if (currentTopHeading?.items?.length) {
58
+ saveContent(currentTopHeading?.items, node);
59
+ }
60
+ else if (items?.length) {
61
+ saveContent(items, node);
62
+ }
63
+ }
64
+ };
65
+ if (Array.isArray(ast)) {
66
+ for (const node of ast) {
67
+ processAst(node);
68
+ }
69
+ }
70
+ else {
71
+ processAst(ast);
72
+ }
73
+ return mapHeadingsDeep(parent, items, initialDepth);
74
+ }
75
+ function mapHeadingsDeep(parent, items, depth = 1) {
76
+ return items.map((heading) => {
77
+ const group = getTagOrGroup('section', heading, parent);
78
+ group.depth = depth;
79
+ if (heading.items) {
80
+ group.items = mapHeadingsDeep(group, heading.items, depth + 1);
81
+ }
82
+ return group;
83
+ });
84
+ }
85
+ function getMarkdownContent(node) {
86
+ if (typeof node?.attributes?.content === 'string') {
87
+ return node.attributes?.content;
88
+ }
89
+ if (node?.children) {
90
+ return getMarkdownContent(node.children[0]);
91
+ }
92
+ }
93
+ //# sourceMappingURL=markdown.js.map
@@ -1 +1,50 @@
1
- import{REDOCLY_TEAMS_RBAC as r}from"@redocly/config";import{encodeBackSlashes as d,getOperationId as c,getOperationName as m}from"../../utils/index.js";function g(o,n,a){if(n.operations.length===0)return[];const p=[],s=[];for(const e of n.operations){const t=c(e,o),i={id:t,type:"operation",parent:o,operationDefinition:e,depth:a,name:m(e),httpVerb:e.httpVerb,path:e.pathName,items:[],isWebhook:e.isWebhook,operationId:e.operationId,badges:e["x-badges"]||[],href:h({id:t}),deprecated:!!e.deprecated,[r]:e[r]||o?.[r]};e.isWebhook?s.push(i):p.push(i)}return[...p.sort((e,t)=>Number(e.deprecated)-Number(t.deprecated)),...s.sort((e,t)=>Number(e.deprecated)-Number(t.deprecated))]}function h({id:o}){return d(`/${o}`.toLowerCase())}export{h as getHref,g as getOperationsItems};
1
+ import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
2
+ import { encodeBackSlashes, getOperationId, getOperationName } from '../../utils/index.js';
3
+ /**
4
+ * Returns array of Operation items for the tag
5
+ * @param parent parent OperationsGroup
6
+ * @param tag tag info returned from `getTagsWithOperations`
7
+ * @param depth items depth
8
+ */
9
+ export function getOperationsItems(parent, tag, depth) {
10
+ if (tag.operations.length === 0) {
11
+ return [];
12
+ }
13
+ const operations = [];
14
+ const webhooks = [];
15
+ for (const operationDefinition of tag.operations) {
16
+ const id = getOperationId(operationDefinition, parent);
17
+ const type = 'operation';
18
+ const item = {
19
+ id,
20
+ type,
21
+ parent,
22
+ operationDefinition,
23
+ depth,
24
+ name: getOperationName(operationDefinition),
25
+ httpVerb: operationDefinition.httpVerb,
26
+ path: operationDefinition.pathName,
27
+ items: [],
28
+ isWebhook: operationDefinition.isWebhook,
29
+ operationId: operationDefinition.operationId,
30
+ badges: operationDefinition['x-badges'] || [],
31
+ href: getHref({ id }),
32
+ deprecated: !!operationDefinition.deprecated,
33
+ [REDOCLY_TEAMS_RBAC]: operationDefinition[REDOCLY_TEAMS_RBAC] || parent?.[REDOCLY_TEAMS_RBAC],
34
+ };
35
+ if (operationDefinition.isWebhook) {
36
+ webhooks.push(item);
37
+ }
38
+ else {
39
+ operations.push(item);
40
+ }
41
+ }
42
+ return [
43
+ ...operations.sort((a, b) => Number(a.deprecated) - Number(b.deprecated)),
44
+ ...webhooks.sort((a, b) => Number(a.deprecated) - Number(b.deprecated)), // webhooks must be in the end for adding separator
45
+ ];
46
+ }
47
+ export function getHref({ id }) {
48
+ return encodeBackSlashes(`/${id}`.toLowerCase());
49
+ }
50
+ //# sourceMappingURL=operation.js.map
@@ -1 +1,166 @@
1
- import{getTagOrGroup as u}from"../../models/group.js";import{DEFAULT_WEBHOOKS_TAG_NAME as h,GROUP_DEPTH as g}from"../../constants.js";import{getValueFromMdParsedExtension as l,isOperationName as x,JsonPointer as y}from"../../utils/index.js";import{getOperationsItems as T}from"./operation.js";import{addMarkdownItems as O}from"./markdown.js";function b(c,i,s,n,r){let e;if(n===void 0?e=Object.keys(i):e=n.tags,!Array.isArray(e))return console.warn("Unexpected values of tags. Check tags or x-tagGroups in your definition."),[];const f=e.map(t=>i[t]?(i[t].used=!0,i[t]):(console.warn(`Non-existing tag "${t}" is added to the group "${n?.name}"`),null)),a=[];for(const t of f){if(!t)continue;const o=u("tag",t,s);if(o.depth=g+1,t.name===""){const m=[...O(l(t,"description")||"",o,o.depth+1),...T(void 0,t,o.depth+1)];a.push(...m);continue}const p=k({definition:c.definition,tag:t,parent:o,schemaDefinitionsTagName:r.schemaDefinitionsTagName});o.items=[...p,...O(l(t,"description")||"",o,o.depth+1),...T(o,t,o.depth+1)],a.push(o)}return a.filter(({name:t,items:o})=>t!==h||o.length>0)}function G(c,i,s,n,r){const e=[];for(const f of s){const a=u("group",f,i);a.depth=g,a.items=b(c,n,a,f,r),e.push(a)}return e}function k({definition:c,tag:i,parent:s,schemaDefinitionsTagName:n}){const r=n?[n]:[];return Object.entries(c.components?.schemas||{}).map(([e,f])=>{if(!(f["x-tags"]||r).includes(i.name))return null;const t=u("schema",{name:e,"x-displayName":`${f.title||e}`,description:`{% schemaDefinition showWriteOnly="true" schemaRef="#/components/schemas/${e}" /%}`,isSchema:!0,level:2},s);return t.depth=s.depth+1,t}).filter(Boolean)}function I(c,i){const{definition:s}=c,n={},r=s["x-webhooks"]||s.webhooks;for(const e of i||[])n[e.name]={...e,operations:[]};return s.paths&&d(c,s.paths,n),r&&d(c,r,n,!0),n}function d(c,i,s,n){for(const r of Object.keys(i||{})){const e=i[r],f=Object.keys(e).filter(x);for(const a of f){const t=e[a];if(e.$ref){const{resolved:p}=c.deref(e);d(c,{[r]:p},s,n);continue}let o=t?.tags;(!o||!o.length)&&(o=n?[h]:[""]);for(const p of o){let m=s[p];m===void 0&&(m={name:p,operations:[]},s[p]=m),!m["x-traitTag"]&&m.operations.push({...t,pathName:r,pointer:y.compile(["paths",r,a]),httpVerb:a,pathParameters:e.parameters||[],pathServers:e.servers,isWebhook:!!n})}}}}export{G as getTagGroupsItems,b as getTagsItems,I as getTagsWithOperations};
1
+ import { getTagOrGroup } from '../../models/group.js';
2
+ import { DEFAULT_WEBHOOKS_TAG_NAME, GROUP_DEPTH } from '../../constants.js';
3
+ import { getValueFromMdParsedExtension, isOperationName, JsonPointer } from '../../utils/index.js';
4
+ import { getOperationsItems } from './operation.js';
5
+ import { addMarkdownItems } from './markdown.js';
6
+ /**
7
+ * Returns array of OperationsGroup items for the tags of the group or for all tags
8
+ * @param parser
9
+ * @param tagsMap tags info returned from `getTagsWithOperations`
10
+ * @param parent parent item
11
+ * @param group group which this tag belongs to. if not provided gets all tags
12
+ * @param options - normalized options
13
+ */
14
+ export function getTagsItems(parser, tagsMap, parent, group, options) {
15
+ let tagNames;
16
+ if (group === undefined) {
17
+ tagNames = Object.keys(tagsMap);
18
+ }
19
+ else {
20
+ tagNames = group.tags;
21
+ }
22
+ if (!Array.isArray(tagNames)) {
23
+ console.warn('Unexpected values of tags. Check tags or x-tagGroups in your definition.');
24
+ return [];
25
+ }
26
+ const tags = tagNames.map((tagName) => {
27
+ if (!tagsMap[tagName]) {
28
+ console.warn(`Non-existing tag "${tagName}" is added to the group "${group?.name}"`);
29
+ return null;
30
+ }
31
+ tagsMap[tagName].used = true;
32
+ return tagsMap[tagName];
33
+ });
34
+ const res = [];
35
+ for (const tag of tags) {
36
+ if (!tag)
37
+ continue;
38
+ const item = getTagOrGroup('tag', tag, parent);
39
+ item.depth = GROUP_DEPTH + 1;
40
+ // don't put empty tag into content, instead put its operations
41
+ if (tag.name === '') {
42
+ const items = [
43
+ ...addMarkdownItems(getValueFromMdParsedExtension(tag, 'description') || '', item, item.depth + 1),
44
+ ...getOperationsItems(undefined, tag, item.depth + 1),
45
+ ];
46
+ res.push(...items);
47
+ continue;
48
+ }
49
+ const relatedSchemas = getTagRelatedSchema({
50
+ definition: parser.definition,
51
+ tag,
52
+ parent: item,
53
+ schemaDefinitionsTagName: options.schemaDefinitionsTagName,
54
+ });
55
+ item.items = [
56
+ ...relatedSchemas,
57
+ ...addMarkdownItems(getValueFromMdParsedExtension(tag, 'description') || '', item, item.depth + 1),
58
+ ...getOperationsItems(item, tag, item.depth + 1),
59
+ ];
60
+ res.push(item);
61
+ }
62
+ return res.filter(({ name, items }) => name !== DEFAULT_WEBHOOKS_TAG_NAME || items.length > 0);
63
+ }
64
+ /**
65
+ * Returns array of OperationsGroup items for the tag groups (x-tagGroups vendor extension)
66
+ * @param parser
67
+ * @param parent
68
+ * @param groups
69
+ * @param tags value of `x-tagGroups` vendor extension
70
+ * @param options - normalized options
71
+ */
72
+ export function getTagGroupsItems(parser, parent, groups, tags, options) {
73
+ const res = [];
74
+ for (const group of groups) {
75
+ const item = getTagOrGroup('group', group, parent);
76
+ item.depth = GROUP_DEPTH;
77
+ item.items = getTagsItems(parser, tags, item, group, options);
78
+ res.push(item);
79
+ }
80
+ return res;
81
+ }
82
+ /**
83
+ * Returns array of schemas with reference to tag, or schemas with reference to schemaDefinitionsTagName tag
84
+ * @param tagsMap all tags
85
+ * @param tag tag to find reference of schema
86
+ * @param schemaDefinitionsTagName config
87
+ */
88
+ function getTagRelatedSchema({ definition, tag, parent, schemaDefinitionsTagName, }) {
89
+ const defaultTags = schemaDefinitionsTagName ? [schemaDefinitionsTagName] : [];
90
+ return Object.entries(definition.components?.schemas || {})
91
+ .map(([schemaName, schema]) => {
92
+ const schemaTags = schema['x-tags'] || defaultTags;
93
+ if (!schemaTags.includes(tag.name))
94
+ return null;
95
+ const item = getTagOrGroup('schema', {
96
+ name: schemaName,
97
+ 'x-displayName': `${schema.title || schemaName}`,
98
+ description: `{% schemaDefinition showWriteOnly="true" schemaRef="#/components/schemas/${schemaName}" /%}`,
99
+ isSchema: true,
100
+ level: 2,
101
+ }, parent);
102
+ item.depth = parent.depth + 1;
103
+ return item;
104
+ })
105
+ .filter(Boolean);
106
+ }
107
+ /**
108
+ * collects tags and maps each tag to list of operations belonging to this tag
109
+ */
110
+ export function getTagsWithOperations(parser, explicitTags) {
111
+ const { definition } = parser;
112
+ const tags = {};
113
+ const webhooks = definition['x-webhooks'] || definition.webhooks;
114
+ for (const tag of explicitTags || []) {
115
+ tags[tag.name] = { ...tag, operations: [] };
116
+ }
117
+ if (definition.paths) {
118
+ getTags(parser, definition.paths, tags);
119
+ }
120
+ if (webhooks) {
121
+ getTags(parser, webhooks, tags, true);
122
+ }
123
+ return tags;
124
+ }
125
+ function getTags(parser, paths, tags, isWebhook) {
126
+ for (const pathName of Object.keys(paths || {})) {
127
+ const path = paths[pathName];
128
+ const operations = Object.keys(path).filter(isOperationName);
129
+ for (const operationName of operations) {
130
+ const operationInfo = path[operationName];
131
+ if (path.$ref) {
132
+ const { resolved: resolvedPaths } = parser.deref(path);
133
+ getTags(parser, { [pathName]: resolvedPaths }, tags, isWebhook);
134
+ continue;
135
+ }
136
+ let operationTags = operationInfo?.tags;
137
+ if (!operationTags || !operationTags.length) {
138
+ // empty tag for operations and default tag for webhooks
139
+ operationTags = isWebhook ? [DEFAULT_WEBHOOKS_TAG_NAME] : [''];
140
+ }
141
+ for (const tagName of operationTags) {
142
+ let tag = tags[tagName];
143
+ if (tag === undefined) {
144
+ tag = {
145
+ name: tagName,
146
+ operations: [],
147
+ };
148
+ tags[tagName] = tag;
149
+ }
150
+ if (tag['x-traitTag']) {
151
+ continue;
152
+ }
153
+ tag.operations.push({
154
+ ...operationInfo,
155
+ pathName,
156
+ pointer: JsonPointer.compile(['paths', pathName, operationName]),
157
+ httpVerb: operationName,
158
+ pathParameters: path.parameters || [],
159
+ pathServers: path.servers,
160
+ isWebhook: !!isWebhook,
161
+ });
162
+ }
163
+ }
164
+ }
165
+ }
166
+ //# sourceMappingURL=tags.js.map
@@ -91,9 +91,6 @@ export interface HooksConfig {
91
91
  AfterApiTitle?: HookConfig<{
92
92
  info: OpenAPIInfo;
93
93
  }>;
94
- AfterOpenApiDescription?: HookConfig<{
95
- info: OpenAPIInfo;
96
- }>;
97
94
  BeforeOperation?: HookConfig<{
98
95
  operation: OperationModel;
99
96
  }>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1,83 @@
1
- import c from"deepmerge";import{isObject as i}from"@redocly/theme/core/openapi";import{isMergeableObject as u}from"../utils/index.js";function b(e,r){return!e||!r?!1:s(e)===s(r)}function s(e){if(!e)return;const r=e.split(";")[0].toLowerCase(),[t,n]=r.split("/");if(n===void 0)return t;const p=n.split("+").pop();return`${t}/${p}`}function m(e){const r=new RegExp("%7B","g"),t=new RegExp("%7D","g");return e.replace(r,"{").replace(t,"}").replace("///","//").replace("./",".")}function a(e,r){if(!(e.length&&f(e)))return r;const t=e.filter(n=>Object.keys(n).length>0);return r.forEach(function(n,o){u(n)?t[o]=c(e[o],n,{arrayMerge:a}):Array.isArray(n)?t.push(n):t[o]=n}),t}const f=e=>e.some(r=>i(r)&&Object.keys(r).length>0);function w(e){return!!e&&Object.keys(e).length===0}const x=typeof window<"u"&&(window.crypto||window.msCrypto)||void 0;function l(e){if(typeof e!="object"||e===null)return e;const r=Array.isArray(e)?[]:{};for(const t in e){const n=e[t];r[t]=l(n)}return r}export{a as arrayMergeStrategy,x as cryptoLib,l as deepClone,w as isEmptyObject,b as isSameMime,s as normalizeMimeType,m as unescapeServerVariables};
1
+ import merge from 'deepmerge';
2
+ import { isObject } from '@redocly/theme/core/openapi';
3
+ import { isMergeableObject } from '../utils/index.js';
4
+ /**
5
+ * Compare mime-types ignoring charset or other params (application/json;charset=UTF-8)
6
+ * @param a
7
+ * @param b
8
+ */
9
+ export function isSameMime(a, b) {
10
+ if (!a || !b)
11
+ return false;
12
+ return normalizeMimeType(a) === normalizeMimeType(b);
13
+ }
14
+ /**
15
+ * Removes the mime-types params e.g. charset (application/json;charset=UTF-8))
16
+ * Removes any prefixes, e.g. application/hal+json => application/json
17
+ * Spec is type/subtype;param1=value or type/semantic+format;param1=value
18
+ * @param mimeType mime type string or undefined
19
+ */
20
+ export function normalizeMimeType(mimeType) {
21
+ if (!mimeType)
22
+ return undefined;
23
+ const mime = mimeType.split(';')[0].toLowerCase(); // get rid of parameters part
24
+ const [type, subtype] = mime.split('/');
25
+ if (subtype === undefined) {
26
+ return type; // some wrong format, return as is
27
+ }
28
+ const subtypeParts = subtype.split('+');
29
+ const syntax = subtypeParts.pop();
30
+ return `${type}/${syntax}`;
31
+ }
32
+ export function unescapeServerVariables(str) {
33
+ // Brackets are escaped in the curl code samples #88
34
+ // ex.: http://localhost:7700/code-samples-playground?versions#operation/Case-11_1
35
+ const bracketsOpenReg = new RegExp('%7B', 'g'); // {
36
+ const bracketsCloseReg = new RegExp('%7D', 'g'); // }
37
+ return str
38
+ .replace(bracketsOpenReg, '{')
39
+ .replace(bracketsCloseReg, '}')
40
+ .replace('///', '//')
41
+ .replace('./', '.');
42
+ }
43
+ export function arrayMergeStrategy(target, source) {
44
+ if (!(target.length && hasObjectOrArray(target))) {
45
+ return source;
46
+ }
47
+ const destination = target.filter((item) => Object.keys(item).length > 0);
48
+ source.forEach(function (item, index) {
49
+ if (isMergeableObject(item)) {
50
+ destination[index] = merge(target[index], item, { arrayMerge: arrayMergeStrategy });
51
+ }
52
+ else if (Array.isArray(item)) {
53
+ destination.push(item);
54
+ }
55
+ else {
56
+ destination[index] = item;
57
+ }
58
+ });
59
+ return destination;
60
+ }
61
+ const hasObjectOrArray = (array) => {
62
+ return array.some((item) => isObject(item) && Object.keys(item).length > 0);
63
+ };
64
+ export function isEmptyObject(obj) {
65
+ return !!obj && Object.keys(obj).length === 0;
66
+ }
67
+ export const cryptoLib = (typeof window !== 'undefined' &&
68
+ (window.crypto || window.msCrypto)) ||
69
+ undefined;
70
+ export function deepClone(inObject) {
71
+ if (typeof inObject !== 'object' || inObject === null) {
72
+ return inObject; // Return the value if inObject is not an object
73
+ }
74
+ // Create an array or object to hold the values
75
+ const outObject = Array.isArray(inObject) ? [] : {};
76
+ for (const key in inObject) {
77
+ const value = inObject[key];
78
+ // Recursively (deep) copy for nested objects, including arrays
79
+ outObject[key] = deepClone(value);
80
+ }
81
+ return outObject;
82
+ }
83
+ //# sourceMappingURL=utils.js.map
package/lib/standalone.js CHANGED
@@ -1 +1,68 @@
1
- import{jsx as i}from"react/jsx-runtime";import{createElement as p}from"react";import{createRoot as m,hydrateRoot as u}from"react-dom/client";import{querySelector as s}from"./utils/dom.js";import{RedoclyOpenAPIDocs as l}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js";import{RedoclyOpenAPIDocsStandalone as f}from"./components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js";import{setSecurityDetails as v,setSecurityDetailsVariants as O}from"./utils/security-details.js";import{setParameterValue as j}from"./utils/parameters.js";function _(t){const e={},o=t.attributes;for(let r=0;r<o.length;r++){const n=o[r];e[n.name]=n.value}return e}function d(t){const e=_(t),o={};for(const r in e){const n=r.replace(/-(.)/g,(c,a)=>a.toUpperCase());o[n]=e[r]}return o}function N(t,e=document.querySelector("redoc")){u(e,i(l,{store:t}))}function E(t,e={},o=s("redoc")){if(o===null)throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');let r,n;typeof t=="string"?r=t:typeof t=="object"&&(n=t),m(o).render(p(f,{definition:n,definitionUrl:r,options:{...e,...d(o)}},["Loading..."]))}const b=__REDOCLY_API_REFERENCE_VERSION__,h=__REDOCLY_API_REFERENCE_REVISION__;function R(){const t=s("redoc");if(!t)return;const e=t.getAttribute("spec-url");e&&E(e,{},t)}R();export{N as hydrate,E as init,h as revision,j as setParameterValue,v as setSecurityDetails,O as setSecurityDetailsVariants,b as version};
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createElement } from 'react';
3
+ import { createRoot, hydrateRoot } from 'react-dom/client';
4
+ import { querySelector } from './utils/dom.js';
5
+ import { RedoclyOpenAPIDocs } from './components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js';
6
+ import { RedoclyOpenAPIDocsStandalone } from './components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js';
7
+ export { setSecurityDetails, setSecurityDetailsVariants } from './utils/security-details.js';
8
+ export { setParameterValue } from './utils/parameters.js';
9
+ function attributesMap(element) {
10
+ const res = {};
11
+ const elAttrs = element.attributes;
12
+ // tslint:disable-next-line
13
+ for (let i = 0; i < elAttrs.length; i++) {
14
+ const attrib = elAttrs[i];
15
+ res[attrib.name] = attrib.value;
16
+ }
17
+ return res;
18
+ }
19
+ function parseOptionsFromElement(element) {
20
+ const attrMap = attributesMap(element);
21
+ const res = {};
22
+ for (const attrName in attrMap) {
23
+ const optionName = attrName.replace(/-(.)/g, (_, $1) => $1.toUpperCase());
24
+ res[optionName] = attrMap[attrName];
25
+ // TODO: normalize options
26
+ }
27
+ return res;
28
+ }
29
+ export function hydrate(store, element = document.querySelector('redoc')) {
30
+ // const store = ProStore.fromJS(state);
31
+ hydrateRoot(element, _jsx(RedoclyOpenAPIDocs, { store: store }));
32
+ }
33
+ export function init(definitionOrDefinitionUrl, options = {}, element = querySelector('redoc')) {
34
+ if (element === null) {
35
+ throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');
36
+ }
37
+ let definitionUrl;
38
+ let definition;
39
+ if (typeof definitionOrDefinitionUrl === 'string') {
40
+ definitionUrl = definitionOrDefinitionUrl;
41
+ }
42
+ else if (typeof definitionOrDefinitionUrl === 'object') {
43
+ definition = definitionOrDefinitionUrl;
44
+ }
45
+ const root = createRoot(element);
46
+ root.render(createElement(RedoclyOpenAPIDocsStandalone, {
47
+ definition,
48
+ definitionUrl,
49
+ options: { ...options, ...parseOptionsFromElement(element) },
50
+ }, ['Loading...']));
51
+ }
52
+ export const version = __REDOCLY_API_REFERENCE_VERSION__;
53
+ export const revision = __REDOCLY_API_REFERENCE_REVISION__;
54
+ /**
55
+ * autoinit ReDoc if <redoc> tag is found on the page with "spec-url" attr
56
+ */
57
+ function autoInit() {
58
+ const element = querySelector('redoc');
59
+ if (!element) {
60
+ return;
61
+ }
62
+ const specUrl = element.getAttribute('spec-url');
63
+ if (specUrl) {
64
+ init(specUrl, {}, element);
65
+ }
66
+ }
67
+ autoInit();
68
+ //# sourceMappingURL=standalone.js.map
@@ -1 +1,6 @@
1
- import t from"styled-components";const e=typeof t=="function"?t:t.default;export{e as styled};
1
+ import _styled from 'styled-components';
2
+ // https://github.com/styled-components/styled-components/issues/3601#issue-1023120934
3
+ export const styled =
4
+ // @ts-expect-error incompatibility between styled-components and @types/styled-components
5
+ typeof _styled === 'function' ? _styled : _styled.default;
6
+ //# sourceMappingURL=styled-components.js.map
package/lib/types/app.js CHANGED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=app.js.map
@@ -1 +1,4 @@
1
- export*from"./open-api.js";export*from"./security.js";export*from"./app.js";
1
+ export * from './open-api.js';
2
+ export * from './security.js';
3
+ export * from './app.js';
4
+ //# sourceMappingURL=index.js.map
@@ -105,6 +105,7 @@ export interface OpenAPIOperation extends ParsedDescriptionWithSummary {
105
105
  'x-codeSamples'?: OpenAPIXCodeSample[];
106
106
  'x-badges'?: OpenAPIXBadges[];
107
107
  'x-hideReplay'?: boolean;
108
+ 'x-owner-key'?: string;
108
109
  }
109
110
  export interface OpenAPIParameter extends ParsedDescription {
110
111
  name: string;