@upendra19/swagger-ui-custom 1.0.0

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 (468) hide show
  1. package/.agignore +1 -0
  2. package/.browserslistrc +29 -0
  3. package/.dockerignore +8 -0
  4. package/.editorconfig +10 -0
  5. package/.eslintrc.js +78 -0
  6. package/.lintstagedrc +4 -0
  7. package/.nvmrc +1 -0
  8. package/.prettierrc.yaml +5 -0
  9. package/.releaserc +26 -0
  10. package/AUTHORIZATION_CONFIG.md +350 -0
  11. package/Dockerfile +39 -0
  12. package/LICENSE +202 -0
  13. package/NOTICE +2 -0
  14. package/README.md +117 -0
  15. package/babel.config.js +140 -0
  16. package/composer.json +40 -0
  17. package/dist/favicon-16x16.png +0 -0
  18. package/dist/favicon-32x32.png +0 -0
  19. package/dist/index.css +16 -0
  20. package/dist/index.html +19 -0
  21. package/dist/log.bundle-sizes.swagger-ui.txt +114 -0
  22. package/dist/log.es-bundle-core-sizes.swagger-ui.txt +14 -0
  23. package/dist/log.es-bundle-sizes.swagger-ui.txt +114 -0
  24. package/dist/oauth2-redirect.html +6 -0
  25. package/dist/oauth2-redirect.js +1 -0
  26. package/dist/swagger-initializer.js +20 -0
  27. package/dist/swagger-ui-bundle.js +2 -0
  28. package/dist/swagger-ui-bundle.js.LICENSE.txt +106 -0
  29. package/dist/swagger-ui-bundle.js.map +1 -0
  30. package/dist/swagger-ui-es-bundle-core.js +3 -0
  31. package/dist/swagger-ui-es-bundle-core.js.LICENSE.txt +35 -0
  32. package/dist/swagger-ui-es-bundle-core.js.map +1 -0
  33. package/dist/swagger-ui-es-bundle.js +2 -0
  34. package/dist/swagger-ui-es-bundle.js.LICENSE.txt +106 -0
  35. package/dist/swagger-ui-es-bundle.js.map +1 -0
  36. package/dist/swagger-ui-standalone-preset.js +2 -0
  37. package/dist/swagger-ui-standalone-preset.js.LICENSE.txt +22 -0
  38. package/dist/swagger-ui-standalone-preset.js.map +1 -0
  39. package/dist/swagger-ui.css +3 -0
  40. package/dist/swagger-ui.css.map +1 -0
  41. package/dist/swagger-ui.js +2 -0
  42. package/dist/swagger-ui.js.map +1 -0
  43. package/docker/configurator/helpers.js +13 -0
  44. package/docker/configurator/index.js +52 -0
  45. package/docker/configurator/oauth.js +55 -0
  46. package/docker/configurator/translator.js +111 -0
  47. package/docker/configurator/variables.js +125 -0
  48. package/docker/cors.conf +14 -0
  49. package/docker/default.conf.template +43 -0
  50. package/docker/docker-entrypoint.d/40-swagger-ui.sh +52 -0
  51. package/docker/embedding.conf +5 -0
  52. package/package.json +224 -0
  53. package/snapcraft.yaml +28 -0
  54. package/src/core/assets/rolling-load.svg +1 -0
  55. package/src/core/components/app.jsx +30 -0
  56. package/src/core/components/auth/api-key-auth.jsx +93 -0
  57. package/src/core/components/auth/auth-item.jsx +60 -0
  58. package/src/core/components/auth/authorization-popup.jsx +59 -0
  59. package/src/core/components/auth/authorize-btn.jsx +30 -0
  60. package/src/core/components/auth/authorize-operation-btn.jsx +35 -0
  61. package/src/core/components/auth/auths.jsx +124 -0
  62. package/src/core/components/auth/basic-auth.jsx +110 -0
  63. package/src/core/components/auth/error.jsx +24 -0
  64. package/src/core/components/auth/oauth2.jsx +283 -0
  65. package/src/core/components/clear.jsx +25 -0
  66. package/src/core/components/contact.jsx +44 -0
  67. package/src/core/components/content-type.jsx +64 -0
  68. package/src/core/components/copy-to-clipboard-btn.jsx +29 -0
  69. package/src/core/components/curl.jsx +38 -0
  70. package/src/core/components/debug.jsx +50 -0
  71. package/src/core/components/deep-link.jsx +20 -0
  72. package/src/core/components/errors.jsx +132 -0
  73. package/src/core/components/example.jsx +43 -0
  74. package/src/core/components/examples-select-value-retainer.jsx +254 -0
  75. package/src/core/components/examples-select.jsx +139 -0
  76. package/src/core/components/execute.jsx +103 -0
  77. package/src/core/components/footer.jsx +9 -0
  78. package/src/core/components/headers.jsx +58 -0
  79. package/src/core/components/info.jsx +169 -0
  80. package/src/core/components/initialized-input.jsx +36 -0
  81. package/src/core/components/jump-to-path.jsx +9 -0
  82. package/src/core/components/layout-utils.jsx +265 -0
  83. package/src/core/components/layouts/base.jsx +156 -0
  84. package/src/core/components/layouts/xpane.jsx +73 -0
  85. package/src/core/components/license.jsx +40 -0
  86. package/src/core/components/live-response.jsx +133 -0
  87. package/src/core/components/online-validator-badge.jsx +120 -0
  88. package/src/core/components/openapi-version.jsx +15 -0
  89. package/src/core/components/operation-extension-row.jsx +17 -0
  90. package/src/core/components/operation-extensions.jsx +35 -0
  91. package/src/core/components/operation-summary-method.jsx +25 -0
  92. package/src/core/components/operation-summary-path.jsx +54 -0
  93. package/src/core/components/operation-summary.jsx +102 -0
  94. package/src/core/components/operation-tag.jsx +121 -0
  95. package/src/core/components/operation.jsx +259 -0
  96. package/src/core/components/operations.jsx +100 -0
  97. package/src/core/components/overview.jsx +119 -0
  98. package/src/core/components/param-body.jsx +156 -0
  99. package/src/core/components/parameter-extension.jsx +12 -0
  100. package/src/core/components/parameter-include-empty.jsx +59 -0
  101. package/src/core/components/parameter-row.jsx +438 -0
  102. package/src/core/components/parameters/index.js +1 -0
  103. package/src/core/components/parameters/parameters.jsx +287 -0
  104. package/src/core/components/property.jsx +17 -0
  105. package/src/core/components/providers/README.md +6 -0
  106. package/src/core/components/providers/markdown.jsx +72 -0
  107. package/src/core/components/response-body.jsx +170 -0
  108. package/src/core/components/response-extension.jsx +12 -0
  109. package/src/core/components/response.jsx +276 -0
  110. package/src/core/components/responses.jsx +170 -0
  111. package/src/core/components/svg-assets.jsx +48 -0
  112. package/src/core/components/system-wrapper.jsx +0 -0
  113. package/src/core/components/try-it-out-button.jsx +41 -0
  114. package/src/core/components/version-pragma-filter.jsx +54 -0
  115. package/src/core/components/version-stamp.jsx +12 -0
  116. package/src/core/containers/OperationContainer.jsx +267 -0
  117. package/src/core/containers/authorize-btn.jsx +31 -0
  118. package/src/core/containers/filter.jsx +44 -0
  119. package/src/core/containers/info.jsx +35 -0
  120. package/src/core/index.js +174 -0
  121. package/src/core/oauth2-authorize.js +137 -0
  122. package/src/core/plugins/auth/actions.js +286 -0
  123. package/src/core/plugins/auth/components/lock-auth-icon.jsx +27 -0
  124. package/src/core/plugins/auth/components/unlock-auth-icon.jsx +27 -0
  125. package/src/core/plugins/auth/configs-extensions/wrap-actions.js +19 -0
  126. package/src/core/plugins/auth/index.js +94 -0
  127. package/src/core/plugins/auth/reducers.js +77 -0
  128. package/src/core/plugins/auth/selectors.js +121 -0
  129. package/src/core/plugins/auth/spec-extensions/wrap-actions.js +10 -0
  130. package/src/core/plugins/auth/wrap-actions.js +66 -0
  131. package/src/core/plugins/configs/actions.js +58 -0
  132. package/src/core/plugins/configs/fn.js +12 -0
  133. package/src/core/plugins/configs/index.js +16 -0
  134. package/src/core/plugins/configs/reducers.js +20 -0
  135. package/src/core/plugins/configs/selectors.js +4 -0
  136. package/src/core/plugins/deep-linking/README.md +1 -0
  137. package/src/core/plugins/deep-linking/helpers.js +7 -0
  138. package/src/core/plugins/deep-linking/index.js +24 -0
  139. package/src/core/plugins/deep-linking/layout.js +209 -0
  140. package/src/core/plugins/deep-linking/operation-tag-wrapper.jsx +25 -0
  141. package/src/core/plugins/deep-linking/operation-wrapper.jsx +27 -0
  142. package/src/core/plugins/download-url/index.js +126 -0
  143. package/src/core/plugins/err/actions.js +60 -0
  144. package/src/core/plugins/err/error-transformers/README.md +31 -0
  145. package/src/core/plugins/err/error-transformers/hook.js +38 -0
  146. package/src/core/plugins/err/error-transformers/transformers/not-of-type.js +29 -0
  147. package/src/core/plugins/err/error-transformers/transformers/parameter-oneof.js +59 -0
  148. package/src/core/plugins/err/index.js +15 -0
  149. package/src/core/plugins/err/reducers.js +100 -0
  150. package/src/core/plugins/err/selectors.js +15 -0
  151. package/src/core/plugins/filter/index.js +9 -0
  152. package/src/core/plugins/filter/opsFilter.js +3 -0
  153. package/src/core/plugins/icons/components/arrow-down.jsx +28 -0
  154. package/src/core/plugins/icons/components/arrow-up.jsx +28 -0
  155. package/src/core/plugins/icons/components/arrow.jsx +28 -0
  156. package/src/core/plugins/icons/components/close.jsx +28 -0
  157. package/src/core/plugins/icons/components/copy.jsx +34 -0
  158. package/src/core/plugins/icons/components/lock.jsx +28 -0
  159. package/src/core/plugins/icons/components/unlock.jsx +28 -0
  160. package/src/core/plugins/icons/index.js +24 -0
  161. package/src/core/plugins/json-schema-2020-12/components/Accordion/Accordion.jsx +45 -0
  162. package/src/core/plugins/json-schema-2020-12/components/Accordion/_accordion.scss +33 -0
  163. package/src/core/plugins/json-schema-2020-12/components/ExpandDeepButton/ExpandDeepButton.jsx +31 -0
  164. package/src/core/plugins/json-schema-2020-12/components/ExpandDeepButton/_expand-deep-button.scss +10 -0
  165. package/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx +227 -0
  166. package/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss +34 -0
  167. package/src/core/plugins/json-schema-2020-12/components/JSONViewer/JSONViewer.jsx +153 -0
  168. package/src/core/plugins/json-schema-2020-12/components/JSONViewer/_json-viewer.scss +11 -0
  169. package/src/core/plugins/json-schema-2020-12/components/_all.scss +4 -0
  170. package/src/core/plugins/json-schema-2020-12/components/_mixins.scss +82 -0
  171. package/src/core/plugins/json-schema-2020-12/components/icons/ChevronRight.jsx +17 -0
  172. package/src/core/plugins/json-schema-2020-12/components/keywords/$anchor.jsx +27 -0
  173. package/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx +27 -0
  174. package/src/core/plugins/json-schema-2020-12/components/keywords/$defs.jsx +93 -0
  175. package/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx +27 -0
  176. package/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicRef.jsx +27 -0
  177. package/src/core/plugins/json-schema-2020-12/components/keywords/$id.jsx +27 -0
  178. package/src/core/plugins/json-schema-2020-12/components/keywords/$ref.jsx +27 -0
  179. package/src/core/plugins/json-schema-2020-12/components/keywords/$schema.jsx +27 -0
  180. package/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/$vocabulary.jsx +66 -0
  181. package/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/_$vocabulary.scss +17 -0
  182. package/src/core/plugins/json-schema-2020-12/components/keywords/AdditionalProperties.jsx +55 -0
  183. package/src/core/plugins/json-schema-2020-12/components/keywords/AllOf.jsx +105 -0
  184. package/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf.jsx +105 -0
  185. package/src/core/plugins/json-schema-2020-12/components/keywords/Const/Const.jsx +28 -0
  186. package/src/core/plugins/json-schema-2020-12/components/keywords/Const/_const.scss +11 -0
  187. package/src/core/plugins/json-schema-2020-12/components/keywords/Constraint/Constraint.jsx +38 -0
  188. package/src/core/plugins/json-schema-2020-12/components/keywords/Constraint/_constraint.scss +16 -0
  189. package/src/core/plugins/json-schema-2020-12/components/keywords/Contains.jsx +35 -0
  190. package/src/core/plugins/json-schema-2020-12/components/keywords/ContentSchema.jsx +39 -0
  191. package/src/core/plugins/json-schema-2020-12/components/keywords/Default/Default.jsx +28 -0
  192. package/src/core/plugins/json-schema-2020-12/components/keywords/Default/_default.scss +11 -0
  193. package/src/core/plugins/json-schema-2020-12/components/keywords/DependentRequired/DependentRequired.jsx +37 -0
  194. package/src/core/plugins/json-schema-2020-12/components/keywords/DependentRequired/_dependent-required.scss +12 -0
  195. package/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas.jsx +97 -0
  196. package/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated.jsx +22 -0
  197. package/src/core/plugins/json-schema-2020-12/components/keywords/Description/Description.jsx +24 -0
  198. package/src/core/plugins/json-schema-2020-12/components/keywords/Description/_description.scss +9 -0
  199. package/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx +35 -0
  200. package/src/core/plugins/json-schema-2020-12/components/keywords/Enum/Enum.jsx +27 -0
  201. package/src/core/plugins/json-schema-2020-12/components/keywords/Enum/_enum.scss +11 -0
  202. package/src/core/plugins/json-schema-2020-12/components/keywords/Examples/Examples.jsx +30 -0
  203. package/src/core/plugins/json-schema-2020-12/components/keywords/Examples/_examples.scss +11 -0
  204. package/src/core/plugins/json-schema-2020-12/components/keywords/ExtensionKeywords/ExtensionKeywords.jsx +103 -0
  205. package/src/core/plugins/json-schema-2020-12/components/keywords/ExtensionKeywords/_extension-keywords.scss +11 -0
  206. package/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx +35 -0
  207. package/src/core/plugins/json-schema-2020-12/components/keywords/Items.jsx +35 -0
  208. package/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx +35 -0
  209. package/src/core/plugins/json-schema-2020-12/components/keywords/OneOf.jsx +105 -0
  210. package/src/core/plugins/json-schema-2020-12/components/keywords/PatternProperties/PatternProperties.jsx +41 -0
  211. package/src/core/plugins/json-schema-2020-12/components/keywords/PatternProperties/_pattern-properties.scss +21 -0
  212. package/src/core/plugins/json-schema-2020-12/components/keywords/PrefixItems.jsx +105 -0
  213. package/src/core/plugins/json-schema-2020-12/components/keywords/Properties/Properties.jsx +61 -0
  214. package/src/core/plugins/json-schema-2020-12/components/keywords/Properties/_properties.scss +24 -0
  215. package/src/core/plugins/json-schema-2020-12/components/keywords/PropertyNames.jsx +38 -0
  216. package/src/core/plugins/json-schema-2020-12/components/keywords/ReadOnly.jsx +22 -0
  217. package/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx +35 -0
  218. package/src/core/plugins/json-schema-2020-12/components/keywords/Title/Title.jsx +24 -0
  219. package/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss +26 -0
  220. package/src/core/plugins/json-schema-2020-12/components/keywords/Type.jsx +27 -0
  221. package/src/core/plugins/json-schema-2020-12/components/keywords/UnevaluatedItems.jsx +39 -0
  222. package/src/core/plugins/json-schema-2020-12/components/keywords/UnevaluatedProperties.jsx +39 -0
  223. package/src/core/plugins/json-schema-2020-12/components/keywords/WriteOnly.jsx +22 -0
  224. package/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss +43 -0
  225. package/src/core/plugins/json-schema-2020-12/context.js +14 -0
  226. package/src/core/plugins/json-schema-2020-12/enum.js +10 -0
  227. package/src/core/plugins/json-schema-2020-12/fn.js +527 -0
  228. package/src/core/plugins/json-schema-2020-12/hoc.jsx +296 -0
  229. package/src/core/plugins/json-schema-2020-12/hooks.js +144 -0
  230. package/src/core/plugins/json-schema-2020-12/index.js +153 -0
  231. package/src/core/plugins/json-schema-2020-12/prop-types.js +10 -0
  232. package/src/core/plugins/json-schema-2020-12-samples/fn/api/encoderAPI.js +20 -0
  233. package/src/core/plugins/json-schema-2020-12-samples/fn/api/formatAPI.js +20 -0
  234. package/src/core/plugins/json-schema-2020-12-samples/fn/api/mediaTypeAPI.js +27 -0
  235. package/src/core/plugins/json-schema-2020-12-samples/fn/api/optionAPI.js +17 -0
  236. package/src/core/plugins/json-schema-2020-12-samples/fn/class/EncoderRegistry.js +33 -0
  237. package/src/core/plugins/json-schema-2020-12-samples/fn/class/FormatRegistry.js +65 -0
  238. package/src/core/plugins/json-schema-2020-12-samples/fn/class/MediaTypeRegistry.js +27 -0
  239. package/src/core/plugins/json-schema-2020-12-samples/fn/class/OptionRegistry.js +16 -0
  240. package/src/core/plugins/json-schema-2020-12-samples/fn/class/Registry.js +24 -0
  241. package/src/core/plugins/json-schema-2020-12-samples/fn/core/constants.js +6 -0
  242. package/src/core/plugins/json-schema-2020-12-samples/fn/core/example.js +57 -0
  243. package/src/core/plugins/json-schema-2020-12-samples/fn/core/merge.js +83 -0
  244. package/src/core/plugins/json-schema-2020-12-samples/fn/core/predicates.js +16 -0
  245. package/src/core/plugins/json-schema-2020-12-samples/fn/core/random.js +46 -0
  246. package/src/core/plugins/json-schema-2020-12-samples/fn/core/type.js +156 -0
  247. package/src/core/plugins/json-schema-2020-12-samples/fn/core/utils.js +23 -0
  248. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/7bit.js +6 -0
  249. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/8bit.js +6 -0
  250. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base16.js +6 -0
  251. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base32.js +34 -0
  252. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base64.js +6 -0
  253. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base64url.js +6 -0
  254. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/binary.js +6 -0
  255. package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/quoted-printable.js +38 -0
  256. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/date-time.js +6 -0
  257. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/date.js +6 -0
  258. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/double.js +6 -0
  259. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/duration.js +6 -0
  260. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/email.js +6 -0
  261. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/float.js +6 -0
  262. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/hostname.js +6 -0
  263. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/idn-email.js +6 -0
  264. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/idn-hostname.js +6 -0
  265. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/int32.js +6 -0
  266. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/int64.js +6 -0
  267. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/ipv4.js +6 -0
  268. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/ipv6.js +6 -0
  269. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/iri-reference.js +6 -0
  270. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/iri.js +6 -0
  271. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/json-pointer.js +6 -0
  272. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/application.js +17 -0
  273. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/audio.js +10 -0
  274. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/image.js +10 -0
  275. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/text.js +17 -0
  276. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/video.js +10 -0
  277. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/password.js +6 -0
  278. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/regex.js +6 -0
  279. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/relative-json-pointer.js +6 -0
  280. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/time.js +6 -0
  281. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uri-reference.js +6 -0
  282. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uri-template.js +7 -0
  283. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uri.js +6 -0
  284. package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uuid.js +6 -0
  285. package/src/core/plugins/json-schema-2020-12-samples/fn/get-json-sample-schema.js +36 -0
  286. package/src/core/plugins/json-schema-2020-12-samples/fn/get-sample-schema.js +39 -0
  287. package/src/core/plugins/json-schema-2020-12-samples/fn/get-xml-sample-schema.js +35 -0
  288. package/src/core/plugins/json-schema-2020-12-samples/fn/get-yaml-sample-schema.js +34 -0
  289. package/src/core/plugins/json-schema-2020-12-samples/fn/index.js +16 -0
  290. package/src/core/plugins/json-schema-2020-12-samples/fn/main.js +562 -0
  291. package/src/core/plugins/json-schema-2020-12-samples/fn/types/array.js +52 -0
  292. package/src/core/plugins/json-schema-2020-12-samples/fn/types/boolean.js +9 -0
  293. package/src/core/plugins/json-schema-2020-12-samples/fn/types/index.js +30 -0
  294. package/src/core/plugins/json-schema-2020-12-samples/fn/types/integer.js +43 -0
  295. package/src/core/plugins/json-schema-2020-12-samples/fn/types/null.js +9 -0
  296. package/src/core/plugins/json-schema-2020-12-samples/fn/types/number.js +65 -0
  297. package/src/core/plugins/json-schema-2020-12-samples/fn/types/object.js +9 -0
  298. package/src/core/plugins/json-schema-2020-12-samples/fn/types/string.js +80 -0
  299. package/src/core/plugins/json-schema-2020-12-samples/index.js +51 -0
  300. package/src/core/plugins/json-schema-5/components/array-model.jsx +80 -0
  301. package/src/core/plugins/json-schema-5/components/enum-model.jsx +19 -0
  302. package/src/core/plugins/json-schema-5/components/json-schema-components.jsx +441 -0
  303. package/src/core/plugins/json-schema-5/components/model-collapse.jsx +99 -0
  304. package/src/core/plugins/json-schema-5/components/model-example.jsx +160 -0
  305. package/src/core/plugins/json-schema-5/components/model-extensions.jsx +28 -0
  306. package/src/core/plugins/json-schema-5/components/model-wrapper.jsx +44 -0
  307. package/src/core/plugins/json-schema-5/components/model.jsx +136 -0
  308. package/src/core/plugins/json-schema-5/components/models.jsx +139 -0
  309. package/src/core/plugins/json-schema-5/components/object-model.jsx +340 -0
  310. package/src/core/plugins/json-schema-5/components/primitive-model.jsx +137 -0
  311. package/src/core/plugins/json-schema-5/components/schemes.jsx +53 -0
  312. package/src/core/plugins/json-schema-5/containers/schemes.jsx +30 -0
  313. package/src/core/plugins/json-schema-5/fn.js +51 -0
  314. package/src/core/plugins/json-schema-5/index.js +41 -0
  315. package/src/core/plugins/json-schema-5-samples/fn/get-json-sample-schema.js +32 -0
  316. package/src/core/plugins/json-schema-5-samples/fn/get-sample-schema.js +30 -0
  317. package/src/core/plugins/json-schema-5-samples/fn/get-xml-sample-schema.js +31 -0
  318. package/src/core/plugins/json-schema-5-samples/fn/get-yaml-sample-schema.js +34 -0
  319. package/src/core/plugins/json-schema-5-samples/fn/index.js +653 -0
  320. package/src/core/plugins/json-schema-5-samples/index.js +56 -0
  321. package/src/core/plugins/layout/actions.js +39 -0
  322. package/src/core/plugins/layout/index.js +19 -0
  323. package/src/core/plugins/layout/reducers.js +32 -0
  324. package/src/core/plugins/layout/selectors.js +24 -0
  325. package/src/core/plugins/layout/spec-extensions/wrap-selector.js +22 -0
  326. package/src/core/plugins/logs/index.js +28 -0
  327. package/src/core/plugins/oas3/actions.js +99 -0
  328. package/src/core/plugins/oas3/auth-extensions/wrap-selectors.js +92 -0
  329. package/src/core/plugins/oas3/components/auth/http-auth.jsx +157 -0
  330. package/src/core/plugins/oas3/components/callbacks.jsx +51 -0
  331. package/src/core/plugins/oas3/components/index.js +19 -0
  332. package/src/core/plugins/oas3/components/operation-link.jsx +43 -0
  333. package/src/core/plugins/oas3/components/operation-servers.jsx +102 -0
  334. package/src/core/plugins/oas3/components/request-body-editor.jsx +103 -0
  335. package/src/core/plugins/oas3/components/request-body.jsx +338 -0
  336. package/src/core/plugins/oas3/components/servers-container.jsx +33 -0
  337. package/src/core/plugins/oas3/components/servers.jsx +153 -0
  338. package/src/core/plugins/oas3/fn.js +35 -0
  339. package/src/core/plugins/oas3/helpers.jsx +48 -0
  340. package/src/core/plugins/oas3/index.js +39 -0
  341. package/src/core/plugins/oas3/reducers.js +111 -0
  342. package/src/core/plugins/oas3/selectors.js +308 -0
  343. package/src/core/plugins/oas3/spec-extensions/selectors.js +100 -0
  344. package/src/core/plugins/oas3/spec-extensions/wrap-selectors.js +71 -0
  345. package/src/core/plugins/oas3/wrap-components/auth/auth-item.jsx +25 -0
  346. package/src/core/plugins/oas3/wrap-components/index.js +15 -0
  347. package/src/core/plugins/oas3/wrap-components/json-schema-string.jsx +27 -0
  348. package/src/core/plugins/oas3/wrap-components/markdown.jsx +45 -0
  349. package/src/core/plugins/oas3/wrap-components/model.jsx +40 -0
  350. package/src/core/plugins/oas3/wrap-components/online-validator-badge.js +5 -0
  351. package/src/core/plugins/oas3/wrap-components/openapi-version.jsx +7 -0
  352. package/src/core/plugins/oas31/after-load.js +72 -0
  353. package/src/core/plugins/oas31/auth-extensions/wrap-selectors.js +28 -0
  354. package/src/core/plugins/oas31/components/_all.scss +2 -0
  355. package/src/core/plugins/oas31/components/auth/auths.jsx +186 -0
  356. package/src/core/plugins/oas31/components/auth/mutual-tls-auth.jsx +32 -0
  357. package/src/core/plugins/oas31/components/contact.jsx +43 -0
  358. package/src/core/plugins/oas31/components/info.jsx +99 -0
  359. package/src/core/plugins/oas31/components/json-schema-dialect.jsx +60 -0
  360. package/src/core/plugins/oas31/components/license.jsx +38 -0
  361. package/src/core/plugins/oas31/components/model/_model.scss +23 -0
  362. package/src/core/plugins/oas31/components/model/model.jsx +54 -0
  363. package/src/core/plugins/oas31/components/models/_models.scss +11 -0
  364. package/src/core/plugins/oas31/components/models/models.jsx +141 -0
  365. package/src/core/plugins/oas31/components/version-pragma-filter.jsx +73 -0
  366. package/src/core/plugins/oas31/components/webhooks.jsx +49 -0
  367. package/src/core/plugins/oas31/fn.js +124 -0
  368. package/src/core/plugins/oas31/index.js +166 -0
  369. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Description.jsx +27 -0
  370. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Discriminator/Discriminator.jsx +118 -0
  371. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Discriminator/DiscriminatorMapping.jsx +32 -0
  372. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Example.jsx +28 -0
  373. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/ExternalDocs.jsx +143 -0
  374. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/OpenAPIExtensions.jsx +33 -0
  375. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Properties.jsx +60 -0
  376. package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Xml.jsx +162 -0
  377. package/src/core/plugins/oas31/json-schema-2020-12-extensions/fn.js +57 -0
  378. package/src/core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Description.jsx +9 -0
  379. package/src/core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Examples.jsx +31 -0
  380. package/src/core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Properties.jsx +9 -0
  381. package/src/core/plugins/oas31/oas3-extensions/fn.js +46 -0
  382. package/src/core/plugins/oas31/selectors.js +26 -0
  383. package/src/core/plugins/oas31/spec-extensions/selectors.js +198 -0
  384. package/src/core/plugins/oas31/spec-extensions/wrap-selectors.js +18 -0
  385. package/src/core/plugins/oas31/wrap-components/auth/auth-item.jsx +22 -0
  386. package/src/core/plugins/oas31/wrap-components/auths.jsx +17 -0
  387. package/src/core/plugins/oas31/wrap-components/contact.jsx +15 -0
  388. package/src/core/plugins/oas31/wrap-components/info.jsx +15 -0
  389. package/src/core/plugins/oas31/wrap-components/license.jsx +15 -0
  390. package/src/core/plugins/oas31/wrap-components/model.jsx +44 -0
  391. package/src/core/plugins/oas31/wrap-components/models.jsx +47 -0
  392. package/src/core/plugins/oas31/wrap-components/version-pragma-filter.jsx +16 -0
  393. package/src/core/plugins/on-complete/index.js +28 -0
  394. package/src/core/plugins/request-snippets/fn.js +169 -0
  395. package/src/core/plugins/request-snippets/index.js +21 -0
  396. package/src/core/plugins/request-snippets/request-snippets.jsx +163 -0
  397. package/src/core/plugins/request-snippets/selectors.js +45 -0
  398. package/src/core/plugins/safe-render/components/error-boundary.jsx +52 -0
  399. package/src/core/plugins/safe-render/components/fallback.jsx +13 -0
  400. package/src/core/plugins/safe-render/fn.jsx +32 -0
  401. package/src/core/plugins/safe-render/index.js +42 -0
  402. package/src/core/plugins/spec/actions.js +531 -0
  403. package/src/core/plugins/spec/index.js +20 -0
  404. package/src/core/plugins/spec/reducers.js +176 -0
  405. package/src/core/plugins/spec/selectors.js +575 -0
  406. package/src/core/plugins/spec/wrap-actions.js +39 -0
  407. package/src/core/plugins/swagger-client/configs-wrap-actions.js +6 -0
  408. package/src/core/plugins/swagger-client/index.js +54 -0
  409. package/src/core/plugins/syntax-highlighting/after-load.js +25 -0
  410. package/src/core/plugins/syntax-highlighting/components/HighlightCode.jsx +107 -0
  411. package/src/core/plugins/syntax-highlighting/components/PlainTextViewer.jsx +17 -0
  412. package/src/core/plugins/syntax-highlighting/components/SyntaxHighlighter.jsx +42 -0
  413. package/src/core/plugins/syntax-highlighting/index.js +34 -0
  414. package/src/core/plugins/syntax-highlighting/root-injects.js +22 -0
  415. package/src/core/plugins/syntax-highlighting/wrap-components/SyntaxHighlighter.jsx +31 -0
  416. package/src/core/plugins/util/index.js +11 -0
  417. package/src/core/plugins/versions/after-load.js +19 -0
  418. package/src/core/plugins/versions/index.js +10 -0
  419. package/src/core/plugins/view/fn.js +1 -0
  420. package/src/core/plugins/view/index.js +34 -0
  421. package/src/core/plugins/view/root-injects.jsx +118 -0
  422. package/src/core/plugins/view-legacy/index.js +25 -0
  423. package/src/core/plugins/view-legacy/root-injects.jsx +12 -0
  424. package/src/core/presets/apis/index.js +18 -0
  425. package/src/core/presets/base/index.js +55 -0
  426. package/src/core/presets/base/plugins/core-components/index.js +130 -0
  427. package/src/core/presets/base/plugins/form-components/index.js +10 -0
  428. package/src/core/system.js +511 -0
  429. package/src/core/utils/create-html-ready-id.js +10 -0
  430. package/src/core/utils/get-parameter-schema.js +94 -0
  431. package/src/core/utils/index.js +847 -0
  432. package/src/core/utils/jsonParse.js +15 -0
  433. package/src/core/utils/memoizeN.js +48 -0
  434. package/src/core/utils/url.js +79 -0
  435. package/src/core/window.js +30 -0
  436. package/src/index.js +3 -0
  437. package/src/standalone/plugins/stadalone-layout/components/StandaloneLayout.jsx +40 -0
  438. package/src/standalone/plugins/stadalone-layout/index.js +12 -0
  439. package/src/standalone/plugins/top-bar/assets/lightbulb-off.svg +1 -0
  440. package/src/standalone/plugins/top-bar/assets/lightbulb.svg +1 -0
  441. package/src/standalone/plugins/top-bar/assets/logo_small.svg +60 -0
  442. package/src/standalone/plugins/top-bar/components/DarkModeToggle.jsx +47 -0
  443. package/src/standalone/plugins/top-bar/components/Logo.jsx +9 -0
  444. package/src/standalone/plugins/top-bar/components/TopBar.jsx +183 -0
  445. package/src/standalone/plugins/top-bar/index.js +12 -0
  446. package/src/standalone/presets/standalone/index.js +19 -0
  447. package/src/style/_authorize.scss +96 -0
  448. package/src/style/_buttons.scss +199 -0
  449. package/src/style/_dark-mode.scss +664 -0
  450. package/src/style/_errors.scss +72 -0
  451. package/src/style/_form.scss +214 -0
  452. package/src/style/_information.scss +99 -0
  453. package/src/style/_layout.scss +941 -0
  454. package/src/style/_markdown.scss +34 -0
  455. package/src/style/_mixins.scss +159 -0
  456. package/src/style/_modal.scss +95 -0
  457. package/src/style/_models.scss +330 -0
  458. package/src/style/_servers.scss +66 -0
  459. package/src/style/_split-pane-mode.scss +3 -0
  460. package/src/style/_table.scss +191 -0
  461. package/src/style/_topbar.scss +126 -0
  462. package/src/style/_type.scss +21 -0
  463. package/src/style/_variables.scss +230 -0
  464. package/src/style/main.scss +28 -0
  465. package/stylelint.config.js +11 -0
  466. package/swagger-ui-dist-package/absolute-path.js +14 -0
  467. package/swagger-ui-dist-package/index.js +17 -0
  468. package/swagger-ui-dist-package/package.json +20 -0
