@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.
- package/.agignore +1 -0
- package/.browserslistrc +29 -0
- package/.dockerignore +8 -0
- package/.editorconfig +10 -0
- package/.eslintrc.js +78 -0
- package/.lintstagedrc +4 -0
- package/.nvmrc +1 -0
- package/.prettierrc.yaml +5 -0
- package/.releaserc +26 -0
- package/AUTHORIZATION_CONFIG.md +350 -0
- package/Dockerfile +39 -0
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +117 -0
- package/babel.config.js +140 -0
- package/composer.json +40 -0
- package/dist/favicon-16x16.png +0 -0
- package/dist/favicon-32x32.png +0 -0
- package/dist/index.css +16 -0
- package/dist/index.html +19 -0
- package/dist/log.bundle-sizes.swagger-ui.txt +114 -0
- package/dist/log.es-bundle-core-sizes.swagger-ui.txt +14 -0
- package/dist/log.es-bundle-sizes.swagger-ui.txt +114 -0
- package/dist/oauth2-redirect.html +6 -0
- package/dist/oauth2-redirect.js +1 -0
- package/dist/swagger-initializer.js +20 -0
- package/dist/swagger-ui-bundle.js +2 -0
- package/dist/swagger-ui-bundle.js.LICENSE.txt +106 -0
- package/dist/swagger-ui-bundle.js.map +1 -0
- package/dist/swagger-ui-es-bundle-core.js +3 -0
- package/dist/swagger-ui-es-bundle-core.js.LICENSE.txt +35 -0
- package/dist/swagger-ui-es-bundle-core.js.map +1 -0
- package/dist/swagger-ui-es-bundle.js +2 -0
- package/dist/swagger-ui-es-bundle.js.LICENSE.txt +106 -0
- package/dist/swagger-ui-es-bundle.js.map +1 -0
- package/dist/swagger-ui-standalone-preset.js +2 -0
- package/dist/swagger-ui-standalone-preset.js.LICENSE.txt +22 -0
- package/dist/swagger-ui-standalone-preset.js.map +1 -0
- package/dist/swagger-ui.css +3 -0
- package/dist/swagger-ui.css.map +1 -0
- package/dist/swagger-ui.js +2 -0
- package/dist/swagger-ui.js.map +1 -0
- package/docker/configurator/helpers.js +13 -0
- package/docker/configurator/index.js +52 -0
- package/docker/configurator/oauth.js +55 -0
- package/docker/configurator/translator.js +111 -0
- package/docker/configurator/variables.js +125 -0
- package/docker/cors.conf +14 -0
- package/docker/default.conf.template +43 -0
- package/docker/docker-entrypoint.d/40-swagger-ui.sh +52 -0
- package/docker/embedding.conf +5 -0
- package/package.json +224 -0
- package/snapcraft.yaml +28 -0
- package/src/core/assets/rolling-load.svg +1 -0
- package/src/core/components/app.jsx +30 -0
- package/src/core/components/auth/api-key-auth.jsx +93 -0
- package/src/core/components/auth/auth-item.jsx +60 -0
- package/src/core/components/auth/authorization-popup.jsx +59 -0
- package/src/core/components/auth/authorize-btn.jsx +30 -0
- package/src/core/components/auth/authorize-operation-btn.jsx +35 -0
- package/src/core/components/auth/auths.jsx +124 -0
- package/src/core/components/auth/basic-auth.jsx +110 -0
- package/src/core/components/auth/error.jsx +24 -0
- package/src/core/components/auth/oauth2.jsx +283 -0
- package/src/core/components/clear.jsx +25 -0
- package/src/core/components/contact.jsx +44 -0
- package/src/core/components/content-type.jsx +64 -0
- package/src/core/components/copy-to-clipboard-btn.jsx +29 -0
- package/src/core/components/curl.jsx +38 -0
- package/src/core/components/debug.jsx +50 -0
- package/src/core/components/deep-link.jsx +20 -0
- package/src/core/components/errors.jsx +132 -0
- package/src/core/components/example.jsx +43 -0
- package/src/core/components/examples-select-value-retainer.jsx +254 -0
- package/src/core/components/examples-select.jsx +139 -0
- package/src/core/components/execute.jsx +103 -0
- package/src/core/components/footer.jsx +9 -0
- package/src/core/components/headers.jsx +58 -0
- package/src/core/components/info.jsx +169 -0
- package/src/core/components/initialized-input.jsx +36 -0
- package/src/core/components/jump-to-path.jsx +9 -0
- package/src/core/components/layout-utils.jsx +265 -0
- package/src/core/components/layouts/base.jsx +156 -0
- package/src/core/components/layouts/xpane.jsx +73 -0
- package/src/core/components/license.jsx +40 -0
- package/src/core/components/live-response.jsx +133 -0
- package/src/core/components/online-validator-badge.jsx +120 -0
- package/src/core/components/openapi-version.jsx +15 -0
- package/src/core/components/operation-extension-row.jsx +17 -0
- package/src/core/components/operation-extensions.jsx +35 -0
- package/src/core/components/operation-summary-method.jsx +25 -0
- package/src/core/components/operation-summary-path.jsx +54 -0
- package/src/core/components/operation-summary.jsx +102 -0
- package/src/core/components/operation-tag.jsx +121 -0
- package/src/core/components/operation.jsx +259 -0
- package/src/core/components/operations.jsx +100 -0
- package/src/core/components/overview.jsx +119 -0
- package/src/core/components/param-body.jsx +156 -0
- package/src/core/components/parameter-extension.jsx +12 -0
- package/src/core/components/parameter-include-empty.jsx +59 -0
- package/src/core/components/parameter-row.jsx +438 -0
- package/src/core/components/parameters/index.js +1 -0
- package/src/core/components/parameters/parameters.jsx +287 -0
- package/src/core/components/property.jsx +17 -0
- package/src/core/components/providers/README.md +6 -0
- package/src/core/components/providers/markdown.jsx +72 -0
- package/src/core/components/response-body.jsx +170 -0
- package/src/core/components/response-extension.jsx +12 -0
- package/src/core/components/response.jsx +276 -0
- package/src/core/components/responses.jsx +170 -0
- package/src/core/components/svg-assets.jsx +48 -0
- package/src/core/components/system-wrapper.jsx +0 -0
- package/src/core/components/try-it-out-button.jsx +41 -0
- package/src/core/components/version-pragma-filter.jsx +54 -0
- package/src/core/components/version-stamp.jsx +12 -0
- package/src/core/containers/OperationContainer.jsx +267 -0
- package/src/core/containers/authorize-btn.jsx +31 -0
- package/src/core/containers/filter.jsx +44 -0
- package/src/core/containers/info.jsx +35 -0
- package/src/core/index.js +174 -0
- package/src/core/oauth2-authorize.js +137 -0
- package/src/core/plugins/auth/actions.js +286 -0
- package/src/core/plugins/auth/components/lock-auth-icon.jsx +27 -0
- package/src/core/plugins/auth/components/unlock-auth-icon.jsx +27 -0
- package/src/core/plugins/auth/configs-extensions/wrap-actions.js +19 -0
- package/src/core/plugins/auth/index.js +94 -0
- package/src/core/plugins/auth/reducers.js +77 -0
- package/src/core/plugins/auth/selectors.js +121 -0
- package/src/core/plugins/auth/spec-extensions/wrap-actions.js +10 -0
- package/src/core/plugins/auth/wrap-actions.js +66 -0
- package/src/core/plugins/configs/actions.js +58 -0
- package/src/core/plugins/configs/fn.js +12 -0
- package/src/core/plugins/configs/index.js +16 -0
- package/src/core/plugins/configs/reducers.js +20 -0
- package/src/core/plugins/configs/selectors.js +4 -0
- package/src/core/plugins/deep-linking/README.md +1 -0
- package/src/core/plugins/deep-linking/helpers.js +7 -0
- package/src/core/plugins/deep-linking/index.js +24 -0
- package/src/core/plugins/deep-linking/layout.js +209 -0
- package/src/core/plugins/deep-linking/operation-tag-wrapper.jsx +25 -0
- package/src/core/plugins/deep-linking/operation-wrapper.jsx +27 -0
- package/src/core/plugins/download-url/index.js +126 -0
- package/src/core/plugins/err/actions.js +60 -0
- package/src/core/plugins/err/error-transformers/README.md +31 -0
- package/src/core/plugins/err/error-transformers/hook.js +38 -0
- package/src/core/plugins/err/error-transformers/transformers/not-of-type.js +29 -0
- package/src/core/plugins/err/error-transformers/transformers/parameter-oneof.js +59 -0
- package/src/core/plugins/err/index.js +15 -0
- package/src/core/plugins/err/reducers.js +100 -0
- package/src/core/plugins/err/selectors.js +15 -0
- package/src/core/plugins/filter/index.js +9 -0
- package/src/core/plugins/filter/opsFilter.js +3 -0
- package/src/core/plugins/icons/components/arrow-down.jsx +28 -0
- package/src/core/plugins/icons/components/arrow-up.jsx +28 -0
- package/src/core/plugins/icons/components/arrow.jsx +28 -0
- package/src/core/plugins/icons/components/close.jsx +28 -0
- package/src/core/plugins/icons/components/copy.jsx +34 -0
- package/src/core/plugins/icons/components/lock.jsx +28 -0
- package/src/core/plugins/icons/components/unlock.jsx +28 -0
- package/src/core/plugins/icons/index.js +24 -0
- package/src/core/plugins/json-schema-2020-12/components/Accordion/Accordion.jsx +45 -0
- package/src/core/plugins/json-schema-2020-12/components/Accordion/_accordion.scss +33 -0
- package/src/core/plugins/json-schema-2020-12/components/ExpandDeepButton/ExpandDeepButton.jsx +31 -0
- package/src/core/plugins/json-schema-2020-12/components/ExpandDeepButton/_expand-deep-button.scss +10 -0
- package/src/core/plugins/json-schema-2020-12/components/JSONSchema/JSONSchema.jsx +227 -0
- package/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss +34 -0
- package/src/core/plugins/json-schema-2020-12/components/JSONViewer/JSONViewer.jsx +153 -0
- package/src/core/plugins/json-schema-2020-12/components/JSONViewer/_json-viewer.scss +11 -0
- package/src/core/plugins/json-schema-2020-12/components/_all.scss +4 -0
- package/src/core/plugins/json-schema-2020-12/components/_mixins.scss +82 -0
- package/src/core/plugins/json-schema-2020-12/components/icons/ChevronRight.jsx +17 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$anchor.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$defs.jsx +93 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicRef.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$id.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$ref.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$schema.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/$vocabulary.jsx +66 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/_$vocabulary.scss +17 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/AdditionalProperties.jsx +55 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/AllOf.jsx +105 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf.jsx +105 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Const/Const.jsx +28 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Const/_const.scss +11 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Constraint/Constraint.jsx +38 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Constraint/_constraint.scss +16 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Contains.jsx +35 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/ContentSchema.jsx +39 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Default/Default.jsx +28 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Default/_default.scss +11 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/DependentRequired/DependentRequired.jsx +37 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/DependentRequired/_dependent-required.scss +12 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas.jsx +97 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Deprecated.jsx +22 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Description/Description.jsx +24 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Description/_description.scss +9 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx +35 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Enum/Enum.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Enum/_enum.scss +11 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Examples/Examples.jsx +30 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Examples/_examples.scss +11 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/ExtensionKeywords/ExtensionKeywords.jsx +103 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/ExtensionKeywords/_extension-keywords.scss +11 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx +35 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Items.jsx +35 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx +35 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/OneOf.jsx +105 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/PatternProperties/PatternProperties.jsx +41 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/PatternProperties/_pattern-properties.scss +21 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/PrefixItems.jsx +105 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Properties/Properties.jsx +61 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Properties/_properties.scss +24 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/PropertyNames.jsx +38 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/ReadOnly.jsx +22 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx +35 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Title/Title.jsx +24 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss +26 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/Type.jsx +27 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/UnevaluatedItems.jsx +39 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/UnevaluatedProperties.jsx +39 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/WriteOnly.jsx +22 -0
- package/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss +43 -0
- package/src/core/plugins/json-schema-2020-12/context.js +14 -0
- package/src/core/plugins/json-schema-2020-12/enum.js +10 -0
- package/src/core/plugins/json-schema-2020-12/fn.js +527 -0
- package/src/core/plugins/json-schema-2020-12/hoc.jsx +296 -0
- package/src/core/plugins/json-schema-2020-12/hooks.js +144 -0
- package/src/core/plugins/json-schema-2020-12/index.js +153 -0
- package/src/core/plugins/json-schema-2020-12/prop-types.js +10 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/api/encoderAPI.js +20 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/api/formatAPI.js +20 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/api/mediaTypeAPI.js +27 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/api/optionAPI.js +17 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/class/EncoderRegistry.js +33 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/class/FormatRegistry.js +65 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/class/MediaTypeRegistry.js +27 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/class/OptionRegistry.js +16 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/class/Registry.js +24 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/constants.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/example.js +57 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/merge.js +83 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/predicates.js +16 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/random.js +46 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/type.js +156 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/core/utils.js +23 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/7bit.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/8bit.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base16.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base32.js +34 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base64.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/base64url.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/binary.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/encoders/quoted-printable.js +38 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/date-time.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/date.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/double.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/duration.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/email.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/float.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/hostname.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/idn-email.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/idn-hostname.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/int32.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/int64.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/ipv4.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/ipv6.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/iri-reference.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/iri.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/json-pointer.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/application.js +17 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/audio.js +10 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/image.js +10 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/text.js +17 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/media-types/video.js +10 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/password.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/regex.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/relative-json-pointer.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/time.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uri-reference.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uri-template.js +7 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uri.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/generators/uuid.js +6 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/get-json-sample-schema.js +36 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/get-sample-schema.js +39 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/get-xml-sample-schema.js +35 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/get-yaml-sample-schema.js +34 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/index.js +16 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/main.js +562 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/array.js +52 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/boolean.js +9 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/index.js +30 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/integer.js +43 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/null.js +9 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/number.js +65 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/object.js +9 -0
- package/src/core/plugins/json-schema-2020-12-samples/fn/types/string.js +80 -0
- package/src/core/plugins/json-schema-2020-12-samples/index.js +51 -0
- package/src/core/plugins/json-schema-5/components/array-model.jsx +80 -0
- package/src/core/plugins/json-schema-5/components/enum-model.jsx +19 -0
- package/src/core/plugins/json-schema-5/components/json-schema-components.jsx +441 -0
- package/src/core/plugins/json-schema-5/components/model-collapse.jsx +99 -0
- package/src/core/plugins/json-schema-5/components/model-example.jsx +160 -0
- package/src/core/plugins/json-schema-5/components/model-extensions.jsx +28 -0
- package/src/core/plugins/json-schema-5/components/model-wrapper.jsx +44 -0
- package/src/core/plugins/json-schema-5/components/model.jsx +136 -0
- package/src/core/plugins/json-schema-5/components/models.jsx +139 -0
- package/src/core/plugins/json-schema-5/components/object-model.jsx +340 -0
- package/src/core/plugins/json-schema-5/components/primitive-model.jsx +137 -0
- package/src/core/plugins/json-schema-5/components/schemes.jsx +53 -0
- package/src/core/plugins/json-schema-5/containers/schemes.jsx +30 -0
- package/src/core/plugins/json-schema-5/fn.js +51 -0
- package/src/core/plugins/json-schema-5/index.js +41 -0
- package/src/core/plugins/json-schema-5-samples/fn/get-json-sample-schema.js +32 -0
- package/src/core/plugins/json-schema-5-samples/fn/get-sample-schema.js +30 -0
- package/src/core/plugins/json-schema-5-samples/fn/get-xml-sample-schema.js +31 -0
- package/src/core/plugins/json-schema-5-samples/fn/get-yaml-sample-schema.js +34 -0
- package/src/core/plugins/json-schema-5-samples/fn/index.js +653 -0
- package/src/core/plugins/json-schema-5-samples/index.js +56 -0
- package/src/core/plugins/layout/actions.js +39 -0
- package/src/core/plugins/layout/index.js +19 -0
- package/src/core/plugins/layout/reducers.js +32 -0
- package/src/core/plugins/layout/selectors.js +24 -0
- package/src/core/plugins/layout/spec-extensions/wrap-selector.js +22 -0
- package/src/core/plugins/logs/index.js +28 -0
- package/src/core/plugins/oas3/actions.js +99 -0
- package/src/core/plugins/oas3/auth-extensions/wrap-selectors.js +92 -0
- package/src/core/plugins/oas3/components/auth/http-auth.jsx +157 -0
- package/src/core/plugins/oas3/components/callbacks.jsx +51 -0
- package/src/core/plugins/oas3/components/index.js +19 -0
- package/src/core/plugins/oas3/components/operation-link.jsx +43 -0
- package/src/core/plugins/oas3/components/operation-servers.jsx +102 -0
- package/src/core/plugins/oas3/components/request-body-editor.jsx +103 -0
- package/src/core/plugins/oas3/components/request-body.jsx +338 -0
- package/src/core/plugins/oas3/components/servers-container.jsx +33 -0
- package/src/core/plugins/oas3/components/servers.jsx +153 -0
- package/src/core/plugins/oas3/fn.js +35 -0
- package/src/core/plugins/oas3/helpers.jsx +48 -0
- package/src/core/plugins/oas3/index.js +39 -0
- package/src/core/plugins/oas3/reducers.js +111 -0
- package/src/core/plugins/oas3/selectors.js +308 -0
- package/src/core/plugins/oas3/spec-extensions/selectors.js +100 -0
- package/src/core/plugins/oas3/spec-extensions/wrap-selectors.js +71 -0
- package/src/core/plugins/oas3/wrap-components/auth/auth-item.jsx +25 -0
- package/src/core/plugins/oas3/wrap-components/index.js +15 -0
- package/src/core/plugins/oas3/wrap-components/json-schema-string.jsx +27 -0
- package/src/core/plugins/oas3/wrap-components/markdown.jsx +45 -0
- package/src/core/plugins/oas3/wrap-components/model.jsx +40 -0
- package/src/core/plugins/oas3/wrap-components/online-validator-badge.js +5 -0
- package/src/core/plugins/oas3/wrap-components/openapi-version.jsx +7 -0
- package/src/core/plugins/oas31/after-load.js +72 -0
- package/src/core/plugins/oas31/auth-extensions/wrap-selectors.js +28 -0
- package/src/core/plugins/oas31/components/_all.scss +2 -0
- package/src/core/plugins/oas31/components/auth/auths.jsx +186 -0
- package/src/core/plugins/oas31/components/auth/mutual-tls-auth.jsx +32 -0
- package/src/core/plugins/oas31/components/contact.jsx +43 -0
- package/src/core/plugins/oas31/components/info.jsx +99 -0
- package/src/core/plugins/oas31/components/json-schema-dialect.jsx +60 -0
- package/src/core/plugins/oas31/components/license.jsx +38 -0
- package/src/core/plugins/oas31/components/model/_model.scss +23 -0
- package/src/core/plugins/oas31/components/model/model.jsx +54 -0
- package/src/core/plugins/oas31/components/models/_models.scss +11 -0
- package/src/core/plugins/oas31/components/models/models.jsx +141 -0
- package/src/core/plugins/oas31/components/version-pragma-filter.jsx +73 -0
- package/src/core/plugins/oas31/components/webhooks.jsx +49 -0
- package/src/core/plugins/oas31/fn.js +124 -0
- package/src/core/plugins/oas31/index.js +166 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Description.jsx +27 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Discriminator/Discriminator.jsx +118 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Discriminator/DiscriminatorMapping.jsx +32 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Example.jsx +28 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/ExternalDocs.jsx +143 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/OpenAPIExtensions.jsx +33 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Properties.jsx +60 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/components/keywords/Xml.jsx +162 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/fn.js +57 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Description.jsx +9 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Examples.jsx +31 -0
- package/src/core/plugins/oas31/json-schema-2020-12-extensions/wrap-components/keywords/Properties.jsx +9 -0
- package/src/core/plugins/oas31/oas3-extensions/fn.js +46 -0
- package/src/core/plugins/oas31/selectors.js +26 -0
- package/src/core/plugins/oas31/spec-extensions/selectors.js +198 -0
- package/src/core/plugins/oas31/spec-extensions/wrap-selectors.js +18 -0
- package/src/core/plugins/oas31/wrap-components/auth/auth-item.jsx +22 -0
- package/src/core/plugins/oas31/wrap-components/auths.jsx +17 -0
- package/src/core/plugins/oas31/wrap-components/contact.jsx +15 -0
- package/src/core/plugins/oas31/wrap-components/info.jsx +15 -0
- package/src/core/plugins/oas31/wrap-components/license.jsx +15 -0
- package/src/core/plugins/oas31/wrap-components/model.jsx +44 -0
- package/src/core/plugins/oas31/wrap-components/models.jsx +47 -0
- package/src/core/plugins/oas31/wrap-components/version-pragma-filter.jsx +16 -0
- package/src/core/plugins/on-complete/index.js +28 -0
- package/src/core/plugins/request-snippets/fn.js +169 -0
- package/src/core/plugins/request-snippets/index.js +21 -0
- package/src/core/plugins/request-snippets/request-snippets.jsx +163 -0
- package/src/core/plugins/request-snippets/selectors.js +45 -0
- package/src/core/plugins/safe-render/components/error-boundary.jsx +52 -0
- package/src/core/plugins/safe-render/components/fallback.jsx +13 -0
- package/src/core/plugins/safe-render/fn.jsx +32 -0
- package/src/core/plugins/safe-render/index.js +42 -0
- package/src/core/plugins/spec/actions.js +531 -0
- package/src/core/plugins/spec/index.js +20 -0
- package/src/core/plugins/spec/reducers.js +176 -0
- package/src/core/plugins/spec/selectors.js +575 -0
- package/src/core/plugins/spec/wrap-actions.js +39 -0
- package/src/core/plugins/swagger-client/configs-wrap-actions.js +6 -0
- package/src/core/plugins/swagger-client/index.js +54 -0
- package/src/core/plugins/syntax-highlighting/after-load.js +25 -0
- package/src/core/plugins/syntax-highlighting/components/HighlightCode.jsx +107 -0
- package/src/core/plugins/syntax-highlighting/components/PlainTextViewer.jsx +17 -0
- package/src/core/plugins/syntax-highlighting/components/SyntaxHighlighter.jsx +42 -0
- package/src/core/plugins/syntax-highlighting/index.js +34 -0
- package/src/core/plugins/syntax-highlighting/root-injects.js +22 -0
- package/src/core/plugins/syntax-highlighting/wrap-components/SyntaxHighlighter.jsx +31 -0
- package/src/core/plugins/util/index.js +11 -0
- package/src/core/plugins/versions/after-load.js +19 -0
- package/src/core/plugins/versions/index.js +10 -0
- package/src/core/plugins/view/fn.js +1 -0
- package/src/core/plugins/view/index.js +34 -0
- package/src/core/plugins/view/root-injects.jsx +118 -0
- package/src/core/plugins/view-legacy/index.js +25 -0
- package/src/core/plugins/view-legacy/root-injects.jsx +12 -0
- package/src/core/presets/apis/index.js +18 -0
- package/src/core/presets/base/index.js +55 -0
- package/src/core/presets/base/plugins/core-components/index.js +130 -0
- package/src/core/presets/base/plugins/form-components/index.js +10 -0
- package/src/core/system.js +511 -0
- package/src/core/utils/create-html-ready-id.js +10 -0
- package/src/core/utils/get-parameter-schema.js +94 -0
- package/src/core/utils/index.js +847 -0
- package/src/core/utils/jsonParse.js +15 -0
- package/src/core/utils/memoizeN.js +48 -0
- package/src/core/utils/url.js +79 -0
- package/src/core/window.js +30 -0
- package/src/index.js +3 -0
- package/src/standalone/plugins/stadalone-layout/components/StandaloneLayout.jsx +40 -0
- package/src/standalone/plugins/stadalone-layout/index.js +12 -0
- package/src/standalone/plugins/top-bar/assets/lightbulb-off.svg +1 -0
- package/src/standalone/plugins/top-bar/assets/lightbulb.svg +1 -0
- package/src/standalone/plugins/top-bar/assets/logo_small.svg +60 -0
- package/src/standalone/plugins/top-bar/components/DarkModeToggle.jsx +47 -0
- package/src/standalone/plugins/top-bar/components/Logo.jsx +9 -0
- package/src/standalone/plugins/top-bar/components/TopBar.jsx +183 -0
- package/src/standalone/plugins/top-bar/index.js +12 -0
- package/src/standalone/presets/standalone/index.js +19 -0
- package/src/style/_authorize.scss +96 -0
- package/src/style/_buttons.scss +199 -0
- package/src/style/_dark-mode.scss +664 -0
- package/src/style/_errors.scss +72 -0
- package/src/style/_form.scss +214 -0
- package/src/style/_information.scss +99 -0
- package/src/style/_layout.scss +941 -0
- package/src/style/_markdown.scss +34 -0
- package/src/style/_mixins.scss +159 -0
- package/src/style/_modal.scss +95 -0
- package/src/style/_models.scss +330 -0
- package/src/style/_servers.scss +66 -0
- package/src/style/_split-pane-mode.scss +3 -0
- package/src/style/_table.scss +191 -0
- package/src/style/_topbar.scss +126 -0
- package/src/style/_type.scss +21 -0
- package/src/style/_variables.scss +230 -0
- package/src/style/main.scss +28 -0
- package/stylelint.config.js +11 -0
- package/swagger-ui-dist-package/absolute-path.js +14 -0
- package/swagger-ui-dist-package/index.js +17 -0
- package/swagger-ui-dist-package/package.json +20 -0
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import XML from "xml"
|
|
2
|
+
import RandExp from "randexp"
|
|
3
|
+
import isEmpty from "lodash/isEmpty"
|
|
4
|
+
import { deeplyStripKey, isFunc, normalizeArray, objectify, immutableToJS } from "core/utils"
|
|
5
|
+
import memoizeN from "core/utils/memoizeN"
|
|
6
|
+
|
|
7
|
+
const generateStringFromRegex = (pattern) => {
|
|
8
|
+
try {
|
|
9
|
+
/**
|
|
10
|
+
* Applying maximum value (100) to numbers from regex patterns to avoid ReDoS:
|
|
11
|
+
* 1. {x}
|
|
12
|
+
* 2. {x,}
|
|
13
|
+
* 3. {,y}
|
|
14
|
+
* 4. {x,y}
|
|
15
|
+
*/
|
|
16
|
+
const patternSanitizer =
|
|
17
|
+
/(?<=(?<!\\)\{)(\d{3,})(?=\})|(?<=(?<!\\)\{\d*,)(\d{3,})(?=\})|(?<=(?<!\\)\{)(\d{3,})(?=,\d*\})/g
|
|
18
|
+
const safePattern = pattern.replace(patternSanitizer, "100")
|
|
19
|
+
const randexpInstance = new RandExp(safePattern)
|
|
20
|
+
randexpInstance.max = 100
|
|
21
|
+
return randexpInstance.gen()
|
|
22
|
+
} catch (e) {
|
|
23
|
+
// Invalid regex should not cause a crash (regex syntax varies across languages)
|
|
24
|
+
return "string"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const primitives = {
|
|
29
|
+
"string": (schema) => schema.pattern ? generateStringFromRegex(schema.pattern) : "string",
|
|
30
|
+
"string_email": () => "user@example.com",
|
|
31
|
+
"string_date-time": () => new Date().toISOString(),
|
|
32
|
+
"string_date": () => new Date().toISOString().substring(0, 10),
|
|
33
|
+
"string_time": () => new Date().toISOString().substring(11),
|
|
34
|
+
"string_uuid": () => "3fa85f64-5717-4562-b3fc-2c963f66afa6",
|
|
35
|
+
"string_hostname": () => "example.com",
|
|
36
|
+
"string_ipv4": () => "198.51.100.42",
|
|
37
|
+
"string_ipv6": () => "2001:0db8:5b96:0000:0000:426f:8e17:642a",
|
|
38
|
+
"number": () => 0,
|
|
39
|
+
"number_float": () => 0.0,
|
|
40
|
+
"integer": () => 0,
|
|
41
|
+
"boolean": (schema) => typeof schema.default === "boolean" ? schema.default : true
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const primitive = (schema) => {
|
|
45
|
+
schema = objectify(schema)
|
|
46
|
+
let { type, format } = schema
|
|
47
|
+
|
|
48
|
+
let fn = primitives[`${type}_${format}`] || primitives[type]
|
|
49
|
+
|
|
50
|
+
if(isFunc(fn))
|
|
51
|
+
return fn(schema)
|
|
52
|
+
|
|
53
|
+
return "Unknown Type: " + schema.type
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// do a couple of quick sanity tests to ensure the value
|
|
57
|
+
// looks like a $$ref that swagger-client generates.
|
|
58
|
+
const sanitizeRef = (value) => deeplyStripKey(value, "$$ref", (val) =>
|
|
59
|
+
typeof val === "string" && val.indexOf("#") > -1)
|
|
60
|
+
|
|
61
|
+
const objectContracts = ["maxProperties", "minProperties"]
|
|
62
|
+
const arrayContracts = ["minItems", "maxItems"]
|
|
63
|
+
const numberContracts = [
|
|
64
|
+
"minimum",
|
|
65
|
+
"maximum",
|
|
66
|
+
"exclusiveMinimum",
|
|
67
|
+
"exclusiveMaximum"
|
|
68
|
+
]
|
|
69
|
+
const stringContracts = ["minLength", "maxLength"]
|
|
70
|
+
|
|
71
|
+
export const mergeJsonSchema = (target, source, config = {}) => {
|
|
72
|
+
const merged = { ...target }
|
|
73
|
+
|
|
74
|
+
const setIfNotDefinedInTarget = (key) => {
|
|
75
|
+
if(merged[key] === undefined && source[key] !== undefined) {
|
|
76
|
+
merged[key] = source[key]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[
|
|
81
|
+
"example",
|
|
82
|
+
"default",
|
|
83
|
+
"enum",
|
|
84
|
+
"xml",
|
|
85
|
+
"type",
|
|
86
|
+
...objectContracts,
|
|
87
|
+
...arrayContracts,
|
|
88
|
+
...numberContracts,
|
|
89
|
+
...stringContracts,
|
|
90
|
+
].forEach(key => setIfNotDefinedInTarget(key))
|
|
91
|
+
|
|
92
|
+
if(source.required !== undefined && Array.isArray(source.required)) {
|
|
93
|
+
if(merged.required === undefined || !merged.required.length) {
|
|
94
|
+
merged.required = []
|
|
95
|
+
}
|
|
96
|
+
source.required.forEach(key => {
|
|
97
|
+
if(merged.required.includes(key)) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
merged.required.push(key)
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
if(source.properties) {
|
|
104
|
+
if(!merged.properties) {
|
|
105
|
+
merged.properties = {}
|
|
106
|
+
}
|
|
107
|
+
let props = objectify(source.properties)
|
|
108
|
+
for (let propName in props) {
|
|
109
|
+
if (!Object.prototype.hasOwnProperty.call(props, propName)) {
|
|
110
|
+
continue
|
|
111
|
+
}
|
|
112
|
+
if ( props[propName] && props[propName].deprecated ) {
|
|
113
|
+
continue
|
|
114
|
+
}
|
|
115
|
+
if ( props[propName] && props[propName].readOnly && !config.includeReadOnly ) {
|
|
116
|
+
continue
|
|
117
|
+
}
|
|
118
|
+
if ( props[propName] && props[propName].writeOnly && !config.includeWriteOnly ) {
|
|
119
|
+
continue
|
|
120
|
+
}
|
|
121
|
+
if(!merged.properties[propName]) {
|
|
122
|
+
merged.properties[propName] = props[propName]
|
|
123
|
+
if(!source.required && Array.isArray(source.required) && source.required.indexOf(propName) !== -1) {
|
|
124
|
+
if(!merged.required) {
|
|
125
|
+
merged.required = [propName]
|
|
126
|
+
} else {
|
|
127
|
+
merged.required.push(propName)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if(source.items) {
|
|
134
|
+
if(!merged.items) {
|
|
135
|
+
merged.items = {}
|
|
136
|
+
}
|
|
137
|
+
merged.items = mergeJsonSchema(merged.items, source.items, config)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return merged
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const sampleFromSchemaGeneric = (schema, config={}, exampleOverride = undefined, respectXML = false) => {
|
|
144
|
+
if(schema && isFunc(schema.toJS))
|
|
145
|
+
schema = schema.toJS()
|
|
146
|
+
let usePlainValue = exampleOverride !== undefined || schema && schema.example !== undefined || schema && schema.default !== undefined
|
|
147
|
+
// first check if there is the need of combining this schema with others required by allOf
|
|
148
|
+
const hasOneOf = !usePlainValue && schema && schema.oneOf && schema.oneOf.length > 0
|
|
149
|
+
const hasAnyOf = !usePlainValue && schema && schema.anyOf && schema.anyOf.length > 0
|
|
150
|
+
if(!usePlainValue && (hasOneOf || hasAnyOf)) {
|
|
151
|
+
const schemaToAdd = objectify(hasOneOf
|
|
152
|
+
? schema.oneOf[0]
|
|
153
|
+
: schema.anyOf[0]
|
|
154
|
+
)
|
|
155
|
+
schema = mergeJsonSchema(schema, schemaToAdd, config)
|
|
156
|
+
if(!schema.xml && schemaToAdd.xml) {
|
|
157
|
+
schema.xml = schemaToAdd.xml
|
|
158
|
+
}
|
|
159
|
+
if(schema.example !== undefined && schemaToAdd.example !== undefined) {
|
|
160
|
+
usePlainValue = true
|
|
161
|
+
} else if(schemaToAdd.properties) {
|
|
162
|
+
if(!schema.properties) {
|
|
163
|
+
schema.properties = {}
|
|
164
|
+
}
|
|
165
|
+
let props = objectify(schemaToAdd.properties)
|
|
166
|
+
for (let propName in props) {
|
|
167
|
+
if (!Object.prototype.hasOwnProperty.call(props, propName)) {
|
|
168
|
+
continue
|
|
169
|
+
}
|
|
170
|
+
if ( props[propName] && props[propName].deprecated ) {
|
|
171
|
+
continue
|
|
172
|
+
}
|
|
173
|
+
if ( props[propName] && props[propName].readOnly && !config.includeReadOnly ) {
|
|
174
|
+
continue
|
|
175
|
+
}
|
|
176
|
+
if ( props[propName] && props[propName].writeOnly && !config.includeWriteOnly ) {
|
|
177
|
+
continue
|
|
178
|
+
}
|
|
179
|
+
if(!schema.properties[propName]) {
|
|
180
|
+
schema.properties[propName] = props[propName]
|
|
181
|
+
if(!schemaToAdd.required && Array.isArray(schemaToAdd.required) && schemaToAdd.required.indexOf(propName) !== -1) {
|
|
182
|
+
if(!schema.required) {
|
|
183
|
+
schema.required = [propName]
|
|
184
|
+
} else {
|
|
185
|
+
schema.required.push(propName)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const _attr = {}
|
|
193
|
+
let { xml, type, example, properties, additionalProperties, items } = schema || {}
|
|
194
|
+
let { includeReadOnly, includeWriteOnly } = config
|
|
195
|
+
xml = xml || {}
|
|
196
|
+
let { name, prefix, namespace } = xml
|
|
197
|
+
let displayName
|
|
198
|
+
let res = {}
|
|
199
|
+
|
|
200
|
+
// set xml naming and attributes
|
|
201
|
+
if(respectXML) {
|
|
202
|
+
name = name || "notagname"
|
|
203
|
+
// add prefix to name if exists
|
|
204
|
+
displayName = (prefix ? prefix + ":" : "") + name
|
|
205
|
+
if ( namespace ) {
|
|
206
|
+
//add prefix to namespace if exists
|
|
207
|
+
let namespacePrefix = prefix ? ( "xmlns:" + prefix ) : "xmlns"
|
|
208
|
+
_attr[namespacePrefix] = namespace
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// init xml default response sample obj
|
|
213
|
+
if(respectXML) {
|
|
214
|
+
res[displayName] = []
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const schemaHasAny = (keys) => keys.some(key => Object.prototype.hasOwnProperty.call(schema, key))
|
|
218
|
+
// try recover missing type
|
|
219
|
+
if(schema && !type) {
|
|
220
|
+
if(properties || additionalProperties || schemaHasAny(objectContracts)) {
|
|
221
|
+
type = "object"
|
|
222
|
+
} else if(items || schemaHasAny(arrayContracts)) {
|
|
223
|
+
type = "array"
|
|
224
|
+
} else if(schemaHasAny(numberContracts)) {
|
|
225
|
+
type = "number"
|
|
226
|
+
schema.type = "number"
|
|
227
|
+
} else if(!usePlainValue && !schema.enum){
|
|
228
|
+
// implicit cover schemaHasAny(stringContracts) or A schema without a type matches any data type is:
|
|
229
|
+
// components:
|
|
230
|
+
// schemas:
|
|
231
|
+
// AnyValue:
|
|
232
|
+
// anyOf:
|
|
233
|
+
// - type: string
|
|
234
|
+
// - type: number
|
|
235
|
+
// - type: integer
|
|
236
|
+
// - type: boolean
|
|
237
|
+
// - type: array
|
|
238
|
+
// items: {}
|
|
239
|
+
// - type: object
|
|
240
|
+
//
|
|
241
|
+
// which would resolve to type: string
|
|
242
|
+
type = "string"
|
|
243
|
+
schema.type = "string"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const handleMinMaxItems = (sampleArray) => {
|
|
248
|
+
if (schema?.maxItems !== null && schema?.maxItems !== undefined) {
|
|
249
|
+
sampleArray = sampleArray.slice(0, schema?.maxItems)
|
|
250
|
+
}
|
|
251
|
+
if (schema?.minItems !== null && schema?.minItems !== undefined) {
|
|
252
|
+
let i = 0
|
|
253
|
+
while (sampleArray.length < schema?.minItems) {
|
|
254
|
+
sampleArray.push(sampleArray[i++ % sampleArray.length])
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return sampleArray
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// add to result helper init for xml or json
|
|
261
|
+
const props = objectify(properties)
|
|
262
|
+
let addPropertyToResult
|
|
263
|
+
let propertyAddedCounter = 0
|
|
264
|
+
|
|
265
|
+
const hasExceededMaxProperties = () => schema
|
|
266
|
+
&& schema.maxProperties !== null && schema.maxProperties !== undefined
|
|
267
|
+
&& propertyAddedCounter >= schema.maxProperties
|
|
268
|
+
|
|
269
|
+
const requiredPropertiesToAdd = () => {
|
|
270
|
+
if(!schema || !schema.required) {
|
|
271
|
+
return 0
|
|
272
|
+
}
|
|
273
|
+
let addedCount = 0
|
|
274
|
+
if(respectXML) {
|
|
275
|
+
schema.required.forEach(key => addedCount +=
|
|
276
|
+
res[key] === undefined
|
|
277
|
+
? 0
|
|
278
|
+
: 1
|
|
279
|
+
)
|
|
280
|
+
} else {
|
|
281
|
+
schema.required.forEach(key => addedCount +=
|
|
282
|
+
res[displayName]?.find(x => x[key] !== undefined) === undefined
|
|
283
|
+
? 0
|
|
284
|
+
: 1
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
return schema.required.length - addedCount
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const isOptionalProperty = (propName) => {
|
|
291
|
+
if(!schema || !schema.required || !schema.required.length) {
|
|
292
|
+
return true
|
|
293
|
+
}
|
|
294
|
+
return !schema.required.includes(propName)
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const canAddProperty = (propName) => {
|
|
298
|
+
if(!schema || schema.maxProperties === null || schema.maxProperties === undefined) {
|
|
299
|
+
return true
|
|
300
|
+
}
|
|
301
|
+
if(hasExceededMaxProperties()) {
|
|
302
|
+
return false
|
|
303
|
+
}
|
|
304
|
+
if(!isOptionalProperty(propName)) {
|
|
305
|
+
return true
|
|
306
|
+
}
|
|
307
|
+
return (schema.maxProperties - propertyAddedCounter - requiredPropertiesToAdd()) > 0
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if(respectXML) {
|
|
311
|
+
addPropertyToResult = (propName, overrideE = undefined) => {
|
|
312
|
+
if(schema && props[propName]) {
|
|
313
|
+
// case it is an xml attribute
|
|
314
|
+
props[propName].xml = props[propName].xml || {}
|
|
315
|
+
|
|
316
|
+
if (props[propName].xml.attribute) {
|
|
317
|
+
const enumAttrVal = Array.isArray(props[propName].enum)
|
|
318
|
+
? props[propName].enum[0]
|
|
319
|
+
: undefined
|
|
320
|
+
const attrExample = props[propName].example
|
|
321
|
+
const attrDefault = props[propName].default
|
|
322
|
+
|
|
323
|
+
if(attrExample !== undefined) {
|
|
324
|
+
_attr[props[propName].xml.name || propName] = attrExample
|
|
325
|
+
} else if(attrDefault !== undefined) {
|
|
326
|
+
_attr[props[propName].xml.name || propName] = attrDefault
|
|
327
|
+
} else if(enumAttrVal !== undefined) {
|
|
328
|
+
_attr[props[propName].xml.name || propName] = enumAttrVal
|
|
329
|
+
} else {
|
|
330
|
+
_attr[props[propName].xml.name || propName] = primitive(props[propName])
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
props[propName].xml.name = props[propName].xml.name || propName
|
|
336
|
+
} else if(!props[propName] && additionalProperties !== false) {
|
|
337
|
+
// case only additionalProperty that is not defined in schema
|
|
338
|
+
props[propName] = {
|
|
339
|
+
xml: {
|
|
340
|
+
name: propName
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
let t = sampleFromSchemaGeneric(schema && props[propName] || undefined, config, overrideE, respectXML)
|
|
346
|
+
if(!canAddProperty(propName)) {
|
|
347
|
+
return
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
propertyAddedCounter++
|
|
351
|
+
if (Array.isArray(t)) {
|
|
352
|
+
res[displayName] = res[displayName].concat(t)
|
|
353
|
+
} else {
|
|
354
|
+
res[displayName].push(t)
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
} else {
|
|
358
|
+
addPropertyToResult = (propName, overrideE) => {
|
|
359
|
+
if(!canAddProperty(propName)) {
|
|
360
|
+
return
|
|
361
|
+
}
|
|
362
|
+
if(Object.prototype.hasOwnProperty.call(schema, "discriminator") &&
|
|
363
|
+
schema.discriminator &&
|
|
364
|
+
Object.prototype.hasOwnProperty.call(schema.discriminator, "mapping") &&
|
|
365
|
+
schema.discriminator.mapping &&
|
|
366
|
+
Object.prototype.hasOwnProperty.call(schema, "$$ref") &&
|
|
367
|
+
schema.$$ref &&
|
|
368
|
+
schema.discriminator.propertyName === propName) {
|
|
369
|
+
for (let pair in schema.discriminator.mapping){
|
|
370
|
+
if (schema.$$ref.search(schema.discriminator.mapping[pair]) !== -1) {
|
|
371
|
+
res[propName] = pair
|
|
372
|
+
break
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
} else {
|
|
376
|
+
res[propName] = sampleFromSchemaGeneric(props[propName], config, overrideE, respectXML)
|
|
377
|
+
}
|
|
378
|
+
propertyAddedCounter++
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// check for plain value and if found use it to generate sample from it
|
|
383
|
+
if(usePlainValue) {
|
|
384
|
+
let sample
|
|
385
|
+
if(exampleOverride !== undefined) {
|
|
386
|
+
sample = sanitizeRef(exampleOverride)
|
|
387
|
+
} else if(example !== undefined) {
|
|
388
|
+
sample = sanitizeRef(example)
|
|
389
|
+
} else {
|
|
390
|
+
sample = sanitizeRef(schema.default)
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// if json just return
|
|
394
|
+
if(!respectXML) {
|
|
395
|
+
// special case yaml parser can not know about
|
|
396
|
+
if(typeof sample === "number" && type === "string") {
|
|
397
|
+
return `${sample}`
|
|
398
|
+
}
|
|
399
|
+
// return if sample does not need any parsing
|
|
400
|
+
if(typeof sample !== "string" || type === "string") {
|
|
401
|
+
return sample
|
|
402
|
+
}
|
|
403
|
+
// check if sample is parsable or just a plain string
|
|
404
|
+
try {
|
|
405
|
+
return JSON.parse(sample)
|
|
406
|
+
} catch(e) {
|
|
407
|
+
// sample is just plain string return it
|
|
408
|
+
return sample
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// recover missing type
|
|
413
|
+
if(!schema) {
|
|
414
|
+
type = Array.isArray(sample) ? "array" : typeof sample
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// generate xml sample recursively for array case
|
|
418
|
+
if(type === "array") {
|
|
419
|
+
if (!Array.isArray(sample)) {
|
|
420
|
+
if(typeof sample === "string") {
|
|
421
|
+
return sample
|
|
422
|
+
}
|
|
423
|
+
sample = [sample]
|
|
424
|
+
}
|
|
425
|
+
const itemSchema = schema
|
|
426
|
+
? schema.items
|
|
427
|
+
: undefined
|
|
428
|
+
if(itemSchema) {
|
|
429
|
+
itemSchema.xml = itemSchema.xml || xml || {}
|
|
430
|
+
itemSchema.xml.name = itemSchema.xml.name || xml.name
|
|
431
|
+
}
|
|
432
|
+
let itemSamples = sample
|
|
433
|
+
.map(s => sampleFromSchemaGeneric(itemSchema, config, s, respectXML))
|
|
434
|
+
itemSamples = handleMinMaxItems(itemSamples)
|
|
435
|
+
if(xml.wrapped) {
|
|
436
|
+
res[displayName] = itemSamples
|
|
437
|
+
if (!isEmpty(_attr)) {
|
|
438
|
+
res[displayName].push({_attr: _attr})
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
res = itemSamples
|
|
443
|
+
}
|
|
444
|
+
return res
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// generate xml sample recursively for object case
|
|
448
|
+
if(type === "object") {
|
|
449
|
+
// case literal example
|
|
450
|
+
if(typeof sample === "string") {
|
|
451
|
+
return sample
|
|
452
|
+
}
|
|
453
|
+
for (let propName in sample) {
|
|
454
|
+
if (!Object.prototype.hasOwnProperty.call(sample, propName)) {
|
|
455
|
+
continue
|
|
456
|
+
}
|
|
457
|
+
if (schema && props[propName] && props[propName].readOnly && !includeReadOnly) {
|
|
458
|
+
continue
|
|
459
|
+
}
|
|
460
|
+
if (schema && props[propName] && props[propName].writeOnly && !includeWriteOnly) {
|
|
461
|
+
continue
|
|
462
|
+
}
|
|
463
|
+
if (schema && props[propName] && props[propName].xml && props[propName].xml.attribute) {
|
|
464
|
+
_attr[props[propName].xml.name || propName] = sample[propName]
|
|
465
|
+
continue
|
|
466
|
+
}
|
|
467
|
+
addPropertyToResult(propName, sample[propName])
|
|
468
|
+
}
|
|
469
|
+
if (!isEmpty(_attr)) {
|
|
470
|
+
res[displayName].push({_attr: _attr})
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
return res
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
res[displayName] = !isEmpty(_attr) ? [{_attr: _attr}, sample] : sample
|
|
477
|
+
return res
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// use schema to generate sample
|
|
481
|
+
|
|
482
|
+
if(type === "object") {
|
|
483
|
+
for (let propName in props) {
|
|
484
|
+
if (!Object.prototype.hasOwnProperty.call(props, propName)) {
|
|
485
|
+
continue
|
|
486
|
+
}
|
|
487
|
+
if ( props[propName] && props[propName].deprecated ) {
|
|
488
|
+
continue
|
|
489
|
+
}
|
|
490
|
+
if ( props[propName] && props[propName].readOnly && !includeReadOnly ) {
|
|
491
|
+
continue
|
|
492
|
+
}
|
|
493
|
+
if ( props[propName] && props[propName].writeOnly && !includeWriteOnly ) {
|
|
494
|
+
continue
|
|
495
|
+
}
|
|
496
|
+
addPropertyToResult(propName)
|
|
497
|
+
}
|
|
498
|
+
if (respectXML && _attr) {
|
|
499
|
+
res[displayName].push({_attr: _attr})
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if(hasExceededMaxProperties()) {
|
|
503
|
+
return res
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
if ( additionalProperties === true ) {
|
|
507
|
+
if(respectXML) {
|
|
508
|
+
res[displayName].push({additionalProp: "Anything can be here"})
|
|
509
|
+
} else {
|
|
510
|
+
res.additionalProp1 = {}
|
|
511
|
+
}
|
|
512
|
+
propertyAddedCounter++
|
|
513
|
+
} else if ( additionalProperties ) {
|
|
514
|
+
const additionalProps = objectify(additionalProperties)
|
|
515
|
+
const additionalPropSample = sampleFromSchemaGeneric(additionalProps, config, undefined, respectXML)
|
|
516
|
+
|
|
517
|
+
if(respectXML && additionalProps.xml && additionalProps.xml.name && additionalProps.xml.name !== "notagname")
|
|
518
|
+
{
|
|
519
|
+
res[displayName].push(additionalPropSample)
|
|
520
|
+
} else {
|
|
521
|
+
const keyName = additionalProps["x-additionalPropertiesName"] || "additionalProp"
|
|
522
|
+
const toGenerateCount = schema.minProperties !== null && schema.minProperties !== undefined && propertyAddedCounter < schema.minProperties
|
|
523
|
+
? schema.minProperties - propertyAddedCounter
|
|
524
|
+
: 3
|
|
525
|
+
for (let i = 1; i <= toGenerateCount; i++) {
|
|
526
|
+
if(hasExceededMaxProperties()) {
|
|
527
|
+
return res
|
|
528
|
+
}
|
|
529
|
+
if(respectXML) {
|
|
530
|
+
const temp = {}
|
|
531
|
+
temp[keyName + i] = additionalPropSample["notagname"]
|
|
532
|
+
res[displayName].push(temp)
|
|
533
|
+
} else {
|
|
534
|
+
res[keyName + i] = additionalPropSample
|
|
535
|
+
}
|
|
536
|
+
propertyAddedCounter++
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return res
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
if(type === "array") {
|
|
544
|
+
if (!items) {
|
|
545
|
+
return
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
let sampleArray
|
|
549
|
+
if(respectXML) {
|
|
550
|
+
items.xml = items.xml || schema?.xml || {}
|
|
551
|
+
items.xml.name = items.xml.name || xml.name
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
if(Array.isArray(items.anyOf)) {
|
|
555
|
+
sampleArray = items.anyOf.map(i => sampleFromSchemaGeneric(mergeJsonSchema(i, items, config), config, undefined, respectXML))
|
|
556
|
+
} else if(Array.isArray(items.oneOf)) {
|
|
557
|
+
sampleArray = items.oneOf.map(i => sampleFromSchemaGeneric(mergeJsonSchema(i, items, config), config, undefined, respectXML))
|
|
558
|
+
} else if(!respectXML || respectXML && xml.wrapped) {
|
|
559
|
+
sampleArray = [sampleFromSchemaGeneric(items, config, undefined, respectXML)]
|
|
560
|
+
} else {
|
|
561
|
+
return sampleFromSchemaGeneric(items, config, undefined, respectXML)
|
|
562
|
+
}
|
|
563
|
+
sampleArray = handleMinMaxItems(sampleArray)
|
|
564
|
+
if(respectXML && xml.wrapped) {
|
|
565
|
+
res[displayName] = sampleArray
|
|
566
|
+
if (!isEmpty(_attr)) {
|
|
567
|
+
res[displayName].push({_attr: _attr})
|
|
568
|
+
}
|
|
569
|
+
return res
|
|
570
|
+
}
|
|
571
|
+
return sampleArray
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
let value
|
|
575
|
+
if (schema && Array.isArray(schema.enum)) {
|
|
576
|
+
//display enum first value
|
|
577
|
+
value = normalizeArray(schema.enum)[0]
|
|
578
|
+
} else if(schema) {
|
|
579
|
+
// display schema default
|
|
580
|
+
value = primitive(schema)
|
|
581
|
+
if(typeof value === "number") {
|
|
582
|
+
let min = schema.minimum
|
|
583
|
+
if(min !== undefined && min !== null) {
|
|
584
|
+
if(schema.exclusiveMinimum) {
|
|
585
|
+
min++
|
|
586
|
+
}
|
|
587
|
+
value = min
|
|
588
|
+
}
|
|
589
|
+
let max = schema.maximum
|
|
590
|
+
if(max !== undefined && max !== null) {
|
|
591
|
+
if(schema.exclusiveMaximum) {
|
|
592
|
+
max--
|
|
593
|
+
}
|
|
594
|
+
value = max
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if(typeof value === "string") {
|
|
598
|
+
if (schema.maxLength !== null && schema.maxLength !== undefined) {
|
|
599
|
+
value = value.slice(0, schema.maxLength)
|
|
600
|
+
}
|
|
601
|
+
if (schema.minLength !== null && schema.minLength !== undefined) {
|
|
602
|
+
let i = 0
|
|
603
|
+
while (value.length < schema.minLength) {
|
|
604
|
+
value += value[i++ % value.length]
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
} else {
|
|
609
|
+
return
|
|
610
|
+
}
|
|
611
|
+
if (type === "file") {
|
|
612
|
+
return
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if(respectXML) {
|
|
616
|
+
res[displayName] = !isEmpty(_attr) ? [{_attr: _attr}, value] : value
|
|
617
|
+
return res
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
return value
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export const inferSchema = (thing) => {
|
|
624
|
+
if(thing.schema)
|
|
625
|
+
thing = thing.schema
|
|
626
|
+
|
|
627
|
+
if(thing.properties) {
|
|
628
|
+
thing.type = "object"
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return thing // Hopefully this will have something schema like in it... `type` for example
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
export const createXMLExample = (schema, config, o) => {
|
|
635
|
+
const json = sampleFromSchemaGeneric(schema, config, o, true)
|
|
636
|
+
if (!json) { return }
|
|
637
|
+
if(typeof json === "string") {
|
|
638
|
+
return json
|
|
639
|
+
}
|
|
640
|
+
return XML(json, { declaration: true, indent: "\t" })
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
export const sampleFromSchema = (schema, config, o) =>
|
|
645
|
+
sampleFromSchemaGeneric(schema, config, o, false)
|
|
646
|
+
|
|
647
|
+
const resolver = (arg1, arg2, arg3) => [arg1, JSON.stringify(arg2), JSON.stringify(arg3)]
|
|
648
|
+
|
|
649
|
+
export const memoizedCreateXMLExample = memoizeN(createXMLExample, resolver)
|
|
650
|
+
|
|
651
|
+
export const memoizedSampleFromSchema = memoizeN(sampleFromSchema, resolver)
|
|
652
|
+
|
|
653
|
+
export const getSchemaObjectType = (schema) => immutableToJS(schema)?.type ?? "string"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @prettier
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
sampleFromSchema,
|
|
6
|
+
inferSchema,
|
|
7
|
+
sampleFromSchemaGeneric,
|
|
8
|
+
createXMLExample,
|
|
9
|
+
memoizedCreateXMLExample,
|
|
10
|
+
memoizedSampleFromSchema,
|
|
11
|
+
mergeJsonSchema,
|
|
12
|
+
getSchemaObjectType,
|
|
13
|
+
} from "./fn/index"
|
|
14
|
+
import makeGetJsonSampleSchema from "./fn/get-json-sample-schema"
|
|
15
|
+
import makeGetYamlSampleSchema from "./fn/get-yaml-sample-schema"
|
|
16
|
+
import makeGetXmlSampleSchema from "./fn/get-xml-sample-schema"
|
|
17
|
+
import makeGetSampleSchema from "./fn/get-sample-schema"
|
|
18
|
+
|
|
19
|
+
const JSONSchema5SamplesPlugin = ({ getSystem }) => {
|
|
20
|
+
const getJsonSampleSchema = makeGetJsonSampleSchema(getSystem)
|
|
21
|
+
const getYamlSampleSchema = makeGetYamlSampleSchema(getSystem)
|
|
22
|
+
const getXmlSampleSchema = makeGetXmlSampleSchema(getSystem)
|
|
23
|
+
const getSampleSchema = makeGetSampleSchema(getSystem)
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
fn: {
|
|
27
|
+
jsonSchema5: {
|
|
28
|
+
inferSchema,
|
|
29
|
+
sampleFromSchema,
|
|
30
|
+
sampleFromSchemaGeneric,
|
|
31
|
+
createXMLExample,
|
|
32
|
+
memoizedSampleFromSchema,
|
|
33
|
+
memoizedCreateXMLExample,
|
|
34
|
+
getJsonSampleSchema,
|
|
35
|
+
getYamlSampleSchema,
|
|
36
|
+
getXmlSampleSchema,
|
|
37
|
+
getSampleSchema,
|
|
38
|
+
mergeJsonSchema,
|
|
39
|
+
},
|
|
40
|
+
inferSchema,
|
|
41
|
+
sampleFromSchema,
|
|
42
|
+
sampleFromSchemaGeneric,
|
|
43
|
+
createXMLExample,
|
|
44
|
+
memoizedSampleFromSchema,
|
|
45
|
+
memoizedCreateXMLExample,
|
|
46
|
+
getJsonSampleSchema,
|
|
47
|
+
getYamlSampleSchema,
|
|
48
|
+
getXmlSampleSchema,
|
|
49
|
+
getSampleSchema,
|
|
50
|
+
mergeJsonSchema,
|
|
51
|
+
getSchemaObjectType,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default JSONSchema5SamplesPlugin
|