docusaurus-theme-openapi-docs 2.0.0-beta.2 → 2.0.0-beta.4

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 (361) hide show
  1. package/lib/index.d.ts +2 -0
  2. package/lib/index.js +53 -55
  3. package/lib/markdown/createDescription.d.ts +1 -0
  4. package/lib/markdown/createDescription.js +8 -11
  5. package/lib/markdown/schema.d.ts +3 -0
  6. package/lib/markdown/schema.js +138 -139
  7. package/lib/markdown/utils.d.ts +8 -0
  8. package/lib/markdown/utils.js +36 -42
  9. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +165 -0
  10. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +46 -0
  11. package/lib/theme/ApiExplorer/Accept/index.d.ts +3 -0
  12. package/lib/theme/ApiExplorer/Accept/index.js +38 -0
  13. package/lib/theme/ApiExplorer/Accept/slice.d.ts +11 -0
  14. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Accept/slice.js +7 -5
  15. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/_Container.scss +7 -0
  16. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +29 -0
  17. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +30 -0
  18. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +134 -0
  19. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/_Content.scss +91 -0
  20. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
  21. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +74 -0
  22. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
  23. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +47 -0
  24. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/_ExpandButton.scss +62 -0
  25. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +156 -0
  26. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +46 -0
  27. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +47 -0
  28. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
  29. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +44 -0
  30. package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +40 -0
  31. package/lib/theme/ApiExplorer/Authorization/auth-types.d.ts +3 -0
  32. package/lib/theme/{ApiDemoPanel → ApiExplorer}/Authorization/auth-types.js +4 -10
  33. package/lib/theme/ApiExplorer/Authorization/index.d.ts +3 -0
  34. package/lib/theme/ApiExplorer/Authorization/index.js +157 -0
  35. package/lib/theme/ApiExplorer/Authorization/slice.d.ts +40 -0
  36. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Authorization/slice.js +23 -16
  37. package/lib/theme/ApiExplorer/Body/index.d.ts +10 -0
  38. package/lib/theme/ApiExplorer/Body/index.js +360 -0
  39. package/lib/theme/ApiExplorer/Body/slice.d.ts +82 -0
  40. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Body/slice.js +21 -12
  41. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +20 -0
  42. package/lib/theme/ApiExplorer/CodeSnippets/index.js +406 -0
  43. package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +291 -0
  44. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/CodeTabs/index.js +26 -8
  45. package/lib/theme/ApiExplorer/ContentType/index.d.ts +3 -0
  46. package/lib/theme/ApiExplorer/ContentType/index.js +40 -0
  47. package/lib/theme/ApiExplorer/ContentType/slice.d.ts +11 -0
  48. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/ContentType/slice.js +7 -5
  49. package/lib/theme/ApiExplorer/Export/index.d.ts +3 -0
  50. package/lib/theme/ApiExplorer/Export/index.js +57 -0
  51. package/{src/theme/ApiDemoPanel → lib/theme/ApiExplorer}/FloatingButton/_FloatingButton.scss +4 -4
  52. package/lib/theme/ApiExplorer/FloatingButton/index.d.ts +8 -0
  53. package/lib/theme/ApiExplorer/FloatingButton/index.js +28 -0
  54. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/FormFileUpload/_FormFileUpload.scss +6 -6
  55. package/lib/theme/ApiExplorer/FormFileUpload/index.d.ts +7 -0
  56. package/lib/theme/ApiExplorer/FormFileUpload/index.js +161 -0
  57. package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +21 -0
  58. package/lib/theme/ApiExplorer/FormItem/index.d.ts +10 -0
  59. package/lib/theme/ApiExplorer/FormItem/index.js +44 -0
  60. package/lib/theme/{ApiDemoPanel → ApiExplorer}/FormMultiSelect/_FormMultiSelect.scss +9 -5
  61. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +9 -0
  62. package/lib/theme/ApiExplorer/FormMultiSelect/index.js +51 -0
  63. package/lib/theme/{ApiDemoPanel → ApiExplorer}/FormSelect/_FormSelect.scss +5 -5
  64. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +8 -0
  65. package/lib/theme/ApiExplorer/FormSelect/index.js +35 -0
  66. package/lib/theme/ApiExplorer/FormTextInput/_FormTextInput.scss +34 -0
  67. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +9 -0
  68. package/lib/theme/ApiExplorer/FormTextInput/index.js +73 -0
  69. package/{src/theme/ApiDemoPanel → lib/theme/ApiExplorer}/LiveEditor/_LiveEditor.scss +2 -2
  70. package/lib/theme/ApiExplorer/LiveEditor/index.d.ts +6 -0
  71. package/lib/theme/ApiExplorer/LiveEditor/index.js +154 -0
  72. package/lib/theme/ApiExplorer/MethodEndpoint/_MethodEndpoint.scss +22 -0
  73. package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +7 -0
  74. package/lib/theme/ApiExplorer/MethodEndpoint/index.js +82 -0
  75. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +6 -0
  76. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +194 -0
  77. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +6 -0
  78. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +63 -0
  79. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +6 -0
  80. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +89 -0
  81. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +6 -0
  82. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +63 -0
  83. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +6 -0
  84. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +38 -0
  85. package/{src/theme/ApiDemoPanel → lib/theme/ApiExplorer}/ParamOptions/_ParamOptions.scss +15 -34
  86. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +7 -0
  87. package/lib/theme/ApiExplorer/ParamOptions/index.js +210 -0
  88. package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +17 -0
  89. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/ParamOptions/slice.js +7 -5
  90. package/lib/theme/ApiExplorer/Request/_Request.scss +122 -0
  91. package/lib/theme/ApiExplorer/Request/index.d.ts +6 -0
  92. package/lib/theme/ApiExplorer/Request/index.js +363 -0
  93. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +4 -0
  94. package/{lib-next/theme/ApiDemoPanel/Execute → lib/theme/ApiExplorer/Request}/makeRequest.js +9 -8
  95. package/lib/theme/ApiExplorer/Response/_Response.scss +81 -0
  96. package/lib/theme/ApiExplorer/Response/index.d.ts +6 -0
  97. package/lib/theme/ApiExplorer/Response/index.js +184 -0
  98. package/lib/theme/ApiExplorer/Response/slice.d.ts +17 -0
  99. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Response/slice.js +21 -12
  100. package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +3 -0
  101. package/lib/theme/ApiExplorer/SecuritySchemes/index.js +380 -0
  102. package/{src/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Server/_Server.scss +11 -1
  103. package/lib/theme/ApiExplorer/Server/index.d.ts +3 -0
  104. package/lib/theme/ApiExplorer/Server/index.js +187 -0
  105. package/lib/theme/ApiExplorer/Server/slice.d.ts +13 -0
  106. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Server/slice.js +10 -5
  107. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +20 -0
  108. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/buildPostmanRequest.js +27 -40
  109. package/lib/theme/ApiExplorer/index.d.ts +7 -0
  110. package/lib/theme/ApiExplorer/index.js +36 -0
  111. package/lib/theme/ApiExplorer/persistanceMiddleware.d.ts +3 -0
  112. package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/persistanceMiddleware.js +11 -14
  113. package/lib/theme/ApiExplorer/storage-utils.d.ts +4 -0
  114. package/lib/theme/{ApiDemoPanel → ApiExplorer}/storage-utils.js +14 -13
  115. package/lib/theme/ApiItem/Layout/index.d.ts +4 -0
  116. package/lib/theme/ApiItem/Layout/index.js +78 -56
  117. package/lib/theme/ApiItem/hooks.d.ts +12 -0
  118. package/lib/theme/ApiItem/hooks.js +5 -10
  119. package/lib/theme/ApiItem/index.d.ts +4 -0
  120. package/lib/theme/ApiItem/index.js +144 -116
  121. package/lib/theme/ApiItem/store.d.ts +46 -0
  122. package/lib/theme/ApiItem/store.js +44 -34
  123. package/lib/theme/ApiLogo/index.d.ts +2 -0
  124. package/lib/theme/ApiLogo/index.js +34 -32
  125. package/lib/theme/ApiTabs/_ApiTabs.scss +29 -22
  126. package/lib/theme/ApiTabs/index.js +4 -3
  127. package/lib/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +16 -13
  128. package/lib/theme/Markdown/Details/_Details.scss +82 -3
  129. package/lib/theme/MimeTabs/_MimeTabs.scss +13 -8
  130. package/lib/theme/MimeTabs/index.js +2 -2
  131. package/lib/theme/ParamsItem/_ParamsItem.scss +24 -9
  132. package/lib/theme/ParamsItem/index.js +9 -6
  133. package/lib/theme/SchemaItem/_SchemaItem.scss +47 -11
  134. package/lib/theme/SchemaItem/index.js +23 -12
  135. package/lib/theme/SchemaTabs/_SchemaTabs.scss +23 -17
  136. package/lib/theme/SchemaTabs/index.js +50 -54
  137. package/lib/theme/styles.scss +55 -18
  138. package/lib/types.d.ts +157 -0
  139. package/lib/types.js +8 -1
  140. package/package.json +13 -21
  141. package/src/index.ts +31 -40
  142. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +165 -0
  143. package/src/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +46 -0
  144. package/src/theme/{ApiDemoPanel → ApiExplorer}/Accept/index.tsx +2 -2
  145. package/src/theme/ApiExplorer/ApiCodeBlock/Container/_Container.scss +7 -0
  146. package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.js +29 -0
  147. package/src/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +30 -0
  148. package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.js +134 -0
  149. package/src/theme/ApiExplorer/ApiCodeBlock/Content/_Content.scss +91 -0
  150. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/_CopyButton.scss +44 -0
  151. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +74 -0
  152. package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/_ExitButton.scss +16 -0
  153. package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +47 -0
  154. package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/_ExpandButton.scss +62 -0
  155. package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +156 -0
  156. package/src/theme/ApiExplorer/ApiCodeBlock/Line/_Line.scss +46 -0
  157. package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.js +47 -0
  158. package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/_WordWrapButton.scss +10 -0
  159. package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +44 -0
  160. package/src/theme/ApiExplorer/ApiCodeBlock/index.js +40 -0
  161. package/src/theme/{ApiDemoPanel → ApiExplorer}/Authorization/index.tsx +3 -3
  162. package/src/theme/{ApiDemoPanel → ApiExplorer}/Authorization/slice.ts +1 -1
  163. package/src/theme/{ApiDemoPanel → ApiExplorer}/Body/index.tsx +54 -37
  164. package/src/theme/{ApiDemoPanel/Curl → ApiExplorer/CodeSnippets}/index.tsx +90 -25
  165. package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +291 -0
  166. package/{lib/theme/ApiDemoPanel → src/theme/ApiExplorer}/CodeTabs/index.js +26 -8
  167. package/src/theme/{ApiDemoPanel → ApiExplorer}/ContentType/index.tsx +2 -2
  168. package/{lib/theme/ApiDemoPanel → src/theme/ApiExplorer}/FloatingButton/_FloatingButton.scss +4 -4
  169. package/src/theme/{ApiDemoPanel → ApiExplorer}/FloatingButton/index.tsx +1 -1
  170. package/src/theme/{ApiDemoPanel → ApiExplorer}/FormFileUpload/_FormFileUpload.scss +6 -6
  171. package/src/theme/{ApiDemoPanel → ApiExplorer}/FormFileUpload/index.tsx +8 -4
  172. package/src/theme/ApiExplorer/FormItem/_FormItem.scss +21 -0
  173. package/src/theme/{ApiDemoPanel → ApiExplorer}/FormItem/index.tsx +9 -11
  174. package/{lib-next/theme/ApiDemoPanel → src/theme/ApiExplorer}/FormMultiSelect/_FormMultiSelect.scss +9 -5
  175. package/src/theme/{ApiDemoPanel → ApiExplorer}/FormMultiSelect/index.tsx +7 -2
  176. package/src/theme/{ApiDemoPanel → ApiExplorer}/FormSelect/_FormSelect.scss +5 -5
  177. package/src/theme/{ApiDemoPanel → ApiExplorer}/FormSelect/index.tsx +1 -1
  178. package/src/theme/ApiExplorer/FormTextInput/_FormTextInput.scss +34 -0
  179. package/src/theme/ApiExplorer/FormTextInput/index.tsx +80 -0
  180. package/{lib/theme/ApiDemoPanel → src/theme/ApiExplorer}/LiveEditor/_LiveEditor.scss +2 -2
  181. package/src/theme/ApiExplorer/LiveEditor/index.tsx +112 -0
  182. package/src/theme/ApiExplorer/MethodEndpoint/_MethodEndpoint.scss +22 -0
  183. package/src/theme/{ApiDemoPanel → ApiExplorer}/MethodEndpoint/index.tsx +12 -9
  184. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +156 -0
  185. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +64 -0
  186. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +86 -0
  187. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +65 -0
  188. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +38 -0
  189. package/{lib-next/theme/ApiDemoPanel → src/theme/ApiExplorer}/ParamOptions/_ParamOptions.scss +15 -34
  190. package/src/theme/ApiExplorer/ParamOptions/index.tsx +145 -0
  191. package/src/theme/ApiExplorer/Request/_Request.scss +122 -0
  192. package/src/theme/ApiExplorer/Request/index.tsx +286 -0
  193. package/src/theme/{ApiDemoPanel/Execute → ApiExplorer/Request}/makeRequest.ts +8 -5
  194. package/src/theme/ApiExplorer/Response/_Response.scss +81 -0
  195. package/src/theme/{ApiDemoPanel → ApiExplorer}/Response/index.tsx +53 -33
  196. package/src/theme/{ApiDemoPanel → ApiExplorer}/SecuritySchemes/index.tsx +5 -3
  197. package/{lib-next/theme/ApiDemoPanel → src/theme/ApiExplorer}/Server/_Server.scss +11 -1
  198. package/src/theme/{ApiDemoPanel → ApiExplorer}/Server/index.tsx +13 -16
  199. package/src/theme/{ApiDemoPanel → ApiExplorer}/buildPostmanRequest.ts +2 -2
  200. package/src/theme/{ApiDemoPanel → ApiExplorer}/index.tsx +10 -12
  201. package/src/theme/{ApiDemoPanel → ApiExplorer}/persistanceMiddleware.ts +1 -1
  202. package/src/theme/ApiItem/index.tsx +17 -8
  203. package/src/theme/ApiItem/store.ts +7 -7
  204. package/src/theme/ApiTabs/_ApiTabs.scss +29 -22
  205. package/src/theme/ApiTabs/index.js +4 -3
  206. package/src/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +16 -13
  207. package/src/theme/Markdown/Details/_Details.scss +82 -3
  208. package/src/theme/MimeTabs/_MimeTabs.scss +13 -8
  209. package/src/theme/MimeTabs/index.js +2 -2
  210. package/src/theme/ParamsItem/_ParamsItem.scss +24 -9
  211. package/src/theme/ParamsItem/index.js +9 -6
  212. package/src/theme/SchemaItem/_SchemaItem.scss +47 -11
  213. package/src/theme/SchemaItem/index.js +23 -12
  214. package/src/theme/SchemaTabs/_SchemaTabs.scss +23 -17
  215. package/src/theme/SchemaTabs/index.js +50 -54
  216. package/src/theme/styles.scss +55 -18
  217. package/src/theme-openapi.d.ts +89 -46
  218. package/tsconfig.json +6 -3
  219. package/lib/postman-code-generators.d.ts +0 -9
  220. package/lib/react-magic-dropzone.d.ts +0 -9
  221. package/lib/theme/ApiDemoPanel/Accept/index.js +0 -32
  222. package/lib/theme/ApiDemoPanel/Accept/slice.js +0 -31
  223. package/lib/theme/ApiDemoPanel/Authorization/index.js +0 -107
  224. package/lib/theme/ApiDemoPanel/Authorization/slice.js +0 -123
  225. package/lib/theme/ApiDemoPanel/Body/index.js +0 -262
  226. package/lib/theme/ApiDemoPanel/Body/slice.js +0 -102
  227. package/lib/theme/ApiDemoPanel/CodeTabs/_CodeTabs.scss +0 -238
  228. package/lib/theme/ApiDemoPanel/ContentType/index.js +0 -32
  229. package/lib/theme/ApiDemoPanel/ContentType/slice.js +0 -31
  230. package/lib/theme/ApiDemoPanel/Curl/index.js +0 -238
  231. package/lib/theme/ApiDemoPanel/Execute/index.js +0 -155
  232. package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +0 -181
  233. package/lib/theme/ApiDemoPanel/Export/index.js +0 -47
  234. package/lib/theme/ApiDemoPanel/FloatingButton/index.js +0 -29
  235. package/lib/theme/ApiDemoPanel/FormFileUpload/_FormFileUpload.scss +0 -72
  236. package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +0 -82
  237. package/lib/theme/ApiDemoPanel/FormItem/_FormItem.scss +0 -12
  238. package/lib/theme/ApiDemoPanel/FormItem/index.js +0 -37
  239. package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +0 -44
  240. package/lib/theme/ApiDemoPanel/FormSelect/index.js +0 -33
  241. package/lib/theme/ApiDemoPanel/FormTextInput/_FormTextInput.scss +0 -15
  242. package/lib/theme/ApiDemoPanel/FormTextInput/index.js +0 -27
  243. package/lib/theme/ApiDemoPanel/LiveEditor/index.js +0 -61
  244. package/lib/theme/ApiDemoPanel/MethodEndpoint/_MethodEndpoint.scss +0 -6
  245. package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +0 -73
  246. package/lib/theme/ApiDemoPanel/ParamOptions/_ParamOptions.scss +0 -141
  247. package/lib/theme/ApiDemoPanel/ParamOptions/index.js +0 -215
  248. package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +0 -34
  249. package/lib/theme/ApiDemoPanel/Request/_Request.scss +0 -48
  250. package/lib/theme/ApiDemoPanel/Request/index.js +0 -66
  251. package/lib/theme/ApiDemoPanel/Response/_Response.scss +0 -27
  252. package/lib/theme/ApiDemoPanel/Response/index.js +0 -100
  253. package/lib/theme/ApiDemoPanel/Response/slice.js +0 -56
  254. package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +0 -257
  255. package/lib/theme/ApiDemoPanel/Server/_Server.scss +0 -16
  256. package/lib/theme/ApiDemoPanel/Server/index.js +0 -103
  257. package/lib/theme/ApiDemoPanel/Server/slice.js +0 -40
  258. package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +0 -303
  259. package/lib/theme/ApiDemoPanel/index.js +0 -35
  260. package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +0 -59
  261. package/lib/theme/ApiDemoPanel/postman-collection.d.ts +0 -10
  262. package/lib/theme/ApiDemoPanel/react-modal.d.ts +0 -8
  263. package/lib/theme-classic.d.ts +0 -13
  264. package/lib/theme-openapi.d.ts +0 -234
  265. package/lib/theme-translations.d.ts +0 -9
  266. package/lib-next/index.js +0 -68
  267. package/lib-next/markdown/createDescription.js +0 -13
  268. package/lib-next/markdown/schema.js +0 -153
  269. package/lib-next/markdown/utils.js +0 -44
  270. package/lib-next/postman-code-generators.d.ts +0 -9
  271. package/lib-next/react-magic-dropzone.d.ts +0 -9
  272. package/lib-next/theme/ApiDemoPanel/Accept/index.js +0 -30
  273. package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +0 -29
  274. package/lib-next/theme/ApiDemoPanel/Authorization/index.js +0 -142
  275. package/lib-next/theme/ApiDemoPanel/Body/index.js +0 -328
  276. package/lib-next/theme/ApiDemoPanel/CodeTabs/_CodeTabs.scss +0 -238
  277. package/lib-next/theme/ApiDemoPanel/ContentType/index.js +0 -30
  278. package/lib-next/theme/ApiDemoPanel/Curl/index.js +0 -281
  279. package/lib-next/theme/ApiDemoPanel/Execute/index.js +0 -178
  280. package/lib-next/theme/ApiDemoPanel/Export/index.js +0 -45
  281. package/lib-next/theme/ApiDemoPanel/FloatingButton/_FloatingButton.scss +0 -25
  282. package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +0 -21
  283. package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +0 -107
  284. package/lib-next/theme/ApiDemoPanel/FormItem/_FormItem.scss +0 -12
  285. package/lib-next/theme/ApiDemoPanel/FormItem/index.js +0 -35
  286. package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +0 -44
  287. package/lib-next/theme/ApiDemoPanel/FormSelect/_FormSelect.scss +0 -43
  288. package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +0 -29
  289. package/lib-next/theme/ApiDemoPanel/FormTextInput/_FormTextInput.scss +0 -15
  290. package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +0 -23
  291. package/lib-next/theme/ApiDemoPanel/LiveEditor/_LiveEditor.scss +0 -15
  292. package/lib-next/theme/ApiDemoPanel/LiveEditor/index.js +0 -58
  293. package/lib-next/theme/ApiDemoPanel/MethodEndpoint/_MethodEndpoint.scss +0 -6
  294. package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +0 -68
  295. package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +0 -299
  296. package/lib-next/theme/ApiDemoPanel/Request/_Request.scss +0 -48
  297. package/lib-next/theme/ApiDemoPanel/Request/index.js +0 -59
  298. package/lib-next/theme/ApiDemoPanel/Response/_Response.scss +0 -27
  299. package/lib-next/theme/ApiDemoPanel/Response/index.js +0 -122
  300. package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +0 -274
  301. package/lib-next/theme/ApiDemoPanel/Server/index.js +0 -131
  302. package/lib-next/theme/ApiDemoPanel/index.js +0 -25
  303. package/lib-next/theme/ApiDemoPanel/storage-utils.js +0 -33
  304. package/lib-next/theme/ApiItem/Layout/index.js +0 -68
  305. package/lib-next/theme/ApiItem/Layout/styles.module.css +0 -17
  306. package/lib-next/theme/ApiItem/hooks.js +0 -10
  307. package/lib-next/theme/ApiItem/index.js +0 -150
  308. package/lib-next/theme/ApiItem/store.js +0 -38
  309. package/lib-next/theme/ApiLogo/index.js +0 -48
  310. package/lib-next/theme/ApiTabs/_ApiTabs.scss +0 -133
  311. package/lib-next/theme/ApiTabs/index.js +0 -191
  312. package/lib-next/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +0 -94
  313. package/lib-next/theme/DiscriminatorTabs/index.js +0 -185
  314. package/lib-next/theme/Markdown/Details/_Details.scss +0 -40
  315. package/lib-next/theme/MimeTabs/_MimeTabs.scss +0 -64
  316. package/lib-next/theme/MimeTabs/index.js +0 -221
  317. package/lib-next/theme/ParamsItem/_ParamsItem.scss +0 -39
  318. package/lib-next/theme/ParamsItem/index.js +0 -133
  319. package/lib-next/theme/ResponseSamples/_ResponseSamples.scss +0 -3
  320. package/lib-next/theme/ResponseSamples/index.js +0 -22
  321. package/lib-next/theme/SchemaItem/_SchemaItem.scss +0 -53
  322. package/lib-next/theme/SchemaItem/index.js +0 -112
  323. package/lib-next/theme/SchemaTabs/_SchemaTabs.scss +0 -58
  324. package/lib-next/theme/SchemaTabs/index.js +0 -186
  325. package/lib-next/theme/styles.scss +0 -123
  326. package/lib-next/theme-classic.d.ts +0 -13
  327. package/lib-next/theme-openapi.d.ts +0 -234
  328. package/lib-next/theme-translations.d.ts +0 -9
  329. package/lib-next/types.js +0 -1
  330. package/src/theme/ApiDemoPanel/Body/json2xml.js +0 -43
  331. package/src/theme/ApiDemoPanel/CodeTabs/_CodeTabs.scss +0 -238
  332. package/src/theme/ApiDemoPanel/CodeTabs/index.js +0 -156
  333. package/src/theme/ApiDemoPanel/Curl/languages.json +0 -1386
  334. package/src/theme/ApiDemoPanel/Execute/index.tsx +0 -200
  335. package/src/theme/ApiDemoPanel/FormItem/_FormItem.scss +0 -12
  336. package/src/theme/ApiDemoPanel/FormMultiSelect/_FormMultiSelect.scss +0 -26
  337. package/src/theme/ApiDemoPanel/FormTextInput/_FormTextInput.scss +0 -15
  338. package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +0 -32
  339. package/src/theme/ApiDemoPanel/LiveEditor/index.tsx +0 -73
  340. package/src/theme/ApiDemoPanel/MethodEndpoint/_MethodEndpoint.scss +0 -6
  341. package/src/theme/ApiDemoPanel/ParamOptions/index.tsx +0 -333
  342. package/src/theme/ApiDemoPanel/Request/_Request.scss +0 -48
  343. package/src/theme/ApiDemoPanel/Request/index.tsx +0 -69
  344. package/src/theme/ApiDemoPanel/Response/_Response.scss +0 -27
  345. package/src/theme/ApiDemoPanel/postman-collection.d.ts +0 -10
  346. package/src/theme/ApiDemoPanel/react-modal.d.ts +0 -8
  347. /package/{lib-next/theme/ApiDemoPanel → lib/theme/ApiExplorer}/Body/json2xml.js +0 -0
  348. /package/{lib-next/theme/ApiDemoPanel/Curl → lib/theme/ApiExplorer/CodeSnippets}/languages.json +0 -0
  349. /package/src/theme/{ApiDemoPanel → ApiExplorer}/Accept/slice.ts +0 -0
  350. /package/src/theme/{ApiDemoPanel → ApiExplorer}/Authorization/auth-types.ts +0 -0
  351. /package/{lib/theme/ApiDemoPanel → src/theme/ApiExplorer}/Body/json2xml.js +0 -0
  352. /package/src/theme/{ApiDemoPanel → ApiExplorer}/Body/slice.ts +0 -0
  353. /package/{lib/theme/ApiDemoPanel/Curl → src/theme/ApiExplorer/CodeSnippets}/languages.json +0 -0
  354. /package/src/theme/{ApiDemoPanel → ApiExplorer}/ContentType/slice.ts +0 -0
  355. /package/src/theme/{ApiDemoPanel → ApiExplorer}/Export/index.tsx +0 -0
  356. /package/src/theme/{ApiDemoPanel → ApiExplorer}/ParamOptions/slice.ts +0 -0
  357. /package/src/theme/{ApiDemoPanel → ApiExplorer}/Response/slice.ts +0 -0
  358. /package/src/theme/{ApiDemoPanel → ApiExplorer}/Server/slice.ts +0 -0
  359. /package/{lib-next/theme/ApiDemoPanel → src/theme/ApiExplorer}/postman-collection.d.ts +0 -0
  360. /package/{lib-next/theme/ApiDemoPanel → src/theme/ApiExplorer}/react-modal.d.ts +0 -0
  361. /package/src/theme/{ApiDemoPanel → ApiExplorer}/storage-utils.ts +0 -0
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const react_1 = __importDefault(require("react"));
15
+ const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
16
+ const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
17
+ const FormTextInput_1 = __importDefault(
18
+ require("@theme/ApiExplorer/FormTextInput")
19
+ );
20
+ const hooks_1 = require("@theme/ApiItem/hooks");
21
+ const slice_1 = require("./slice");
22
+ function Authorization() {
23
+ const data = (0, hooks_1.useTypedSelector)((state) => state.auth.data);
24
+ const options = (0, hooks_1.useTypedSelector)((state) => state.auth.options);
25
+ const selected = (0, hooks_1.useTypedSelector)(
26
+ (state) => state.auth.selected
27
+ );
28
+ const dispatch = (0, hooks_1.useTypedDispatch)();
29
+ if (selected === undefined) {
30
+ return null;
31
+ }
32
+ const selectedAuth = options[selected];
33
+ const optionKeys = Object.keys(options);
34
+ return react_1.default.createElement(
35
+ "div",
36
+ null,
37
+ optionKeys.length > 1 &&
38
+ react_1.default.createElement(
39
+ FormItem_1.default,
40
+ { label: "Security Scheme" },
41
+ react_1.default.createElement(FormSelect_1.default, {
42
+ options: optionKeys,
43
+ value: selected,
44
+ onChange: (e) => {
45
+ dispatch((0, slice_1.setSelectedAuth)(e.target.value));
46
+ },
47
+ })
48
+ ),
49
+ selectedAuth.map((a) => {
50
+ if (a.type === "http" && a.scheme === "bearer") {
51
+ return react_1.default.createElement(
52
+ FormItem_1.default,
53
+ { label: "Bearer Token", key: a.key + "-bearer" },
54
+ react_1.default.createElement(FormTextInput_1.default, {
55
+ placeholder: "Bearer Token",
56
+ value: data[a.key].token ?? "",
57
+ onChange: (e) => {
58
+ const value = e.target.value;
59
+ dispatch(
60
+ (0, slice_1.setAuthData)({
61
+ scheme: a.key,
62
+ key: "token",
63
+ value: value ? value : undefined,
64
+ })
65
+ );
66
+ },
67
+ })
68
+ );
69
+ }
70
+ if (a.type === "oauth2") {
71
+ return react_1.default.createElement(
72
+ FormItem_1.default,
73
+ { label: "Bearer Token", key: a.key + "-oauth2" },
74
+ react_1.default.createElement(FormTextInput_1.default, {
75
+ placeholder: "Bearer Token",
76
+ value: data[a.key].token ?? "",
77
+ onChange: (e) => {
78
+ const value = e.target.value;
79
+ dispatch(
80
+ (0, slice_1.setAuthData)({
81
+ scheme: a.key,
82
+ key: "token",
83
+ value: value ? value : undefined,
84
+ })
85
+ );
86
+ },
87
+ })
88
+ );
89
+ }
90
+ if (a.type === "http" && a.scheme === "basic") {
91
+ return react_1.default.createElement(
92
+ react_1.default.Fragment,
93
+ { key: a.key + "-basic" },
94
+ react_1.default.createElement(
95
+ FormItem_1.default,
96
+ { label: "Username" },
97
+ react_1.default.createElement(FormTextInput_1.default, {
98
+ placeholder: "Username",
99
+ value: data[a.key].username ?? "",
100
+ onChange: (e) => {
101
+ const value = e.target.value;
102
+ dispatch(
103
+ (0, slice_1.setAuthData)({
104
+ scheme: a.key,
105
+ key: "username",
106
+ value: value ? value : undefined,
107
+ })
108
+ );
109
+ },
110
+ })
111
+ ),
112
+ react_1.default.createElement(
113
+ FormItem_1.default,
114
+ { label: "Password" },
115
+ react_1.default.createElement(FormTextInput_1.default, {
116
+ placeholder: "Password",
117
+ password: true,
118
+ value: data[a.key].password ?? "",
119
+ onChange: (e) => {
120
+ const value = e.target.value;
121
+ dispatch(
122
+ (0, slice_1.setAuthData)({
123
+ scheme: a.key,
124
+ key: "password",
125
+ value: value ? value : undefined,
126
+ })
127
+ );
128
+ },
129
+ })
130
+ )
131
+ );
132
+ }
133
+ if (a.type === "apiKey") {
134
+ return react_1.default.createElement(
135
+ FormItem_1.default,
136
+ { label: `${a.key}`, key: a.key + "-apikey" },
137
+ react_1.default.createElement(FormTextInput_1.default, {
138
+ placeholder: `${a.key}`,
139
+ value: data[a.key].apiKey ?? "",
140
+ onChange: (e) => {
141
+ const value = e.target.value;
142
+ dispatch(
143
+ (0, slice_1.setAuthData)({
144
+ scheme: a.key,
145
+ key: "apiKey",
146
+ value: value ? value : undefined,
147
+ })
148
+ );
149
+ },
150
+ })
151
+ );
152
+ }
153
+ return null;
154
+ })
155
+ );
156
+ }
157
+ exports.default = Authorization;
@@ -0,0 +1,40 @@
1
+ import { PayloadAction } from "@reduxjs/toolkit";
2
+ import { SecurityRequirementObject, SecuritySchemeObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
3
+ import { ThemeConfig } from "docusaurus-theme-openapi-docs/src/types";
4
+ export declare function createAuth({ security, securitySchemes, options, }: {
5
+ security?: SecurityRequirementObject[];
6
+ securitySchemes?: {
7
+ [key: string]: SecuritySchemeObject;
8
+ };
9
+ options?: ThemeConfig["api"];
10
+ }): AuthState;
11
+ export declare type Scheme = {
12
+ key: string;
13
+ scopes: string[];
14
+ } & SecuritySchemeObject;
15
+ export interface AuthState {
16
+ data: {
17
+ [scheme: string]: {
18
+ [key: string]: string | undefined;
19
+ };
20
+ };
21
+ options: {
22
+ [key: string]: Scheme[];
23
+ };
24
+ selected?: string;
25
+ }
26
+ export declare const slice: import("@reduxjs/toolkit").Slice<AuthState, {
27
+ setAuthData: (state: import("immer/dist/internal").WritableDraft<AuthState>, action: PayloadAction<{
28
+ scheme: string;
29
+ key: string;
30
+ value?: string;
31
+ }>) => void;
32
+ setSelectedAuth: (state: import("immer/dist/internal").WritableDraft<AuthState>, action: PayloadAction<string>) => void;
33
+ }, "auth">;
34
+ export declare const setAuthData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
35
+ scheme: string;
36
+ key: string;
37
+ value?: string | undefined;
38
+ }, "auth/setAuthData">, setSelectedAuth: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "auth/setSelectedAuth">;
39
+ declare const _default: import("redux").Reducer<AuthState, import("redux").AnyAction>;
40
+ export default _default;
@@ -1,26 +1,30 @@
1
+ "use strict";
1
2
  /* ============================================================================
2
3
  * Copyright (c) Palo Alto Networks
3
4
  *
4
5
  * This source code is licensed under the MIT license found in the
5
6
  * LICENSE file in the root directory of this source tree.
6
7
  * ========================================================================== */
7
-
8
- import { createSlice } from "@reduxjs/toolkit";
9
- import { createStorage, hashArray } from "@theme/ApiDemoPanel/storage-utils";
10
- import { getAuthDataKeys } from "./auth-types";
11
-
8
+ var _a;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.setSelectedAuth =
11
+ exports.setAuthData =
12
+ exports.slice =
13
+ exports.createAuth =
14
+ void 0;
15
+ const toolkit_1 = require("@reduxjs/toolkit");
16
+ const storage_utils_1 = require("@theme/ApiExplorer/storage-utils");
17
+ const auth_types_1 = require("./auth-types");
12
18
  // The global definitions
13
19
  // "securitySchemes": {
14
20
  // "BearerAuth": { "type": "http", "scheme": "BeAreR" },
15
21
  // "BasicAuth": { "type": "http", "scheme": "basic" }
16
22
  // },
17
-
18
23
  // The operation level requirements
19
24
  // "security": [
20
25
  // { "BearerAuth": [] },
21
26
  // { "BearerAuth": [], "BasicAuth": [] }
22
27
  // ],
23
-
24
28
  // SLICE_STATE
25
29
  // data:
26
30
  // BearerAuth:
@@ -34,14 +38,12 @@ import { getAuthDataKeys } from "./auth-types";
34
38
  // "BearerAuth and BasicAuth": [{ key: "BearerAuth", scopes: [], ...rest }, { key: "BasicAuth", scopes: [], ...rest }]
35
39
  //
36
40
  // selected: "BearerAuth and BasicAuth"
37
-
38
41
  // LOCAL_STORAGE
39
42
  // hash(SLICE_STATE.options) -> "BearerAuth and BasicAuth"
40
43
  // BearerAuth -> { token: xxx }
41
44
  // BasicAuth -> { username: xxx, password: xxx }
42
-
43
- export function createAuth({ security, securitySchemes, options: opts }) {
44
- const storage = createStorage("sessionStorage");
45
+ function createAuth({ security, securitySchemes, options: opts }) {
46
+ const storage = (0, storage_utils_1.createStorage)("sessionStorage");
45
47
  let data = {};
46
48
  let options = {};
47
49
  for (const option of security ?? []) {
@@ -52,7 +54,7 @@ export function createAuth({ security, securitySchemes, options: opts }) {
52
54
  if (options[id] === undefined) {
53
55
  options[id] = [];
54
56
  }
55
- const dataKeys = getAuthDataKeys(scheme);
57
+ const dataKeys = (0, auth_types_1.getAuthDataKeys)(scheme);
56
58
  for (const key of dataKeys) {
57
59
  if (data[schemeID] === undefined) {
58
60
  data[schemeID] = {};
@@ -73,7 +75,9 @@ export function createAuth({ security, securitySchemes, options: opts }) {
73
75
  }
74
76
  let persisted = undefined;
75
77
  try {
76
- persisted = storage.getItem(hashArray(Object.keys(options))) ?? undefined;
78
+ persisted =
79
+ storage.getItem((0, storage_utils_1.hashArray)(Object.keys(options))) ??
80
+ undefined;
77
81
  } catch {}
78
82
  return {
79
83
  data,
@@ -81,8 +85,9 @@ export function createAuth({ security, securitySchemes, options: opts }) {
81
85
  selected: persisted ?? Object.keys(options)[0],
82
86
  };
83
87
  }
88
+ exports.createAuth = createAuth;
84
89
  const initialState = {};
85
- export const slice = createSlice({
90
+ exports.slice = (0, toolkit_1.createSlice)({
86
91
  name: "auth",
87
92
  initialState,
88
93
  reducers: {
@@ -95,5 +100,7 @@ export const slice = createSlice({
95
100
  },
96
101
  },
97
102
  });
98
- export const { setAuthData, setSelectedAuth } = slice.actions;
99
- export default slice.reducer;
103
+ (_a = exports.slice.actions),
104
+ (exports.setAuthData = _a.setAuthData),
105
+ (exports.setSelectedAuth = _a.setSelectedAuth);
106
+ exports.default = exports.slice.reducer;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
3
+ export interface Props {
4
+ jsonRequestBodyExample: string;
5
+ requestBodyMetadata?: RequestBodyObject;
6
+ methods?: any;
7
+ required?: boolean;
8
+ }
9
+ declare function BodyWrap({ requestBodyMetadata, jsonRequestBodyExample, methods, required, }: Props): JSX.Element | null;
10
+ export default BodyWrap;
@@ -0,0 +1,360 @@
1
+ "use strict";
2
+ /* ============================================================================
3
+ * Copyright (c) Palo Alto Networks
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ * ========================================================================== */
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const react_1 = __importDefault(require("react"));
15
+ const json2xml_1 = __importDefault(require("@theme/ApiExplorer/Body/json2xml"));
16
+ const FormFileUpload_1 = __importDefault(
17
+ require("@theme/ApiExplorer/FormFileUpload")
18
+ );
19
+ const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
20
+ const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
21
+ const FormTextInput_1 = __importDefault(
22
+ require("@theme/ApiExplorer/FormTextInput")
23
+ );
24
+ const LiveEditor_1 = __importDefault(require("@theme/ApiExplorer/LiveEditor"));
25
+ const hooks_1 = require("@theme/ApiItem/hooks");
26
+ const SchemaTabs_1 = __importDefault(require("@theme/SchemaTabs"));
27
+ const TabItem_1 = __importDefault(require("@theme/TabItem"));
28
+ const xml_formatter_1 = __importDefault(require("xml-formatter"));
29
+ const slice_1 = require("./slice");
30
+ function BodyWrap({
31
+ requestBodyMetadata,
32
+ jsonRequestBodyExample,
33
+ methods,
34
+ required,
35
+ }) {
36
+ const contentType = (0, hooks_1.useTypedSelector)(
37
+ (state) => state.contentType.value
38
+ );
39
+ // NOTE: We used to check if body was required, but opted to always show the request body
40
+ // to reduce confusion, see: https://github.com/cloud-annotations/docusaurus-openapi/issues/145
41
+ // No body
42
+ if (contentType === undefined) {
43
+ return null;
44
+ }
45
+ return react_1.default.createElement(Body, {
46
+ requestBodyMetadata: requestBodyMetadata,
47
+ jsonRequestBodyExample: jsonRequestBodyExample,
48
+ required: required,
49
+ });
50
+ }
51
+ function Body({
52
+ requestBodyMetadata,
53
+ jsonRequestBodyExample,
54
+ methods,
55
+ required,
56
+ }) {
57
+ const contentType = (0, hooks_1.useTypedSelector)(
58
+ (state) => state.contentType.value
59
+ );
60
+ const dispatch = (0, hooks_1.useTypedDispatch)();
61
+ // Lot's of possible content-types:
62
+ // - application/json
63
+ // - application/xml
64
+ // - text/plain
65
+ // - text/css
66
+ // - text/html
67
+ // - text/javascript
68
+ // - application/javascript
69
+ // - multipart/form-data
70
+ // - application/x-www-form-urlencoded
71
+ // - image/svg+xml;charset=US-ASCII
72
+ // Show editor:
73
+ // - application/json
74
+ // - application/xml
75
+ // - */*
76
+ // Show form:
77
+ // - multipart/form-data
78
+ // - application/x-www-form-urlencoded
79
+ const schema = requestBodyMetadata?.content?.[contentType]?.schema;
80
+ const example = requestBodyMetadata?.content?.[contentType]?.example;
81
+ const examples = requestBodyMetadata?.content?.[contentType]?.examples;
82
+ if (schema?.format === "binary") {
83
+ return react_1.default.createElement(
84
+ FormItem_1.default,
85
+ null,
86
+ react_1.default.createElement(FormFileUpload_1.default, {
87
+ placeholder: schema.description || "Body",
88
+ onChange: (file) => {
89
+ if (file === undefined) {
90
+ dispatch((0, slice_1.clearRawBody)());
91
+ return;
92
+ }
93
+ dispatch(
94
+ (0, slice_1.setFileRawBody)({
95
+ src: `/path/to/${file.name}`,
96
+ content: file,
97
+ })
98
+ );
99
+ },
100
+ })
101
+ );
102
+ }
103
+ if (
104
+ (contentType === "multipart/form-data" ||
105
+ contentType === "application/x-www-form-urlencoded") &&
106
+ schema?.type === "object"
107
+ ) {
108
+ return react_1.default.createElement(
109
+ FormItem_1.default,
110
+ { className: "openapi-explorer__form-item-body-container" },
111
+ react_1.default.createElement(
112
+ "div",
113
+ null,
114
+ Object.entries(schema.properties ?? {}).map(([key, val]) => {
115
+ if (val.format === "binary") {
116
+ return react_1.default.createElement(
117
+ FormItem_1.default,
118
+ {
119
+ key: key,
120
+ label: key,
121
+ required:
122
+ Array.isArray(schema.required) &&
123
+ schema.required.includes(key),
124
+ },
125
+ react_1.default.createElement(FormFileUpload_1.default, {
126
+ placeholder: val.description || key,
127
+ onChange: (file) => {
128
+ if (file === undefined) {
129
+ dispatch((0, slice_1.clearFormBodyKey)(key));
130
+ return;
131
+ }
132
+ dispatch(
133
+ (0, slice_1.setFileFormBody)({
134
+ key: key,
135
+ value: {
136
+ src: `/path/to/${file.name}`,
137
+ content: file,
138
+ },
139
+ })
140
+ );
141
+ },
142
+ })
143
+ );
144
+ }
145
+ if (val.enum) {
146
+ return react_1.default.createElement(
147
+ FormItem_1.default,
148
+ {
149
+ key: key,
150
+ label: key,
151
+ required:
152
+ Array.isArray(schema.required) &&
153
+ schema.required.includes(key),
154
+ },
155
+ react_1.default.createElement(FormSelect_1.default, {
156
+ options: ["---", ...val.enum],
157
+ onChange: (e) => {
158
+ const val = e.target.value;
159
+ if (val === "---") {
160
+ dispatch((0, slice_1.clearFormBodyKey)(key));
161
+ } else {
162
+ dispatch(
163
+ (0, slice_1.setStringFormBody)({
164
+ key: key,
165
+ value: val,
166
+ })
167
+ );
168
+ }
169
+ },
170
+ })
171
+ );
172
+ }
173
+ // TODO: support all the other types.
174
+ return react_1.default.createElement(
175
+ FormItem_1.default,
176
+ {
177
+ key: key,
178
+ label: key,
179
+ required:
180
+ Array.isArray(schema.required) && schema.required.includes(key),
181
+ },
182
+ react_1.default.createElement(FormTextInput_1.default, {
183
+ paramName: key,
184
+ isRequired:
185
+ Array.isArray(schema.required) && schema.required.includes(key),
186
+ placeholder: val.description || key,
187
+ onChange: (e) => {
188
+ dispatch(
189
+ (0, slice_1.setStringFormBody)({
190
+ key: key,
191
+ value: e.target.value,
192
+ })
193
+ );
194
+ },
195
+ })
196
+ );
197
+ })
198
+ )
199
+ );
200
+ }
201
+ let language = "plaintext";
202
+ let defaultBody = ""; //"body content";
203
+ let exampleBody;
204
+ let examplesBodies = [];
205
+ if (contentType === "application/json" || contentType.endsWith("+json")) {
206
+ if (jsonRequestBodyExample) {
207
+ defaultBody = JSON.stringify(jsonRequestBodyExample, null, 2);
208
+ }
209
+ if (example) {
210
+ exampleBody = JSON.stringify(example, null, 2);
211
+ }
212
+ if (examples) {
213
+ for (const [key, example] of Object.entries(examples)) {
214
+ examplesBodies.push({
215
+ label: key,
216
+ body: JSON.stringify(example.value, null, 2),
217
+ summary: example.summary,
218
+ });
219
+ }
220
+ }
221
+ language = "json";
222
+ }
223
+ if (contentType === "application/xml" || contentType.endsWith("+xml")) {
224
+ if (jsonRequestBodyExample) {
225
+ try {
226
+ defaultBody = (0, xml_formatter_1.default)(
227
+ (0, json2xml_1.default)(jsonRequestBodyExample, ""),
228
+ {
229
+ indentation: " ",
230
+ lineSeparator: "\n",
231
+ collapseContent: true,
232
+ }
233
+ );
234
+ } catch {
235
+ defaultBody = (0, json2xml_1.default)(jsonRequestBodyExample);
236
+ }
237
+ }
238
+ if (example) {
239
+ try {
240
+ exampleBody = (0, xml_formatter_1.default)(
241
+ (0, json2xml_1.default)(example, ""),
242
+ {
243
+ indentation: " ",
244
+ lineSeparator: "\n",
245
+ collapseContent: true,
246
+ }
247
+ );
248
+ } catch {
249
+ exampleBody = (0, json2xml_1.default)(example);
250
+ }
251
+ }
252
+ if (examples) {
253
+ for (const [key, example] of Object.entries(examples)) {
254
+ let formattedXmlBody;
255
+ try {
256
+ formattedXmlBody = (0, xml_formatter_1.default)(example.value, {
257
+ indentation: " ",
258
+ lineSeparator: "\n",
259
+ collapseContent: true,
260
+ });
261
+ } catch {
262
+ formattedXmlBody = example.value;
263
+ }
264
+ examplesBodies.push({
265
+ label: key,
266
+ body: formattedXmlBody,
267
+ summary: example.summary,
268
+ });
269
+ }
270
+ }
271
+ language = "xml";
272
+ }
273
+ if (exampleBody) {
274
+ return react_1.default.createElement(
275
+ FormItem_1.default,
276
+ null,
277
+ react_1.default.createElement(
278
+ SchemaTabs_1.default,
279
+ { className: "openapi-tabs__schema", lazy: true },
280
+ react_1.default.createElement(
281
+ TabItem_1.default,
282
+ {
283
+ label: "Example (from schema)",
284
+ value: "Example (from schema)",
285
+ default: true,
286
+ },
287
+ react_1.default.createElement(
288
+ LiveEditor_1.default,
289
+ { action: dispatch, language: language, required: required },
290
+ defaultBody
291
+ )
292
+ ),
293
+ react_1.default.createElement(
294
+ TabItem_1.default,
295
+ { label: "Example", value: "example" },
296
+ exampleBody &&
297
+ react_1.default.createElement(
298
+ LiveEditor_1.default,
299
+ { action: dispatch, language: language, required: required },
300
+ exampleBody
301
+ )
302
+ )
303
+ )
304
+ );
305
+ }
306
+ if (examplesBodies && examplesBodies.length > 0) {
307
+ return react_1.default.createElement(
308
+ FormItem_1.default,
309
+ { className: "openapi-explorer__form-item-body-container" },
310
+ react_1.default.createElement(
311
+ SchemaTabs_1.default,
312
+ { className: "openapi-tabs__schema", lazy: true },
313
+ react_1.default.createElement(
314
+ TabItem_1.default,
315
+ {
316
+ label: "Example (from schema)",
317
+ value: "Example (from schema)",
318
+ default: true,
319
+ },
320
+ react_1.default.createElement(
321
+ LiveEditor_1.default,
322
+ { action: dispatch, language: language, required: required },
323
+ defaultBody
324
+ )
325
+ ),
326
+ examplesBodies.map((example) => {
327
+ return (
328
+ // @ts-ignore
329
+ react_1.default.createElement(
330
+ TabItem_1.default,
331
+ {
332
+ label: example.label,
333
+ value: example.label,
334
+ key: example.label,
335
+ },
336
+ example.summary &&
337
+ react_1.default.createElement("p", null, example.summary),
338
+ example.body &&
339
+ react_1.default.createElement(
340
+ LiveEditor_1.default,
341
+ { action: dispatch, language: language },
342
+ example.body
343
+ )
344
+ )
345
+ );
346
+ })
347
+ )
348
+ );
349
+ }
350
+ return react_1.default.createElement(
351
+ FormItem_1.default,
352
+ null,
353
+ react_1.default.createElement(
354
+ LiveEditor_1.default,
355
+ { action: dispatch, language: language, required: required },
356
+ defaultBody
357
+ )
358
+ );
359
+ }
360
+ exports.default = BodyWrap;