@@ -0,0 +1,562 @@
1
+ /**
2
+ * @prettier
3
+ */
4
+ import XML from "xml"
5
+ import isEmpty from "lodash/isEmpty"
6
+ import isPlainObject from "lodash/isPlainObject"
7
+
8
+ import { objectify, normalizeArray } from "core/utils"
9
+ import memoizeN from "core/utils/memoizeN"
10
+ import typeMap from "./types/index"
11
+ import { getType } from "./core/type"
12
+ import { typeCast } from "./core/utils"
13
+ import { hasExample, extractExample } from "./core/example"
14
+ import { pick as randomPick } from "./core/random"
15
+ import merge from "./core/merge"
16
+ import { isBooleanJSONSchema, isJSONSchemaObject } from "./core/predicates"
17
+
18
+ export const sampleFromSchemaGeneric = (
19
+ schema,
20
+ config = {},
21
+ exampleOverride = undefined,
22
+ respectXML = false
23
+ ) => {
24
+ // there is nothing to generate schema from
25
+ if (schema == null && exampleOverride === undefined) return undefined
26
+
27
+ if (typeof schema?.toJS === "function") schema = schema.toJS()
28
+ schema = typeCast(schema)
29
+
30
+ let usePlainValue = exampleOverride !== undefined || hasExample(schema)
31
+ // first check if there is the need of combining this schema with others required by allOf
32
+ const hasOneOf =
33
+ !usePlainValue && Array.isArray(schema.oneOf) && schema.oneOf.length > 0
34
+ const hasAnyOf =
35
+ !usePlainValue && Array.isArray(schema.anyOf) && schema.anyOf.length > 0
36
+ if (!usePlainValue && (hasOneOf || hasAnyOf)) {
37
+ const schemaToAdd = typeCast(
38
+ hasOneOf ? randomPick(schema.oneOf) : randomPick(schema.anyOf)
39
+ )
40
+ schema = merge(schema, schemaToAdd, config)
41
+ if (!schema.xml && schemaToAdd.xml) {
42
+ schema.xml = schemaToAdd.xml
43
+ }
44
+ if (hasExample(schema) && hasExample(schemaToAdd)) {
45
+ usePlainValue = true
46
+ }
47
+ }
48
+ const _attr = {}
49
+ let { xml, properties, additionalProperties, items, contains } = schema || {}
50
+ let type = getType(schema)
51
+ let { includeReadOnly, includeWriteOnly } = config
52
+ xml = xml || {}
53
+ let { name, prefix, namespace } = xml
54
+ let displayName
55
+ let res = {}
56
+
57
+ if (!Object.hasOwn(schema, "type")) {
58
+ schema.type = type
59
+ }
60
+
61
+ // set xml naming and attributes
62
+ if (respectXML) {
63
+ name = name || "notagname"
64
+ // add prefix to name if exists
65
+ displayName = (prefix ? `${prefix}:` : "") + name
66
+ if (namespace) {
67
+ //add prefix to namespace if exists
68
+ let namespacePrefix = prefix ? `xmlns:${prefix}` : "xmlns"
69
+ _attr[namespacePrefix] = namespace
70
+ }
71
+ }
72
+
73
+ // init xml default response sample obj
74
+ if (respectXML) {
75
+ res[displayName] = []
76
+ }
77
+
78
+ // add to result helper init for xml or json
79
+ const props = objectify(properties)
80
+ let addPropertyToResult
81
+ let propertyAddedCounter = 0
82
+
83
+ const hasExceededMaxProperties = () =>
84
+ Number.isInteger(schema.maxProperties) &&
85
+ schema.maxProperties > 0 &&
86
+ propertyAddedCounter >= schema.maxProperties
87
+
88
+ const requiredPropertiesToAdd = () => {
89
+ if (!Array.isArray(schema.required) || schema.required.length === 0) {
90
+ return 0
91
+ }
92
+ let addedCount = 0
93
+ if (respectXML) {
94
+ schema.required.forEach(
95
+ (key) => (addedCount += res[key] === undefined ? 0 : 1)
96
+ )
97
+ } else {
98
+ schema.required.forEach((key) => {
99
+ addedCount +=
100
+ res[displayName]?.find((x) => x[key] !== undefined) === undefined
101
+ ? 0
102
+ : 1
103
+ })
104
+ }
105
+ return schema.required.length - addedCount
106
+ }
107
+
108
+ const isOptionalProperty = (propName) => {
109
+ if (!Array.isArray(schema.required)) return true
110
+ if (schema.required.length === 0) return true
111
+
112
+ return !schema.required.includes(propName)
113
+ }
114
+
115
+ const canAddProperty = (propName) => {
116
+ if (!(Number.isInteger(schema.maxProperties) && schema.maxProperties > 0)) {
117
+ return true
118
+ }
119
+ if (hasExceededMaxProperties()) {
120
+ return false
121
+ }
122
+ if (!isOptionalProperty(propName)) {
123
+ return true
124
+ }
125
+ return (
126
+ schema.maxProperties - propertyAddedCounter - requiredPropertiesToAdd() >
127
+ 0
128
+ )
129
+ }
130
+
131
+ if (respectXML) {
132
+ addPropertyToResult = (propName, overrideE = undefined) => {
133
+ if (schema && props[propName]) {
134
+ // case it is a xml attribute
135
+ props[propName].xml = props[propName].xml || {}
136
+
137
+ if (props[propName].xml.attribute) {
138
+ const enumAttrVal = Array.isArray(props[propName].enum)
139
+ ? randomPick(props[propName].enum)
140
+ : undefined
141
+ if (hasExample(props[propName])) {
142
+ _attr[props[propName].xml.name || propName] = extractExample(
143
+ props[propName]
144
+ )
145
+ } else if (enumAttrVal !== undefined) {
146
+ _attr[props[propName].xml.name || propName] = enumAttrVal
147
+ } else {
148
+ const propSchema = typeCast(props[propName])
149
+ const propSchemaType = getType(propSchema)
150
+ const attrName = props[propName].xml.name || propName
151
+
152
+ if (propSchemaType === "array") {
153
+ const arraySample = sampleFromSchemaGeneric(
154
+ props[propName],
155
+ config,
156
+ overrideE,
157
+ false
158
+ )
159
+ _attr[attrName] = arraySample
160
+ .map((item) => {
161
+ if (isPlainObject(item)) {
162
+ return "UnknownTypeObject"
163
+ }
164
+ if (Array.isArray(item)) {
165
+ return "UnknownTypeArray"
166
+ }
167
+ return item
168
+ })
169
+ .join(" ")
170
+ } else {
171
+ _attr[attrName] =
172
+ propSchemaType === "object"
173
+ ? "UnknownTypeObject"
174
+ : typeMap[propSchemaType](propSchema)
175
+ }
176
+ }
177
+
178
+ return
179
+ }
180
+ props[propName].xml.name = props[propName].xml.name || propName
181
+ } else if (!props[propName] && additionalProperties !== false) {
182
+ // case only additionalProperty that is not defined in schema
183
+ props[propName] = {
184
+ xml: {
185
+ name: propName,
186
+ },
187
+ }
188
+ }
189
+
190
+ let t = sampleFromSchemaGeneric(
191
+ props[propName],
192
+ config,
193
+ overrideE,
194
+ respectXML
195
+ )
196
+ if (!canAddProperty(propName)) {
197
+ return
198
+ }
199
+
200
+ propertyAddedCounter++
201
+ if (Array.isArray(t)) {
202
+ res[displayName] = res[displayName].concat(t)
203
+ } else {
204
+ res[displayName].push(t)
205
+ }
206
+ }
207
+ } else {
208
+ addPropertyToResult = (propName, overrideE) => {
209
+ if (!canAddProperty(propName)) {
210
+ return
211
+ }
212
+ if (
213
+ isPlainObject(schema.discriminator?.mapping) &&
214
+ schema.discriminator.propertyName === propName &&
215
+ typeof schema.$$ref === "string"
216
+ ) {
217
+ for (const pair in schema.discriminator.mapping) {
218
+ if (schema.$$ref.search(schema.discriminator.mapping[pair]) !== -1) {
219
+ res[propName] = pair
220
+ break
221
+ }
222
+ }
223
+ } else {
224
+ res[propName] = sampleFromSchemaGeneric(
225
+ props[propName],
226
+ config,
227
+ overrideE,
228
+ respectXML
229
+ )
230
+ }
231
+ propertyAddedCounter++
232
+ }
233
+ }
234
+
235
+ // check for plain value and if found use it to generate sample from it
236
+ if (usePlainValue) {
237
+ let sample
238
+ if (exampleOverride !== undefined) {
239
+ sample = exampleOverride
240
+ } else {
241
+ sample = extractExample(schema)
242
+ }
243
+
244
+ // if json just return
245
+ if (!respectXML) {
246
+ // special case yaml parser can not know about
247
+ if (typeof sample === "number" && type === "string") {
248
+ return `${sample}`
249
+ }
250
+ // return if sample does not need any parsing
251
+ if (typeof sample !== "string" || type === "string") {
252
+ return sample
253
+ }
254
+ // check if sample is parsable or just a plain string
255
+ try {
256
+ return JSON.parse(sample)
257
+ } catch {
258
+ // sample is just plain string return it
259
+ return sample
260
+ }
261
+ }
262
+
263
+ // generate xml sample recursively for array case
264
+ if (type === "array") {
265
+ if (!Array.isArray(sample)) {
266
+ if (typeof sample === "string") {
267
+ return sample
268
+ }
269
+ sample = [sample]
270
+ }
271
+
272
+ let itemSamples = []
273
+
274
+ if (isJSONSchemaObject(items)) {
275
+ items.xml = items.xml || xml || {}
276
+ items.xml.name = items.xml.name || xml.name
277
+ itemSamples = sample.map((s) =>
278
+ sampleFromSchemaGeneric(items, config, s, respectXML)
279
+ )
280
+ }
281
+
282
+ if (isJSONSchemaObject(contains)) {
283
+ contains.xml = contains.xml || xml || {}
284
+ contains.xml.name = contains.xml.name || xml.name
285
+ itemSamples = [
286
+ sampleFromSchemaGeneric(contains, config, undefined, respectXML),
287
+ ...itemSamples,
288
+ ]
289
+ }
290
+
291
+ itemSamples = typeMap.array(schema, { sample: itemSamples })
292
+ if (xml.wrapped) {
293
+ res[displayName] = itemSamples
294
+ if (!isEmpty(_attr)) {
295
+ res[displayName].push({ _attr: _attr })
296
+ }
297
+ } else {
298
+ res = itemSamples
299
+ }
300
+ return res
301
+ }
302
+
303
+ // generate xml sample recursively for object case
304
+ if (type === "object") {
305
+ // case literal example
306
+ if (typeof sample === "string") {
307
+ return sample
308
+ }
309
+ for (const propName in sample) {
310
+ if (!Object.hasOwn(sample, propName)) {
311
+ continue
312
+ }
313
+ if (props[propName]?.readOnly && !includeReadOnly) {
314
+ continue
315
+ }
316
+ if (props[propName]?.writeOnly && !includeWriteOnly) {
317
+ continue
318
+ }
319
+ if (props[propName]?.xml?.attribute) {
320
+ _attr[props[propName].xml.name || propName] = sample[propName]
321
+ continue
322
+ }
323
+ addPropertyToResult(propName, sample[propName])
324
+ }
325
+ if (!isEmpty(_attr)) {
326
+ res[displayName].push({ _attr: _attr })
327
+ }
328
+
329
+ return res
330
+ }
331
+
332
+ res[displayName] = !isEmpty(_attr) ? [{ _attr: _attr }, sample] : sample
333
+ return res
334
+ }
335
+
336
+ // use schema to generate sample
337
+ if (type === "array") {
338
+ let sampleArray = []
339
+
340
+ if (isJSONSchemaObject(contains)) {
341
+ if (respectXML) {
342
+ contains.xml = contains.xml || schema.xml || {}
343
+ contains.xml.name = contains.xml.name || xml.name
344
+ }
345
+
346
+ if (Array.isArray(contains.anyOf)) {
347
+ // eslint-disable-next-line no-unused-vars
348
+ const { anyOf, ...containsWithoutAnyOf } = items
349
+
350
+ sampleArray.push(
351
+ ...contains.anyOf.map((anyOfSchema) =>
352
+ sampleFromSchemaGeneric(
353
+ merge(anyOfSchema, containsWithoutAnyOf, config),
354
+ config,
355
+ undefined,
356
+ respectXML
357
+ )
358
+ )
359
+ )
360
+ } else if (Array.isArray(contains.oneOf)) {
361
+ // eslint-disable-next-line no-unused-vars
362
+ const { oneOf, ...containsWithoutOneOf } = items
363
+
364
+ sampleArray.push(
365
+ ...contains.oneOf.map((oneOfSchema) =>
366
+ sampleFromSchemaGeneric(
367
+ merge(oneOfSchema, containsWithoutOneOf, config),
368
+ config,
369
+ undefined,
370
+ respectXML
371
+ )
372
+ )
373
+ )
374
+ } else if (!respectXML || (respectXML && xml.wrapped)) {
375
+ sampleArray.push(
376
+ sampleFromSchemaGeneric(contains, config, undefined, respectXML)
377
+ )
378
+ } else {
379
+ return sampleFromSchemaGeneric(contains, config, undefined, respectXML)
380
+ }
381
+ }
382
+
383
+ if (isJSONSchemaObject(items)) {
384
+ if (respectXML) {
385
+ items.xml = items.xml || schema.xml || {}
386
+ items.xml.name = items.xml.name || xml.name
387
+ }
388
+
389
+ if (Array.isArray(items.anyOf)) {
390
+ // eslint-disable-next-line no-unused-vars
391
+ const { anyOf, ...itemsWithoutAnyOf } = items
392
+
393
+ sampleArray.push(
394
+ ...items.anyOf.map((i) =>
395
+ sampleFromSchemaGeneric(
396
+ merge(i, itemsWithoutAnyOf, config),
397
+ config,
398
+ undefined,
399
+ respectXML
400
+ )
401
+ )
402
+ )
403
+ } else if (Array.isArray(items.oneOf)) {
404
+ // eslint-disable-next-line no-unused-vars
405
+ const { oneOf, ...itemsWithoutOneOf } = items
406
+
407
+ sampleArray.push(
408
+ ...items.oneOf.map((i) =>
409
+ sampleFromSchemaGeneric(
410
+ merge(i, itemsWithoutOneOf, config),
411
+ config,
412
+ undefined,
413
+ respectXML
414
+ )
415
+ )
416
+ )
417
+ } else if (!respectXML || (respectXML && xml.wrapped)) {
418
+ sampleArray.push(
419
+ sampleFromSchemaGeneric(items, config, undefined, respectXML)
420
+ )
421
+ } else {
422
+ return sampleFromSchemaGeneric(items, config, undefined, respectXML)
423
+ }
424
+ }
425
+
426
+ sampleArray = typeMap.array(schema, { sample: sampleArray })
427
+ if (respectXML && xml.wrapped) {
428
+ res[displayName] = sampleArray
429
+ if (!isEmpty(_attr)) {
430
+ res[displayName].push({ _attr: _attr })
431
+ }
432
+ return res
433
+ }
434
+
435
+ return sampleArray
436
+ }
437
+
438
+ if (type === "object") {
439
+ for (let propName in props) {
440
+ if (!Object.hasOwn(props, propName)) {
441
+ continue
442
+ }
443
+ if (props[propName]?.deprecated) {
444
+ continue
445
+ }
446
+ if (props[propName]?.readOnly && !includeReadOnly) {
447
+ continue
448
+ }
449
+ if (props[propName]?.writeOnly && !includeWriteOnly) {
450
+ continue
451
+ }
452
+ addPropertyToResult(propName)
453
+ }
454
+ if (respectXML && _attr) {
455
+ res[displayName].push({ _attr: _attr })
456
+ }
457
+
458
+ if (hasExceededMaxProperties()) {
459
+ return res
460
+ }
461
+
462
+ if (isBooleanJSONSchema(additionalProperties) && additionalProperties) {
463
+ if (respectXML) {
464
+ res[displayName].push({ additionalProp: "Anything can be here" })
465
+ } else {
466
+ res.additionalProp1 = {}
467
+ }
468
+ propertyAddedCounter++
469
+ } else if (isJSONSchemaObject(additionalProperties)) {
470
+ const additionalProps = additionalProperties
471
+ const additionalPropSample = sampleFromSchemaGeneric(
472
+ additionalProps,
473
+ config,
474
+ undefined,
475
+ respectXML
476
+ )
477
+
478
+ if (
479
+ respectXML &&
480
+ typeof additionalProps?.xml?.name === "string" &&
481
+ additionalProps?.xml?.name !== "notagname"
482
+ ) {
483
+ res[displayName].push(additionalPropSample)
484
+ } else {
485
+ const keyName =
486
+ additionalProps?.["x-additionalPropertiesName"] || "additionalProp"
487
+ const toGenerateCount =
488
+ Number.isInteger(schema.minProperties) &&
489
+ schema.minProperties > 0 &&
490
+ propertyAddedCounter < schema.minProperties
491
+ ? schema.minProperties - propertyAddedCounter
492
+ : 3
493
+ for (let i = 1; i <= toGenerateCount; i++) {
494
+ if (hasExceededMaxProperties()) {
495
+ return res
496
+ }
497
+ if (respectXML) {
498
+ const temp = {}
499
+ temp[keyName + i] = additionalPropSample["notagname"]
500
+ res[displayName].push(temp)
501
+ } else {
502
+ res[keyName + i] = additionalPropSample
503
+ }
504
+ propertyAddedCounter++
505
+ }
506
+ }
507
+ }
508
+ return res
509
+ }
510
+
511
+ let value
512
+ if (typeof schema.const !== "undefined") {
513
+ // display const value
514
+ value = schema.const
515
+ } else if (schema && Array.isArray(schema.enum)) {
516
+ //display enum first value
517
+ value = randomPick(normalizeArray(schema.enum))
518
+ } else {
519
+ // display schema default
520
+ const contentSample = isJSONSchemaObject(schema.contentSchema)
521
+ ? sampleFromSchemaGeneric(
522
+ schema.contentSchema,
523
+ config,
524
+ undefined,
525
+ respectXML
526
+ )
527
+ : undefined
528
+ value = typeMap[type](schema, { sample: contentSample })
529
+ }
530
+
531
+ if (respectXML) {
532
+ res[displayName] = !isEmpty(_attr) ? [{ _attr: _attr }, value] : value
533
+ return res
534
+ }
535
+
536
+ return value
537
+ }
538
+
539
+ export const createXMLExample = (schema, config, o) => {
540
+ const json = sampleFromSchemaGeneric(schema, config, o, true)
541
+ if (!json) {
542
+ return
543
+ }
544
+ if (typeof json === "string") {
545
+ return json
546
+ }
547
+ return XML(json, { declaration: true, indent: "\t" })
548
+ }
549
+
550
+ export const sampleFromSchema = (schema, config, o) => {
551
+ return sampleFromSchemaGeneric(schema, config, o, false)
552
+ }
553
+
554
+ const resolver = (arg1, arg2, arg3) => [
555
+ arg1,
556
+ JSON.stringify(arg2),
557
+ JSON.stringify(arg3),
558
+ ]
559
+
560
+ export const memoizedCreateXMLExample = memoizeN(createXMLExample, resolver)
561
+
562
+ export const memoizedSampleFromSchema = memoizeN(sampleFromSchema, resolver)
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @prettier
3
+ */
4
+
5
+ export const applyArrayConstraints = (array, constraints = {}) => {
6
+ const { minItems, maxItems, uniqueItems } = constraints
7
+ const { contains, minContains, maxContains } = constraints
8
+ let constrainedArray = [...array]
9
+
10
+ if (contains != null && typeof contains === "object") {
11
+ if (Number.isInteger(minContains) && minContains > 1) {
12
+ const containsItem = constrainedArray.at(0)
13
+ for (let i = 1; i < minContains; i += 1) {
14
+ constrainedArray.unshift(containsItem)
15
+ }
16
+ }
17
+ if (Number.isInteger(maxContains) && maxContains > 0) {
18
+ /**
19
+ * This is noop. `minContains` already generate minimum required
20
+ * number of items that satisfies `contains`. `maxContains` would
21
+ * have no effect.
22
+ */
23
+ }
24
+ }
25
+
26
+ if (Number.isInteger(maxItems) && maxItems > 0) {
27
+ constrainedArray = array.slice(0, maxItems)
28
+ }
29
+ if (Number.isInteger(minItems) && minItems > 0) {
30
+ for (let i = 0; constrainedArray.length < minItems; i += 1) {
31
+ constrainedArray.push(constrainedArray[i % constrainedArray.length])
32
+ }
33
+ }
34
+
35
+ if (uniqueItems === true) {
36
+ /**
37
+ * If uniqueItems is true, it implies that every item in the array must be unique.
38
+ * This overrides any minItems constraint that cannot be satisfied with unique items.
39
+ * So if minItems is greater than the number of unique items,
40
+ * it should be reduced to the number of unique items.
41
+ */
42
+ constrainedArray = Array.from(new Set(constrainedArray))
43
+ }
44
+
45
+ return constrainedArray
46
+ }
47
+
48
+ const arrayType = (schema, { sample = [] } = {}) => {
49
+ return applyArrayConstraints(sample, schema)
50
+ }
51
+
52
+ export default arrayType
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @prettier
3
+ */
4
+
5
+ const booleanType = (schema) => {
6
+ return typeof schema.default === "boolean" ? schema.default : true
7
+ }
8
+
9
+ export default booleanType
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @prettier
3
+ */
4
+ import arrayType from "./array"
5
+ import objectType from "./object"
6
+ import stringType from "./string"
7
+ import numberType from "./number"
8
+ import integerType from "./integer"
9
+ import booleanType from "./boolean"
10
+ import nullType from "./null"
11
+
12
+ const typeMap = {
13
+ array: arrayType,
14
+ object: objectType,
15
+ string: stringType,
16
+ number: numberType,
17
+ integer: integerType,
18
+ boolean: booleanType,
19
+ null: nullType,
20
+ }
21
+
22
+ export default new Proxy(typeMap, {
23
+ get(target, prop) {
24
+ if (typeof prop === "string" && Object.hasOwn(target, prop)) {
25
+ return target[prop]
26
+ }
27
+
28
+ return () => `Unknown Type: ${prop}`
29
+ },
30
+ })
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @prettier
3
+ */
4
+ import { integer as randomInteger } from "../core/random"
5
+ import formatAPI from "../api/formatAPI"
6
+ import int32Generator from "../generators/int32"
7
+ import int64Generator from "../generators/int64"
8
+ import { applyNumberConstraints } from "./number"
9
+
10
+ const generateFormat = (schema) => {
11
+ const { format } = schema
12
+
13
+ const formatGenerator = formatAPI(format)
14
+ if (typeof formatGenerator === "function") {
15
+ return formatGenerator(schema)
16
+ }
17
+
18
+ switch (format) {
19
+ case "int32": {
20
+ return int32Generator()
21
+ }
22
+ case "int64": {
23
+ return int64Generator()
24
+ }
25
+ }
26
+
27
+ return randomInteger()
28
+ }
29
+
30
+ const integerType = (schema) => {
31
+ const { format } = schema
32
+ let generatedInteger
33
+
34
+ if (typeof format === "string") {
35
+ generatedInteger = generateFormat(schema)
36
+ } else {
37
+ generatedInteger = randomInteger()
38
+ }
39
+
40
+ return applyNumberConstraints(generatedInteger, schema)
41
+ }
42
+
43
+ export default integerType
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @prettier
3
+ */
4
+
5
+ const nullType = () => {
6
+ return null
7
+ }
8
+
9
+ export default nullType