@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,26 @@
1
- import{getMediaType as y}from"./mediaType.js";function c({parser:a,info:e,isRequestType:p,options:d,data:{operation:n,type:i,response:m,absolutePointer:s=""}}){const r=Object.keys(e).map(t=>y(a,t,p,e[t],d,{operation:n,type:i,response:m,absolutePointer:s})),o=r.filter(t=>!!t.examples||!!t.formExamples).length>0;return{mediaTypes:r,isRequestType:p,hasSample:o,operation:n}}function f(a,e){return e&&a.mediaTypes.find(d=>d.name===e)||a.mediaTypes[0]||{}}export{f as getActiveMediaType,c as getMediaContent};
1
+ import { getMediaType } from './mediaType.js';
2
+ /**
3
+ * MediaContent model ready to be sued by React components
4
+ * Contains multiple MediaTypes and keeps track of the currently active one
5
+ */
6
+ export function getMediaContent({ parser, info, isRequestType, options, data: { operation, type, response, absolutePointer = '' }, }) {
7
+ const mediaTypes = Object.keys(info).map((name) => getMediaType(parser, name, isRequestType, info[name], options, {
8
+ operation,
9
+ type,
10
+ response,
11
+ absolutePointer,
12
+ }));
13
+ const hasSample = mediaTypes.filter((mime) => !!mime.examples || !!mime.formExamples).length > 0;
14
+ return {
15
+ mediaTypes,
16
+ isRequestType,
17
+ hasSample,
18
+ operation,
19
+ };
20
+ }
21
+ export function getActiveMediaType(content, activeMimeName) {
22
+ const mediaType = (activeMimeName && content.mediaTypes.find((type) => type.name === activeMimeName)) ||
23
+ content.mediaTypes[0];
24
+ return mediaType || {};
25
+ }
26
+ //# sourceMappingURL=mediaContent.js.map
@@ -1 +1,153 @@
1
- import{getSchema as E}from"./schema.js";import{isFormUrlEncoded as P,isJsonLike as b,isXmlLike as k,isMultipartFormData as j,JsonPointer as R,mapValues as w}from"../utils/index.js";import{getExamples as r}from"./example.js";import{safeSample as v}from"../services/code-samples/index.js";function g({parser:i,info:{encoding:e,schema:a},schema:l,mime:m,options:{isRequestType:s,onlyRequiredInSamples:u,generatedSamplesMaxDepth:p,format:d="json"}}){const f={skipReadOnly:s,skipWriteOnly:!s,skipNonRequired:s&&u,maxSampleDepth:p,quiet:!0,format:d};let n={};if(l&&l.oneOf)for(const o of l.oneOf){const t=v(o.rawSchema,f,i.definition);t!==null&&(l.discriminatorProp&&typeof t=="object"&&t&&t[l.discriminatorProp]&&(t[l.discriminatorProp]=o.title),n[o.title]=r({parser:i,infoOrRef:{value:t},mime:m,encoding:e}))}else if(l){const o=v(a,f,i.definition);o!==null?n={default:r({parser:i,infoOrRef:{value:o},mime:m,encoding:e})}:n={default:{value:null,rawValue:"null"}}}else n={default:{value:null,rawValue:"null"}};return n}function J(i,e,a,l,m,{operation:s,type:u,response:p,absolutePointer:d=""}){let f,n;const o=l.schema&&E({parser:i,schemaOrRef:l.schema,pointer:"",absolutePointer:R.join(d,["content",e,"schema"]),options:m,deps:{operation:s,type:u,response:p}}),{onlyRequiredInSamples:t,generatedSamplesMaxDepth:c}=m,{encoding:x,examples:O,example:S}=l;return m.unstable_skipSamples||(O!==void 0?f=w(O,h=>r({parser:i,infoOrRef:h,mime:e,encoding:x})):S!==void 0?f={default:r({parser:i,infoOrRef:{value:i.deref(S).resolved},mime:e,encoding:x})}:b(e)||k(e)?f=g({parser:i,info:l,schema:o,mime:e,options:{isRequestType:a,onlyRequiredInSamples:t,generatedSamplesMaxDepth:c,format:k(e)?"xml":"json"}}):(P(e)||j(e))&&(n=g({parser:i,info:l,schema:o,mime:e,options:{isRequestType:a,onlyRequiredInSamples:t,generatedSamplesMaxDepth:c}}))),{examples:f,schema:o,name:e,isRequestType:a,formExamples:n,onlyRequiredInSamples:t,operation:s}}export{J as getMediaType};
1
+ import { getSchema } from './schema.js';
2
+ import { isFormUrlEncoded, isJsonLike, isXmlLike, isMultipartFormData, JsonPointer, mapValues, } from '../utils/index.js';
3
+ import { getExamples } from './example.js';
4
+ import { safeSample } from '../services/code-samples/index.js';
5
+ function generateExamples({ parser, info: { encoding, schema: infoSchema }, schema, mime, options: { isRequestType, onlyRequiredInSamples, generatedSamplesMaxDepth, format = 'json' }, }) {
6
+ // FIXME: check warning in rebilly spec
7
+ const samplerOptions = {
8
+ skipReadOnly: isRequestType,
9
+ skipWriteOnly: !isRequestType,
10
+ skipNonRequired: isRequestType && onlyRequiredInSamples,
11
+ maxSampleDepth: generatedSamplesMaxDepth,
12
+ quiet: true,
13
+ format,
14
+ };
15
+ let examples = {};
16
+ if (schema && schema.oneOf) {
17
+ for (const subSchema of schema.oneOf) {
18
+ const sample = safeSample(subSchema.rawSchema, samplerOptions, parser.definition);
19
+ if (sample === null) {
20
+ continue;
21
+ }
22
+ if (schema.discriminatorProp &&
23
+ typeof sample === 'object' &&
24
+ sample &&
25
+ sample[schema.discriminatorProp] // handle case with readOnly with discriminator
26
+ ) {
27
+ sample[schema.discriminatorProp] = subSchema.title;
28
+ }
29
+ examples[subSchema.title] = getExamples({
30
+ parser,
31
+ infoOrRef: {
32
+ value: sample,
33
+ },
34
+ mime,
35
+ encoding,
36
+ });
37
+ }
38
+ }
39
+ else if (schema) {
40
+ const sample = safeSample(infoSchema, samplerOptions, parser.definition);
41
+ if (sample !== null) {
42
+ examples = {
43
+ default: getExamples({
44
+ parser,
45
+ infoOrRef: {
46
+ value: sample,
47
+ },
48
+ mime,
49
+ encoding,
50
+ }),
51
+ };
52
+ }
53
+ else {
54
+ examples = {
55
+ default: {
56
+ value: null,
57
+ rawValue: 'null',
58
+ },
59
+ };
60
+ }
61
+ }
62
+ else {
63
+ // default to {} example when schema is not defined
64
+ examples = {
65
+ default: {
66
+ value: null,
67
+ rawValue: 'null',
68
+ },
69
+ };
70
+ }
71
+ return examples;
72
+ }
73
+ /**
74
+ * @param parser
75
+ * @param name
76
+ * @param isRequestType needed to know if skip RO/RW fields in objects
77
+ * @param info
78
+ * @param options
79
+ * @param operation
80
+ * @param type
81
+ * @param response
82
+ */
83
+ export function getMediaType(parser, name, isRequestType, info, options, { operation, type, response, absolutePointer = '', }) {
84
+ let examples;
85
+ let formExamples;
86
+ const schema = info.schema &&
87
+ getSchema({
88
+ parser,
89
+ schemaOrRef: info.schema,
90
+ pointer: '',
91
+ absolutePointer: JsonPointer.join(absolutePointer, ['content', name, 'schema']),
92
+ options,
93
+ deps: {
94
+ operation,
95
+ type,
96
+ response,
97
+ },
98
+ });
99
+ const { onlyRequiredInSamples, generatedSamplesMaxDepth } = options;
100
+ const { encoding, examples: infoExamples, example } = info;
101
+ if (!options.unstable_skipSamples) {
102
+ if (infoExamples !== undefined) {
103
+ examples = mapValues(infoExamples, (example) => getExamples({ parser, infoOrRef: example, mime: name, encoding }));
104
+ }
105
+ else if (example !== undefined) {
106
+ examples = {
107
+ default: getExamples({
108
+ parser,
109
+ infoOrRef: { value: parser.deref(example).resolved },
110
+ mime: name,
111
+ encoding,
112
+ }),
113
+ };
114
+ }
115
+ else if (isJsonLike(name) || isXmlLike(name)) {
116
+ examples = generateExamples({
117
+ parser,
118
+ info,
119
+ schema,
120
+ mime: name,
121
+ options: {
122
+ isRequestType,
123
+ onlyRequiredInSamples,
124
+ generatedSamplesMaxDepth,
125
+ format: isXmlLike(name) ? 'xml' : 'json',
126
+ },
127
+ });
128
+ }
129
+ else if (isFormUrlEncoded(name) || isMultipartFormData(name)) {
130
+ formExamples = generateExamples({
131
+ parser,
132
+ info,
133
+ schema,
134
+ mime: name,
135
+ options: {
136
+ isRequestType,
137
+ onlyRequiredInSamples,
138
+ generatedSamplesMaxDepth,
139
+ },
140
+ });
141
+ }
142
+ }
143
+ return {
144
+ examples,
145
+ schema,
146
+ name,
147
+ isRequestType,
148
+ formExamples,
149
+ onlyRequiredInSamples,
150
+ operation,
151
+ };
152
+ }
153
+ //# sourceMappingURL=mediaType.js.map
@@ -1 +1,166 @@
1
- import{REDOCLY_TEAMS_RBAC as y}from"@redocly/config";import{removeLeadingSlash as b}from"@redocly/theme/core/openapi";import{configure as v}from"@redocly/theme/ext/configure";import{extractExtensions as x,getOperationId as R,getOperationName as q,getStatusCodeType as P,getValueFromMdParsedExtension as B,isStatusCode as E,JsonPointer as C,mergeParams as k,normalizeServers as o,sortByDeprecated as V,sortByRequired as I,updateOperationWithRequestValues as O,updateParametersWithUserValues as N}from"../utils/index.js";import{getCallback as W}from"./callback.js";import{getField as w}from"./field.js";import{getRequestBody as A}from"./request.js";import{getSecurity as S}from"./security.js";import{getResponse as F}from"./response.js";import{getHref as M}from"../services/menu/operation.js";function Z(s){return s.lang==="Payload"&&"requestBodyContent"in s}function $(s,e,t,a,m,d,c){const h=e.isWebhook,r={operationDefinition:e,parent:t,pointer:e.pointer,description:B(e,"description"),externalDocs:e.externalDocs,deprecated:!!e.deprecated,httpVerb:e.httpVerb,operationId:e.operationId,path:e.pathName,isWebhook:h,isCallback:!!d?.isCallback,isEvent:d?.isCallback||h,name:q(e),defaultExampleName:e.defaultSampleName,[y]:e[y]||t?.[y],type:"operation",callbackId:d?.id,href:m,get callbacks(){return Object.keys(e.callbacks||[]).map(u=>W(s,u,e.callbacks?.[u],r.pointer,a,m,t,c))},get responses(){let u=!1;return Object.keys(e.responses||[]).filter(l=>l==="default"?!0:(P(l)==="success"&&(u=!0),E(l))).map(l=>F({parser:s,code:l,defaultAsError:u,infoOrRef:e.responses[l],options:a,isEvent:r.isEvent,operation:r}))},get parameters(){return j(s,e,r,a,g)}};if(d?.isCallback)r.security=S(e.security,s),r.servers=o("",e.servers||e.pathServers||[]),r.id=b(m);else{r.id=R(e,t),r.href=r.href||M(r),r.security=S(e.security||s.definition.security,s);const u=e.servers||(e.pathServers?.length?e.pathServers:null)||s.definition.servers||[];r.servers=o(s.definitionUrl,L(u,a.mockServer))}a.showExtensions&&(r.extensions=x(e,a.showExtensions)),r.requestBody=e.requestBody?A({parser:s,infoOrRef:e.requestBody,options:a,operation:r,isEvent:r.isEvent}):void 0;const p=r.requestBody?.content;r.payload={lang:"Payload",source:"",requestBodyContent:p?.hasSample?p:void 0},r.definitionSamples=e["x-codeSamples"]||[],r.badges=e["x-badges"]?.map(({name:u,color:l,position:n})=>({name:u,color:l||"var(--color-info-base)",position:n||"after"}))||[],r.hasSamples=p?.hasSample||r.definitionSamples.length>0,r.hideReplay=e["x-hideReplay"]===!0;const f={userClaims:c,operation:{operationId:r.operationId,name:r.name,path:r.path,href:r.href,method:r.httpVerb},servers:r.servers},g=(v(f)||{}).requestValues||{};return O(r,g),r}function j(s,e,t,a,m){let d=k(s,e.pathParameters,e.parameters,{pathPointer:C.dirName(t.pointer),operationPointer:t.pointer}).map(({paramOrRef:c,pointer:h})=>{const r=w(s,c,h,a,{operation:t,type:"request"});return N(r,m),r});return a.sortRequiredPropsFirst&&(d=I(d)),V(d)}function L(s,e){if(!e)return s;const t={url:e.url,description:e.description};switch(e.position){case"first":return[t,...s];case"last":return[...s,t];case"replace":return[t];default:return s}}export{$ as getOperation,Z as isPayloadSample,L as mergeInMockServer};
1
+ import { REDOCLY_TEAMS_RBAC } from '@redocly/config';
2
+ import { removeLeadingSlash } from '@redocly/theme/core/openapi';
3
+ import { configure } from '@redocly/theme/ext/configure';
4
+ import { extractExtensions, getOperationId, getOperationName, getStatusCodeType, getValueFromMdParsedExtension, isStatusCode, JsonPointer, mergeParams, normalizeServers, sortByDeprecated, sortByRequired, updateOperationWithRequestValues, updateParametersWithUserValues, } from '../utils/index.js';
5
+ import { getCallback } from './callback.js';
6
+ import { getField } from './field.js';
7
+ import { getRequestBody } from './request.js';
8
+ import { getSecurity } from './security.js';
9
+ import { getResponse } from './response.js';
10
+ import { getHref } from '../services/menu/operation.js';
11
+ export function isPayloadSample(sample) {
12
+ return sample.lang === 'Payload' && 'requestBodyContent' in sample;
13
+ }
14
+ export function getOperation(parser, operationDefinition, parent, options, href, callback, userClaims) {
15
+ const isWebhook = operationDefinition.isWebhook;
16
+ const operation = {
17
+ operationDefinition,
18
+ parent,
19
+ pointer: operationDefinition.pointer,
20
+ description: getValueFromMdParsedExtension(operationDefinition, 'description'),
21
+ externalDocs: operationDefinition.externalDocs,
22
+ deprecated: !!operationDefinition.deprecated,
23
+ httpVerb: operationDefinition.httpVerb,
24
+ operationId: operationDefinition.operationId,
25
+ path: operationDefinition.pathName,
26
+ isWebhook,
27
+ isCallback: Boolean(callback?.isCallback),
28
+ isEvent: callback?.isCallback || isWebhook,
29
+ name: getOperationName(operationDefinition),
30
+ defaultExampleName: operationDefinition.defaultSampleName,
31
+ [REDOCLY_TEAMS_RBAC]: operationDefinition[REDOCLY_TEAMS_RBAC] || parent?.[REDOCLY_TEAMS_RBAC],
32
+ type: 'operation',
33
+ callbackId: callback?.id,
34
+ href,
35
+ get callbacks() {
36
+ return Object.keys(operationDefinition.callbacks || []).map((callbackEventName) => {
37
+ return getCallback(parser, callbackEventName, operationDefinition.callbacks?.[callbackEventName], operation.pointer, options, href, parent, userClaims);
38
+ });
39
+ },
40
+ get responses() {
41
+ let hasSuccessResponses = false;
42
+ return Object.keys(operationDefinition.responses || [])
43
+ .filter((code) => {
44
+ if (code === 'default') {
45
+ return true;
46
+ }
47
+ if (getStatusCodeType(code) === 'success') {
48
+ hasSuccessResponses = true;
49
+ }
50
+ return isStatusCode(code);
51
+ }) // filter out other props (e.g. x-props)
52
+ .map((code) => {
53
+ return getResponse({
54
+ parser,
55
+ code,
56
+ defaultAsError: hasSuccessResponses,
57
+ infoOrRef: operationDefinition.responses[code],
58
+ options,
59
+ isEvent: operation.isEvent,
60
+ operation,
61
+ });
62
+ });
63
+ },
64
+ get parameters() {
65
+ return processParameters(parser, operationDefinition, operation, options, userDefinedRequestValues);
66
+ },
67
+ };
68
+ if (callback?.isCallback) {
69
+ // NOTE: Callbacks by default should not inherit the specification's global `security` definition.
70
+ // Can be defined individually per-callback in the specification. Defaults to none.
71
+ operation.security = getSecurity(operationDefinition.security, parser);
72
+ // TODO: update getting pathInfo for overriding servers on path level
73
+ operation.servers = normalizeServers('', operationDefinition.servers || operationDefinition.pathServers || []);
74
+ // TODO: remove it when all deep links are updated with one proper handler
75
+ operation.id = removeLeadingSlash(href); // pass operation href as id for callbacks
76
+ }
77
+ else {
78
+ operation.id = getOperationId(operationDefinition, parent);
79
+ operation.href = operation.href || getHref(operation);
80
+ operation.security = getSecurity(operationDefinition.security || parser.definition.security, parser);
81
+ const servers = operationDefinition.servers ||
82
+ (operationDefinition.pathServers?.length ? operationDefinition.pathServers : null) ||
83
+ parser.definition.servers ||
84
+ [];
85
+ operation.servers = normalizeServers(parser.definitionUrl, mergeInMockServer(servers, options.mockServer));
86
+ }
87
+ if (options.showExtensions) {
88
+ operation.extensions = extractExtensions(operationDefinition, options.showExtensions);
89
+ }
90
+ operation.requestBody = operationDefinition.requestBody
91
+ ? getRequestBody({
92
+ parser: parser,
93
+ infoOrRef: operationDefinition.requestBody,
94
+ options,
95
+ operation,
96
+ isEvent: operation.isEvent,
97
+ })
98
+ : undefined;
99
+ const requestBodyContent = operation.requestBody?.content;
100
+ operation.payload = {
101
+ lang: 'Payload',
102
+ source: '',
103
+ requestBodyContent: requestBodyContent?.hasSample ? requestBodyContent : undefined,
104
+ };
105
+ operation.definitionSamples = operationDefinition['x-codeSamples'] || [];
106
+ operation.badges =
107
+ operationDefinition['x-badges']?.map(({ name, color, position }) => ({
108
+ name,
109
+ color: color || 'var(--color-info-base)',
110
+ position: position || 'after',
111
+ })) || [];
112
+ operation.hasSamples = requestBodyContent?.hasSample || operation.definitionSamples.length > 0;
113
+ operation.hideReplay = operationDefinition['x-hideReplay'] === true;
114
+ const operationParams = {
115
+ userClaims,
116
+ operation: {
117
+ operationId: operation.operationId,
118
+ name: operation.name,
119
+ path: operation.path,
120
+ href: operation.href,
121
+ method: operation.httpVerb,
122
+ },
123
+ servers: operation.servers,
124
+ };
125
+ const configResult = configure(operationParams) || {};
126
+ const userDefinedRequestValues = configResult.requestValues || {};
127
+ updateOperationWithRequestValues(operation, userDefinedRequestValues);
128
+ return operation;
129
+ }
130
+ function processParameters(parser, operationDefinition, operation, options, userDefinedRequestValues) {
131
+ let parameters = mergeParams(parser, operationDefinition.pathParameters, operationDefinition.parameters, {
132
+ pathPointer: JsonPointer.dirName(operation.pointer),
133
+ operationPointer: operation.pointer,
134
+ }).map(({ paramOrRef, pointer }) => {
135
+ const param = getField(parser, paramOrRef, pointer, options, {
136
+ operation,
137
+ type: 'request',
138
+ });
139
+ updateParametersWithUserValues(param, userDefinedRequestValues);
140
+ return param;
141
+ });
142
+ if (options.sortRequiredPropsFirst) {
143
+ parameters = sortByRequired(parameters);
144
+ }
145
+ return sortByDeprecated(parameters);
146
+ }
147
+ export function mergeInMockServer(servers, mockServerOptions) {
148
+ if (!mockServerOptions) {
149
+ return servers;
150
+ }
151
+ const mockServer = {
152
+ url: mockServerOptions.url,
153
+ description: mockServerOptions.description,
154
+ };
155
+ switch (mockServerOptions.position) {
156
+ case 'first':
157
+ return [mockServer, ...servers];
158
+ case 'last':
159
+ return [...servers, mockServer];
160
+ case 'replace':
161
+ return [mockServer];
162
+ default:
163
+ return servers;
164
+ }
165
+ }
166
+ //# sourceMappingURL=operation.js.map
@@ -1 +1,25 @@
1
- import{getContentWithLegacyExamples as f,getValueFromMdParsedExtension as m,JsonPointer as p}from"../utils/index.js";import{getMediaContent as q}from"./mediaContent.js";function y({parser:t,infoOrRef:n,options:s,isEvent:d,operation:o}){const{resolved:e}=t.deref(n),u=m(e,"description")||"",c=e.required;let i;const a=!d,r=f(e);return r!==void 0&&(i=q({parser:t,info:r,isRequestType:a,options:s,data:{operation:o,type:"request",absolutePointer:n.$ref||p.join(o.pointer,["requestBody"])}})),{description:u,required:c,content:i}}export{y as getRequestBody};
1
+ import { getContentWithLegacyExamples, getValueFromMdParsedExtension, JsonPointer, } from '../utils/index.js';
2
+ import { getMediaContent } from './mediaContent.js';
3
+ export function getRequestBody({ parser, infoOrRef, options, isEvent, operation, }) {
4
+ const { resolved: info } = parser.deref(infoOrRef);
5
+ const description = getValueFromMdParsedExtension(info, 'description') || '';
6
+ const required = info.required;
7
+ let content;
8
+ const isRequestType = !isEvent;
9
+ const mediaContent = getContentWithLegacyExamples(info);
10
+ if (mediaContent !== undefined) {
11
+ content = getMediaContent({
12
+ parser,
13
+ info: mediaContent,
14
+ isRequestType,
15
+ options,
16
+ data: {
17
+ operation,
18
+ type: 'request',
19
+ absolutePointer: infoOrRef['$ref'] || JsonPointer.join(operation.pointer, ['requestBody']),
20
+ },
21
+ });
22
+ }
23
+ return { description, required, content };
24
+ }
25
+ //# sourceMappingURL=request.js.map
@@ -1 +1,46 @@
1
- import{getStatusCodeType as h,getContentWithLegacyExamples as x,JsonPointer as c,getValueFromMdParsedExtension as d}from"../utils/index.js";import{getField as C}from"./field.js";import{getMediaContent as j}from"./mediaContent.js";function F({parser:n,code:s,defaultAsError:f,infoOrRef:m,options:p,isEvent:y,operation:o}){const g=!!y,{resolved:t}=n.deref(m),e={code:s};t["x-summary"]!==void 0?(e.summary=d(t,"x-summary"),e.description=d(t,"description")||""):(e.summary=d(t,"description")||"",e.description=""),e.type=h(s,f);const r=t.headers,a=m.$ref||c.join(o?.pointer||"",["responses",s]);r!==void 0&&(e.headers=Object.keys(r).map(i=>{const l=r[i];return C(n,{...l,name:i},c.join(a,["headers",i]),p,{operation:o,type:"response",response:e})}));const u=x(t);return u!==void 0&&(e.content=j({parser:n,info:u,isRequestType:g,options:p,data:{operation:o,type:"response",response:e,absolutePointer:a}})),e}export{F as getResponse};
1
+ import { getStatusCodeType, getContentWithLegacyExamples, JsonPointer, getValueFromMdParsedExtension, } from '../utils/index.js';
2
+ import { getField } from './field.js';
3
+ import { getMediaContent } from './mediaContent.js';
4
+ export function getResponse({ parser, code, defaultAsError, infoOrRef, options, isEvent, operation, }) {
5
+ const isRequestType = !!isEvent;
6
+ const { resolved: info } = parser.deref(infoOrRef);
7
+ const response = { code };
8
+ if (info['x-summary'] !== undefined) {
9
+ response.summary = getValueFromMdParsedExtension(info, 'x-summary');
10
+ response.description = getValueFromMdParsedExtension(info, 'description') || '';
11
+ }
12
+ else {
13
+ response.summary = getValueFromMdParsedExtension(info, 'description') || '';
14
+ response.description = '';
15
+ }
16
+ response.type = getStatusCodeType(code, defaultAsError);
17
+ const infoHeaders = info.headers;
18
+ const absolutePointer = infoOrRef['$ref'] || JsonPointer.join(operation?.pointer || '', ['responses', code]);
19
+ if (infoHeaders !== undefined) {
20
+ response.headers = Object.keys(infoHeaders).map((name) => {
21
+ const header = infoHeaders[name];
22
+ return getField(parser, { ...header, name }, JsonPointer.join(absolutePointer, ['headers', name]), options, {
23
+ operation,
24
+ type: 'response',
25
+ response,
26
+ });
27
+ });
28
+ }
29
+ const mediaContent = getContentWithLegacyExamples(info);
30
+ if (mediaContent !== undefined) {
31
+ response.content = getMediaContent({
32
+ parser,
33
+ info: mediaContent,
34
+ isRequestType,
35
+ options,
36
+ data: {
37
+ operation,
38
+ type: 'response',
39
+ response,
40
+ absolutePointer,
41
+ },
42
+ });
43
+ }
44
+ return response;
45
+ }
46
+ //# sourceMappingURL=response.js.map