diff --git a/.browserslistrc b/.browserslistrc
new file mode 100644
index 00000000000..89a3d87c6b5
--- /dev/null
+++ b/.browserslistrc
@@ -0,0 +1,10 @@
+[production]
+> 1%
+last 2 versions
+Firefox ESR
+not dead
+
+[development]
+last 1 chrome version
+last 1 firefox version
+last 1 safari version
diff --git a/babel.config.js b/babel.config.js
index 4d144301736..510e8189c76 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,56 +1,89 @@
module.exports = {
"env": {
- "commonjs": {
+ "esm": {
"presets": [
[
- "@babel/preset-env",
+ "@babel/env",
{
- "debug": false,
- "modules": "commonjs",
- "targets": {
- "node": "8"
- },
- "forceAllTransforms": false,
- "ignoreBrowserslistConfig": true
+ "debug": true,
+ "modules": false,
+ "ignoreBrowserslistConfig": false,
+ "useBuiltIns": false,
+ "include": [
+ "@babel/plugin-proposal-logical-assignment-operators"
+ ]
}
],
- "@babel/preset-react",
+ "@babel/preset-react"
],
"plugins": [
[
- "@babel/plugin-transform-modules-commonjs",
+ "@babel/plugin-transform-runtime",
+ {
+ "corejs": 3,
+ "absoluteRuntime": false,
+ "version": "^7.11.2"
+ }
+ ],
+ [
+ "transform-react-remove-prop-types",
{
- "loose": true
+ "additionalLibraries": [
+ "react-immutable-proptypes"
+ ]
}
],
- "@babel/proposal-class-properties",
- "@babel/proposal-object-rest-spread",
- "@babel/plugin-proposal-optional-chaining",
+ [
+ "babel-plugin-module-resolver",
+ {
+ "alias": {
+ "root": ".",
+ "core": "./src/core",
+ }
+ }
+ ]
]
},
- "es": {
+ "test": {
"presets": [
[
- "@babel/preset-env",
+ "@babel/env",
{
- "debug": false,
- "modules": false
+ "targets": {
+ "node": "16.13.2"
+ },
+ "ignoreBrowserslistConfig": true,
+ "useBuiltIns": false,
}
],
- "@babel/preset-react",
+ "@babel/preset-react"
],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
- "absoluteRuntime": false,
"corejs": 3,
+ "absoluteRuntime": false,
"version": "^7.11.2"
}
],
- "@babel/proposal-class-properties",
- "@babel/proposal-object-rest-spread",
- "@babel/plugin-proposal-optional-chaining",
+ [
+ "transform-react-remove-prop-types",
+ {
+ "additionalLibraries": [
+ "react-immutable-proptypes"
+ ]
+ }
+ ],
+ [
+ "babel-plugin-module-resolver",
+ {
+ "alias": {
+ "root": ".",
+ "core": "./src/core",
+ }
+ }
+ ]
]
},
"development": {
@@ -58,17 +91,8 @@ module.exports = {
[
"@babel/env",
{
- "targets": {
- "browsers": [
- /* benefit of C/S/FF/Edge only? */
- "> 1%",
- "last 2 versions",
- "Firefox ESR",
- "not dead"
- ]
- },
+ "ignoreBrowserslistConfig": false,
"useBuiltIns": false,
- "corejs": { version: 3 },
"include": [
"@babel/plugin-proposal-logical-assignment-operators"
]
@@ -85,8 +109,6 @@ module.exports = {
"version": "^7.11.2"
}
],
- "@babel/plugin-proposal-class-properties",
- "@babel/plugin-proposal-optional-chaining",
[
"transform-react-remove-prop-types",
{
@@ -100,33 +122,31 @@ module.exports = {
{
"alias": {
"root": ".",
- "components": "./src/core/components",
- "containers": "./src/core/containers",
"core": "./src/core",
- "plugins": "./src/plugins",
- "img": "./src/img",
- "corePlugins": "./src/core/plugins",
- "less": "./src/less"
}
}
]
]
},
- "test": {
+ "production": {
"presets": [
[
"@babel/env",
{
- "targets": {
- "node": "10"
- },
+ "ignoreBrowserslistConfig": false,
"useBuiltIns": false,
- "corejs": { version: 3 }
+ "include": [
+ "@babel/plugin-proposal-logical-assignment-operators"
+ ]
}
],
"@babel/preset-react"
],
"plugins": [
+ "@babel/plugin-transform-class-properties",
+ "@babel/plugin-transform-nullish-coalescing-operator",
+ "@babel/plugin-transform-object-rest-spread",
+ "@babel/plugin-transform-optional-chaining",
[
"@babel/plugin-transform-runtime",
{
@@ -135,8 +155,6 @@ module.exports = {
"version": "^7.11.2"
}
],
- "@babel/plugin-proposal-class-properties",
- "@babel/plugin-proposal-optional-chaining",
[
"transform-react-remove-prop-types",
{
@@ -150,18 +168,12 @@ module.exports = {
{
"alias": {
"root": ".",
- "components": "./src/core/components",
- "containers": "./src/core/containers",
"core": "./src/core",
- "plugins": "./src/plugins",
- "img": "./src/img",
- "corePlugins": "./src/core/plugins",
- "less": "./src/less"
}
}
]
]
- }
+ },
}
}
diff --git a/config/jest/jest.unit.config.js b/config/jest/jest.unit.config.js
index 7bf24f390cf..9fca4bef852 100644
--- a/config/jest/jest.unit.config.js
+++ b/config/jest/jest.unit.config.js
@@ -19,6 +19,9 @@ module.exports = {
'
content
","application/*":()=>(0,r.bytes)(25).toString("binary")}},4342:(e,t,a)=>{a.r(t),a.d(t,{default:()=>r});var n=a(5202);const r={"audio/*":()=>(0,n.bytes)(25).toString("binary")}},6724:(e,t,a)=>{a.r(t),a.d(t,{default:()=>r});var n=a(5202);const r={"image/*":()=>(0,n.bytes)(25).toString("binary")}},5378:(e,t,a)=>{a.r(t),a.d(t,{default:()=>n});const n={"text/plain":()=>"string","text/css":()=>".selector { border: 1px solid red }","text/csv":()=>"value1,value2,value3","text/html":()=>"content
","text/calendar":()=>"BEGIN:VCALENDAR","text/javascript":()=>"console.dir('Hello world!');","text/xml":()=>'content
", + "text/calendar": () => "BEGIN:VCALENDAR", + "text/javascript": () => "console.dir('Hello world!');", + "text/xml": () => 'content
", + "application/*": () => bytes(25).toString("binary") +}; + +/* harmony default export */ const application = (applicationMediaTypesGenerators); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/class/MediaTypeRegistry.js +function MediaTypeRegistry_classPrivateFieldInitSpec(obj, privateMap, value) {MediaTypeRegistry_checkPrivateRedeclaration(obj, privateMap);privateMap.set(obj, value);}function MediaTypeRegistry_checkPrivateRedeclaration(obj, privateCollection) {if (privateCollection.has(obj)) {throw new TypeError("Cannot initialize the same private elements twice on an object");}} /** + * @prettier + */ + + + + + +var MediaTypeRegistry_defaults = /*#__PURE__*/new WeakMap(); + +class MediaTypeRegistry extends class_Registry {constructor() {super(...arguments);MediaTypeRegistry_classPrivateFieldInitSpec(this, MediaTypeRegistry_defaults, { writable: true, value: (0,objectSpread2_namespaceObject["default"])((0,objectSpread2_namespaceObject["default"])((0,objectSpread2_namespaceObject["default"])((0,objectSpread2_namespaceObject["default"])((0,objectSpread2_namespaceObject["default"])({}, + + media_types_text), + media_types_image), + audio), + video), + application) });(0,defineProperty_namespaceObject["default"])(this, "data", (0,objectSpread2_namespaceObject["default"])({}, (0,classPrivateFieldGet_namespaceObject["default"])( + + + this, MediaTypeRegistry_defaults)));} + + get defaults() { + return (0,objectSpread2_namespaceObject["default"])({}, (0,classPrivateFieldGet_namespaceObject["default"])(this, MediaTypeRegistry_defaults)); + } +} + +/* harmony default export */ const class_MediaTypeRegistry = (MediaTypeRegistry); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/api/mediaTypeAPI.js +/** + * @prettier + */ + + + +const mediaTypeAPI_registry = new class_MediaTypeRegistry(); + +const mediaTypeAPI = (mediaType, generator) => { + if (typeof generator === "function") { + return mediaTypeAPI_registry.register(mediaType, generator); + } else if (generator === null) { + return mediaTypeAPI_registry.unregister(mediaType); + } + + const mediaTypeNoParams = mediaType.split(";").at(0); + const topLevelMediaType = `${mediaTypeNoParams.split("/").at(0)}/*`; + + return ( + mediaTypeAPI_registry.get(mediaType) || + mediaTypeAPI_registry.get(mediaTypeNoParams) || + mediaTypeAPI_registry.get(topLevelMediaType)); + +}; +mediaTypeAPI.getDefaults = () => mediaTypeAPI_registry.defaults; + +/* harmony default export */ const api_mediaTypeAPI = (mediaTypeAPI); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/types/string.js +/** + * @prettier + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +const generateFormat = (schema) => { + const { format } = schema; + + const formatGenerator = api_formatAPI(format); + if (typeof formatGenerator === "function") { + return formatGenerator(schema); + } + + switch (format) { + case "email":{ + return email(); + } + case "idn-email":{ + return idn_email(); + } + case "hostname":{ + return hostname(); + } + case "idn-hostname":{ + return idn_hostname(); + } + case "ipv4":{ + return ipv4(); + } + case "ipv6":{ + return ipv6(); + } + case "uri":{ + return uri(); + } + case "uri-reference":{ + return uri_reference(); + } + case "iri":{ + return iri(); + } + case "iri-reference":{ + return iri_reference(); + } + case "uuid":{ + return uuid(); + } + case "uri-template":{ + return uri_template(); + } + case "json-pointer":{ + return json_pointer(); + } + case "relative-json-pointer":{ + return relative_json_pointer(); + } + case "date-time":{ + return date_time(); + } + case "date":{ + return date(); + } + case "time":{ + return time(); + } + case "duration":{ + return duration(); + } + case "password":{ + return generators_password(); + } + case "regex":{ + return regex(); + } + } + + return string(); +}; + +const applyStringConstraints = function (string) {let constraints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + const { maxLength, minLength } = constraints; + let constrainedString = string; + + if (Number.isInteger(maxLength) && maxLength > 0) { + constrainedString = constrainedString.slice(0, maxLength); + } + if (Number.isInteger(minLength) && minLength > 0) { + let i = 0; + while (constrainedString.length < minLength) { + constrainedString += constrainedString[i++ % constrainedString.length]; + } + } + + return constrainedString; +}; +const stringType = function (schema) {let { sample } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + const { contentEncoding, contentMediaType, contentSchema } = schema; + const { pattern, format } = schema; + const encode = api_encoderAPI(contentEncoding) || identity_namespaceObject["default"]; + let generatedString; + + if (typeof pattern === "string") { + generatedString = randexp(pattern); + } else if (typeof format === "string") { + generatedString = generateFormat(schema); + } else if ( + isJSONSchema(contentSchema) && + typeof contentMediaType === "string" && + typeof sample !== "undefined") + { + if (Array.isArray(sample) || typeof sample === "object") { + generatedString = JSON.stringify(sample); + } else { + generatedString = String(sample); + } + } else if (typeof contentMediaType === "string") { + const mediaTypeGenerator = api_mediaTypeAPI(contentMediaType); + if (typeof mediaTypeGenerator === "function") { + generatedString = mediaTypeGenerator(schema); + } + } else { + generatedString = string(); + } + + return encode(applyStringConstraints(generatedString, schema)); +}; + +/* harmony default export */ const types_string = (stringType); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/generators/float.js +/** + * @prettier + */ +const floatGenerator = () => 0.1; + +/* harmony default export */ const generators_float = (floatGenerator); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/generators/double.js +/** + * @prettier + */ +const doubleGenerator = () => 0.1; + +/* harmony default export */ const generators_double = (doubleGenerator); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/types/number.js +/** + * @prettier + */ + + + + + +const number_generateFormat = (schema) => { + const { format } = schema; + + const formatGenerator = api_formatAPI(format); + if (typeof formatGenerator === "function") { + return formatGenerator(schema); + } + + switch (format) { + case "float":{ + return generators_float(); + } + case "double":{ + return generators_double(); + } + } + + return number(); +}; + +const applyNumberConstraints = function (number) {let constraints = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + const { minimum, maximum, exclusiveMinimum, exclusiveMaximum } = constraints; + const { multipleOf } = constraints; + const epsilon = Number.isInteger(number) ? 1 : Number.EPSILON; + let minValue = typeof minimum === "number" ? minimum : null; + let maxValue = typeof maximum === "number" ? maximum : null; + let constrainedNumber = number; + + if (typeof exclusiveMinimum === "number") { + minValue = + minValue !== null ? + Math.max(minValue, exclusiveMinimum + epsilon) : + exclusiveMinimum + epsilon; + } + if (typeof exclusiveMaximum === "number") { + maxValue = + maxValue !== null ? + Math.min(maxValue, exclusiveMaximum - epsilon) : + exclusiveMaximum - epsilon; + } + constrainedNumber = + minValue > maxValue && number || minValue || maxValue || constrainedNumber; + + if (typeof multipleOf === "number" && multipleOf > 0) { + const remainder = constrainedNumber % multipleOf; + constrainedNumber = + remainder === 0 ? + constrainedNumber : + constrainedNumber + multipleOf - remainder; + } + + return constrainedNumber; +}; + +const numberType = (schema) => { + const { format } = schema; + let generatedNumber; + + if (typeof format === "string") { + generatedNumber = number_generateFormat(schema); + } else { + generatedNumber = number(); + } + + return applyNumberConstraints(generatedNumber, schema); +}; + +/* harmony default export */ const types_number = (numberType); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/generators/int32.js +/** + * @prettier + */ +const int32Generator = () => 2 ** 30 >>> 0; + +/* harmony default export */ const int32 = (int32Generator); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/generators/int64.js +/** + * @prettier + */ +const int64Generator = () => 2 ** 53 - 1; + +/* harmony default export */ const int64 = (int64Generator); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/types/integer.js +/** + * @prettier + */ + + + + + +const integer_generateFormat = (schema) => { + const { format } = schema; + + const formatGenerator = api_formatAPI(format); + if (typeof formatGenerator === "function") { + return formatGenerator(schema); + } + + switch (format) { + case "int32":{ + return int32(); + } + case "int64":{ + return int64(); + } + } + + return integer(); +}; +const integerType = (schema) => { + const { format } = schema; + + if (typeof format === "string") { + return integer_generateFormat(schema); + } + + return integer(); +}; + +/* harmony default export */ const types_integer = (integerType); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/types/boolean.js +/** + * @prettier + */ + +const booleanType = (schema) => { + return typeof schema.default === "boolean" ? schema.default : true; +}; + +/* harmony default export */ const types_boolean = (booleanType); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/types/null.js +/** + * @prettier + */ + +const nullType = () => { + return null; +}; + +/* harmony default export */ const types_null = (nullType); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/types/index.js +/** + * @prettier + */ + + + + + + + + +const typeMap = { + array: array, + object: object, + string: types_string, + number: types_number, + integer: types_integer, + boolean: types_boolean, + null: types_null +}; + +/* harmony default export */ const types = (new Proxy(typeMap, { + get(target, prop) { + if (typeof prop === "string" && Object.hasOwn(target, prop)) { + return target[prop]; + } + + return () => `Unknown Type: ${prop}`; + } +})); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/core/constants.js +/** + * @prettier + */ +const SCALAR_TYPES = ["number", "integer", "string", "boolean", "null"]; + +const ALL_TYPES = ["array", "object", ...SCALAR_TYPES]; +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/core/example.js +/** + * @prettier + */ + + +/** + * Precedence of keywords that provides author defined values (top of the list = higher priority) + * + * ### examples + * Array containing example values for the item defined by the schema. + * Not guaranteed to be valid or invalid against the schema + * + * ### default + * Default value for an item defined by the schema. + * Is expected to be a valid instance of the schema. + * + * ### example + * Deprecated. Part of OpenAPI 3.1.0 Schema Object dialect. + * Represents single example. Equivalent of `examples` keywords + * with single item. + */ + +const hasExample = (schema) => { + if (!isJSONSchemaObject(schema)) return false; + + const { examples, example, default: defaultVal } = schema; + + if (Array.isArray(examples) && examples.length >= 1) { + return true; + } + + if (typeof defaultVal !== "undefined") { + return true; + } + + return typeof example !== "undefined"; +}; + +const extractExample = (schema) => { + if (!isJSONSchemaObject(schema)) return null; + + const { examples, example, default: defaultVal } = schema; + + if (Array.isArray(examples) && examples.length >= 1) { + return examples.at(0); + } + + if (typeof defaultVal !== "undefined") { + return defaultVal; + } + + if (typeof example !== "undefined") { + return example; + } + + return undefined; +}; +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/core/type.js +/** + * @prettier + */ + + + + + +const inferringKeywords = { + array: [ + "items", + "prefixItems", + "contains", + "maxContains", + "minContains", + "maxItems", + "minItems", + "uniqueItems", + "unevaluatedItems"], + + object: [ + "properties", + "additionalProperties", + "patternProperties", + "propertyNames", + "minProperties", + "maxProperties", + "required", + "dependentSchemas", + "dependentRequired", + "unevaluatedProperties"], + + string: [ + "pattern", + "format", + "minLength", + "maxLength", + "contentEncoding", + "contentMediaType", + "contentSchema"], + + integer: [ + "minimum", + "maximum", + "exclusiveMinimum", + "exclusiveMaximum", + "multipleOf"] + +}; +inferringKeywords.number = inferringKeywords.integer; + +const fallbackType = "string"; + +const inferTypeFromValue = (value) => { + if (typeof value === "undefined") return null; + if (value === null) return "null"; + if (Array.isArray(value)) return "array"; + if (Number.isInteger(value)) return "integer"; + + return typeof value; +}; + +const foldType = (type) => { + if (Array.isArray(type) && type.length >= 1) { + if (type.includes("array")) { + return "array"; + } else if (type.includes("object")) { + return "object"; + } else { + const pickedType = pick(type); + if (ALL_TYPES.includes(pickedType)) { + return pickedType; + } + } + } + + if (ALL_TYPES.includes(type)) { + return type; + } + + return null; +}; + +const inferType = function (schema) {let processedSchemas = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakSet(); + if (!isJSONSchemaObject(schema)) return fallbackType; + if (processedSchemas.has(schema)) return fallbackType; + + processedSchemas.add(schema); + + let { type, const: constant } = schema; + type = foldType(type); + + // inferring type from inferring keywords + if (typeof type !== "string") { + const inferringTypes = Object.keys(inferringKeywords); + + interrupt: for (let i = 0; i < inferringTypes.length; i += 1) { + const inferringType = inferringTypes[i]; + const inferringTypeKeywords = inferringKeywords[inferringType]; + + for (let j = 0; j < inferringTypeKeywords.length; j += 1) { + const inferringKeyword = inferringTypeKeywords[j]; + if (Object.hasOwn(schema, inferringKeyword)) { + type = inferringType; + break interrupt; + } + } + } + } + + // inferring type from const keyword + if (typeof type !== "string" && typeof constant !== "undefined") { + const constType = inferTypeFromValue(constant); + type = typeof constType === "string" ? constType : type; + } + + // inferring type from combining schemas + if (typeof type !== "string") { + const combineTypes = (keyword) => { + if (Array.isArray(schema[keyword])) { + const combinedTypes = schema[keyword].map((subSchema) => + inferType(subSchema, processedSchemas) + ); + return foldType(combinedTypes); + } + return null; + }; + + const allOf = combineTypes("allOf"); + const anyOf = combineTypes("anyOf"); + const oneOf = combineTypes("oneOf"); + const not = schema.not ? inferType(schema.not, processedSchemas) : null; + + if (allOf || anyOf || oneOf || not) { + type = foldType([allOf, anyOf, oneOf, not].filter(Boolean)); + } + } + + // inferring type from example + if (typeof type !== "string" && hasExample(schema)) { + const example = extractExample(schema); + const exampleType = inferTypeFromValue(example); + type = typeof exampleType === "string" ? exampleType : type; + } + + processedSchemas.delete(schema); + + return type || fallbackType; +}; + +const type_getType = (schema) => { + return inferType(schema); +}; +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/core/utils.js +/** + * @prettier + */ + + +const fromJSONBooleanSchema = (schema) => { + if (schema === false) { + return { not: {} }; + } + + return {}; +}; + +const typeCast = (schema) => { + if (predicates_isBooleanJSONSchema(schema)) { + return fromJSONBooleanSchema(schema); + } + if (!isJSONSchemaObject(schema)) { + return {}; + } + + return schema; +}; +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/core/merge.js + /** + * @prettier + */ + + + +const merge = function (target, source) {let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + if (predicates_isBooleanJSONSchema(target) && target === true) return true; + if (predicates_isBooleanJSONSchema(target) && target === false) return false; + if (predicates_isBooleanJSONSchema(source) && source === true) return true; + if (predicates_isBooleanJSONSchema(source) && source === false) return false; + + if (!isJSONSchema(target)) return source; + if (!isJSONSchema(source)) return target; + + /** + * Merging properties from the source object into the target object + * only if they do not already exist in the target object. + */ + const merged = (0,objectSpread2_namespaceObject["default"])((0,objectSpread2_namespaceObject["default"])({}, source), target); + + // merging the type keyword + if (source.type && target.type) { + if (Array.isArray(source.type) && typeof source.type === "string") { + const mergedType = normalizeArray(source.type).concat(target.type); + merged.type = Array.from(new Set(mergedType)); + } + } + + // merging required keyword + if (Array.isArray(source.required) && Array.isArray(target.required)) { + merged.required = [...new Set([...target.required, ...source.required])]; + } + + // merging properties keyword + if (source.properties && target.properties) { + const allPropertyNames = new Set([ + ...Object.keys(source.properties), + ...Object.keys(target.properties)] + ); + + merged.properties = {}; + for (const name of allPropertyNames) { + const sourceProperty = source.properties[name] || {}; + const targetProperty = target.properties[name] || {}; + + if ( + sourceProperty.readOnly && !config.includeReadOnly || + sourceProperty.writeOnly && !config.includeWriteOnly) + { + merged.required = (merged.required || []).filter((p) => p !== name); + } else { + merged.properties[name] = merge(targetProperty, sourceProperty, config); + } + } + } + + // merging items keyword + if (isJSONSchema(source.items) && isJSONSchema(target.items)) { + merged.items = merge(target.items, source.items, config); + } + + // merging contains keyword + if (isJSONSchema(source.contains) && isJSONSchema(target.contains)) { + merged.contains = merge(target.contains, source.contains, config); + } + + // merging contentSchema keyword + if ( + isJSONSchema(source.contentSchema) && + isJSONSchema(target.contentSchema)) + { + merged.contentSchema = merge( + target.contentSchema, + source.contentSchema, + config + ); + } + + return merged; +}; + +/* harmony default export */ const core_merge = (merge); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/main.js +/** + * @prettier + */ + + + + + + + + + + + + + + +const main_sampleFromSchemaGeneric = function ( +schema) + + + +{var _schema;let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};let exampleOverride = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;let respectXML = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; + if (typeof ((_schema = schema) === null || _schema === void 0 ? void 0 : _schema.toJS) === "function") schema = schema.toJS(); + schema = typeCast(schema); + + let usePlainValue = exampleOverride !== undefined || hasExample(schema); + // first check if there is the need of combining this schema with others required by allOf + const hasOneOf = + !usePlainValue && Array.isArray(schema.oneOf) && schema.oneOf.length > 0; + const hasAnyOf = + !usePlainValue && Array.isArray(schema.anyOf) && schema.anyOf.length > 0; + if (!usePlainValue && (hasOneOf || hasAnyOf)) { + const schemaToAdd = typeCast( + hasOneOf ? pick(schema.oneOf) : pick(schema.anyOf) + ); + schema = core_merge(schema, schemaToAdd, config); + if (!schema.xml && schemaToAdd.xml) { + schema.xml = schemaToAdd.xml; + } + if (hasExample(schema) && hasExample(schemaToAdd)) { + usePlainValue = true; + } + } + const _attr = {}; + let { xml, properties, additionalProperties, items, contains } = schema || {}; + let type = type_getType(schema); + let { includeReadOnly, includeWriteOnly } = config; + xml = xml || {}; + let { name, prefix, namespace } = xml; + let displayName; + let res = {}; + + if (!Object.hasOwn(schema, "type")) { + schema.type = type; + } + + // set xml naming and attributes + if (respectXML) { + name = name || "notagname"; + // add prefix to name if exists + displayName = (prefix ? `${prefix}:` : "") + name; + if (namespace) { + //add prefix to namespace if exists + let namespacePrefix = prefix ? `xmlns:${prefix}` : "xmlns"; + _attr[namespacePrefix] = namespace; + } + } + + // init xml default response sample obj + if (respectXML) { + res[displayName] = []; + } + + // add to result helper init for xml or json + const props = objectify(properties); + let addPropertyToResult; + let propertyAddedCounter = 0; + + const hasExceededMaxProperties = () => + Number.isInteger(schema.maxProperties) && + schema.maxProperties > 0 && + propertyAddedCounter >= schema.maxProperties; + + const requiredPropertiesToAdd = () => { + if (!Array.isArray(schema.required) || schema.required.length === 0) { + return 0; + } + let addedCount = 0; + if (respectXML) { + schema.required.forEach( + (key) => addedCount += res[key] === undefined ? 0 : 1 + ); + } else { + schema.required.forEach((key) => {var _res$displayName; + addedCount += + ((_res$displayName = res[displayName]) === null || _res$displayName === void 0 ? void 0 : _res$displayName.find((x) => x[key] !== undefined)) === undefined ? + 0 : + 1; + }); + } + return schema.required.length - addedCount; + }; + + const isOptionalProperty = (propName) => { + if (!Array.isArray(schema.required)) return true; + if (schema.required.length === 0) return true; + + return !schema.required.includes(propName); + }; + + const canAddProperty = (propName) => { + if (!(Number.isInteger(schema.maxProperties) && schema.maxProperties > 0)) { + return true; + } + if (hasExceededMaxProperties()) { + return false; + } + if (!isOptionalProperty(propName)) { + return true; + } + return ( + schema.maxProperties - propertyAddedCounter - requiredPropertiesToAdd() > + 0); + + }; + + if (respectXML) { + addPropertyToResult = function (propName) {let overrideE = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; + if (schema && props[propName]) { + // case it is a xml attribute + props[propName].xml = props[propName].xml || {}; + + if (props[propName].xml.attribute) { + const enumAttrVal = Array.isArray(props[propName].enum) ? + pick(props[propName].enum) : + undefined; + if (hasExample(props[propName])) { + _attr[props[propName].xml.name || propName] = extractExample( + props[propName] + ); + } else if (enumAttrVal !== undefined) { + _attr[props[propName].xml.name || propName] = enumAttrVal; + } else { + const propSchema = typeCast(props[propName]); + const propSchemaType = type_getType(propSchema); + const attrName = props[propName].xml.name || propName; + _attr[attrName] = types[propSchemaType](propSchema); + } + + return; + } + props[propName].xml.name = props[propName].xml.name || propName; + } else if (!props[propName] && additionalProperties !== false) { + // case only additionalProperty that is not defined in schema + props[propName] = { + xml: { + name: propName + } + }; + } + + let t = main_sampleFromSchemaGeneric( + props[propName], + config, + overrideE, + respectXML + ); + if (!canAddProperty(propName)) { + return; + } + + propertyAddedCounter++; + if (Array.isArray(t)) { + res[displayName] = res[displayName].concat(t); + } else { + res[displayName].push(t); + } + }; + } else { + addPropertyToResult = (propName, overrideE) => {var _schema$discriminator; + if (!canAddProperty(propName)) { + return; + } + if ( + (0,isPlainObject_namespaceObject["default"])((_schema$discriminator = schema.discriminator) === null || _schema$discriminator === void 0 ? void 0 : _schema$discriminator.mapping) && + schema.discriminator.propertyName === propName && + typeof schema.$$ref === "string") + { + for (const pair in schema.discriminator.mapping) { + if (schema.$$ref.search(schema.discriminator.mapping[pair]) !== -1) { + res[propName] = pair; + break; + } + } + } else { + res[propName] = main_sampleFromSchemaGeneric( + props[propName], + config, + overrideE, + respectXML + ); + } + propertyAddedCounter++; + }; + } + + // check for plain value and if found use it to generate sample from it + if (usePlainValue) { + let sample; + if (exampleOverride !== undefined) { + sample = exampleOverride; + } else { + sample = extractExample(schema); + } + + // if json just return + if (!respectXML) { + // spacial case yaml parser can not know about + if (typeof sample === "number" && type === "string") { + return `${sample}`; + } + // return if sample does not need any parsing + if (typeof sample !== "string" || type === "string") { + return sample; + } + // check if sample is parsable or just a plain string + try { + return JSON.parse(sample); + } catch { + // sample is just plain string return it + return sample; + } + } + + // generate xml sample recursively for array case + if (type === "array") { + if (!Array.isArray(sample)) { + if (typeof sample === "string") { + return sample; + } + sample = [sample]; + } + + let itemSamples = []; + + if (isJSONSchemaObject(items)) { + items.xml = items.xml || xml || {}; + items.xml.name = items.xml.name || xml.name; + itemSamples = sample.map((s) => + main_sampleFromSchemaGeneric(items, config, s, respectXML) + ); + } + + if (isJSONSchemaObject(contains)) { + contains.xml = contains.xml || xml || {}; + contains.xml.name = contains.xml.name || xml.name; + itemSamples = [ + main_sampleFromSchemaGeneric(contains, config, undefined, respectXML), + ...itemSamples]; + + } + + itemSamples = types.array(schema, { sample: itemSamples }); + if (xml.wrapped) { + res[displayName] = itemSamples; + if (!(0,isEmpty_namespaceObject["default"])(_attr)) { + res[displayName].push({ _attr: _attr }); + } + } else { + res = itemSamples; + } + return res; + } + + // generate xml sample recursively for object case + if (type === "object") { + // case literal example + if (typeof sample === "string") { + return sample; + } + for (const propName in sample) {var _props$propName, _props$propName2, _props$propName3; + if (!Object.hasOwn(sample, propName)) { + continue; + } + if ((_props$propName = props[propName]) !== null && _props$propName !== void 0 && _props$propName.readOnly && !includeReadOnly) { + continue; + } + if ((_props$propName2 = props[propName]) !== null && _props$propName2 !== void 0 && _props$propName2.writeOnly && !includeWriteOnly) { + continue; + } + if ((_props$propName3 = props[propName]) !== null && _props$propName3 !== void 0 && (_props$propName3 = _props$propName3.xml) !== null && _props$propName3 !== void 0 && _props$propName3.attribute) { + _attr[props[propName].xml.name || propName] = sample[propName]; + continue; + } + addPropertyToResult(propName, sample[propName]); + } + if (!(0,isEmpty_namespaceObject["default"])(_attr)) { + res[displayName].push({ _attr: _attr }); + } + + return res; + } + + res[displayName] = !(0,isEmpty_namespaceObject["default"])(_attr) ? [{ _attr: _attr }, sample] : sample; + return res; + } + + // use schema to generate sample + if (type === "array") { + let sampleArray = []; + + if (isJSONSchemaObject(contains)) { + if (respectXML) { + contains.xml = contains.xml || schema.xml || {}; + contains.xml.name = contains.xml.name || xml.name; + } + + if (Array.isArray(contains.anyOf)) { + sampleArray.push( + ...contains.anyOf.map((anyOfSchema) => + main_sampleFromSchemaGeneric( + core_merge(anyOfSchema, contains, config), + config, + undefined, + respectXML + ) + ) + ); + } else if (Array.isArray(contains.oneOf)) { + sampleArray.push( + ...contains.oneOf.map((oneOfSchema) => + main_sampleFromSchemaGeneric( + core_merge(oneOfSchema, contains, config), + config, + undefined, + respectXML + ) + ) + ); + } else if (!respectXML || respectXML && xml.wrapped) { + sampleArray.push( + main_sampleFromSchemaGeneric(contains, config, undefined, respectXML) + ); + } else { + return main_sampleFromSchemaGeneric(contains, config, undefined, respectXML); + } + } + + if (isJSONSchemaObject(items)) { + if (respectXML) { + items.xml = items.xml || schema.xml || {}; + items.xml.name = items.xml.name || xml.name; + } + + if (Array.isArray(items.anyOf)) { + sampleArray.push( + ...items.anyOf.map((i) => + main_sampleFromSchemaGeneric( + core_merge(i, items, config), + config, + undefined, + respectXML + ) + ) + ); + } else if (Array.isArray(items.oneOf)) { + sampleArray.push( + ...items.oneOf.map((i) => + main_sampleFromSchemaGeneric( + core_merge(i, items, config), + config, + undefined, + respectXML + ) + ) + ); + } else if (!respectXML || respectXML && xml.wrapped) { + sampleArray.push( + main_sampleFromSchemaGeneric(items, config, undefined, respectXML) + ); + } else { + return main_sampleFromSchemaGeneric(items, config, undefined, respectXML); + } + } + + sampleArray = types.array(schema, { sample: sampleArray }); + if (respectXML && xml.wrapped) { + res[displayName] = sampleArray; + if (!(0,isEmpty_namespaceObject["default"])(_attr)) { + res[displayName].push({ _attr: _attr }); + } + return res; + } + + return sampleArray; + } + + if (type === "object") { + for (let propName in props) {var _props$propName4, _props$propName5, _props$propName6; + if (!Object.hasOwn(props, propName)) { + continue; + } + if ((_props$propName4 = props[propName]) !== null && _props$propName4 !== void 0 && _props$propName4.deprecated) { + continue; + } + if ((_props$propName5 = props[propName]) !== null && _props$propName5 !== void 0 && _props$propName5.readOnly && !includeReadOnly) { + continue; + } + if ((_props$propName6 = props[propName]) !== null && _props$propName6 !== void 0 && _props$propName6.writeOnly && !includeWriteOnly) { + continue; + } + addPropertyToResult(propName); + } + if (respectXML && _attr) { + res[displayName].push({ _attr: _attr }); + } + + if (hasExceededMaxProperties()) { + return res; + } + + if (predicates_isBooleanJSONSchema(additionalProperties) && additionalProperties) { + if (respectXML) { + res[displayName].push({ additionalProp: "Anything can be here" }); + } else { + res.additionalProp1 = {}; + } + propertyAddedCounter++; + } else if (isJSONSchemaObject(additionalProperties)) {var _additionalProps$xml, _additionalProps$xml2; + const additionalProps = additionalProperties; + const additionalPropSample = main_sampleFromSchemaGeneric( + additionalProps, + config, + undefined, + respectXML + ); + + if ( + respectXML && + typeof (additionalProps === null || additionalProps === void 0 || (_additionalProps$xml = additionalProps.xml) === null || _additionalProps$xml === void 0 ? void 0 : _additionalProps$xml.name) === "string" && + (additionalProps === null || additionalProps === void 0 || (_additionalProps$xml2 = additionalProps.xml) === null || _additionalProps$xml2 === void 0 ? void 0 : _additionalProps$xml2.name) !== "notagname") + { + res[displayName].push(additionalPropSample); + } else { + const toGenerateCount = + Number.isInteger(schema.minProperties) && + schema.minProperties > 0 && + propertyAddedCounter < schema.minProperties ? + schema.minProperties - propertyAddedCounter : + 3; + for (let i = 1; i <= toGenerateCount; i++) { + if (hasExceededMaxProperties()) { + return res; + } + if (respectXML) { + const temp = {}; + temp["additionalProp" + i] = additionalPropSample["notagname"]; + res[displayName].push(temp); + } else { + res["additionalProp" + i] = additionalPropSample; + } + propertyAddedCounter++; + } + } + } + return res; + } + + let value; + if (typeof schema.const !== "undefined") { + // display const value + value = schema.const; + } else if (schema && Array.isArray(schema.enum)) { + //display enum first value + value = pick(normalizeArray(schema.enum)); + } else { + // display schema default + const contentSample = isJSONSchemaObject(schema.contentSchema) ? + main_sampleFromSchemaGeneric( + schema.contentSchema, + config, + undefined, + respectXML + ) : + undefined; + value = types[type](schema, { sample: contentSample }); + } + + if (respectXML) { + res[displayName] = !(0,isEmpty_namespaceObject["default"])(_attr) ? [{ _attr: _attr }, value] : value; + return res; + } + + return value; +}; + +const main_createXMLExample = (schema, config, o) => { + const json = main_sampleFromSchemaGeneric(schema, config, o, true); + if (!json) { + return; + } + if (typeof json === "string") { + return json; + } + return (0,external_xml_namespaceObject["default"])(json, { declaration: true, indent: "\t" }); +}; + +const main_sampleFromSchema = (schema, config, o) => { + return main_sampleFromSchemaGeneric(schema, config, o, false); +}; + +const main_resolver = (arg1, arg2, arg3) => [ +arg1, +JSON.stringify(arg2), +JSON.stringify(arg3)]; + + +const main_memoizedCreateXMLExample = utils_memoizeN(main_createXMLExample, main_resolver); + +const main_memoizedSampleFromSchema = utils_memoizeN(main_sampleFromSchema, main_resolver); +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/samples-extensions/fn/index.js +/** + * @prettier + */ + + + + + +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/hoc.jsx + /** + * @prettier + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +const withJSONSchemaContext = function (Component) {let overrides = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + const value = { + components: (0,objectSpread2_namespaceObject["default"])({ + JSONSchema: JSONSchema_JSONSchema, + Keyword$schema: keywords_$schema, + Keyword$vocabulary: $vocabulary_$vocabulary, + Keyword$id: keywords_$id, + Keyword$anchor: keywords_$anchor, + Keyword$dynamicAnchor: keywords_$dynamicAnchor, + Keyword$ref: keywords_$ref, + Keyword$dynamicRef: keywords_$dynamicRef, + Keyword$defs: keywords_$defs, + Keyword$comment: keywords_$comment, + KeywordAllOf: keywords_AllOf, + KeywordAnyOf: keywords_AnyOf, + KeywordOneOf: keywords_OneOf, + KeywordNot: keywords_Not, + KeywordIf: keywords_If, + KeywordThen: keywords_Then, + KeywordElse: keywords_Else, + KeywordDependentSchemas: keywords_DependentSchemas, + KeywordPrefixItems: keywords_PrefixItems, + KeywordItems: keywords_Items, + KeywordContains: keywords_Contains, + KeywordProperties: keywords_Properties_Properties, + KeywordPatternProperties: PatternProperties_PatternProperties, + KeywordAdditionalProperties: keywords_AdditionalProperties, + KeywordPropertyNames: keywords_PropertyNames, + KeywordUnevaluatedItems: keywords_UnevaluatedItems, + KeywordUnevaluatedProperties: keywords_UnevaluatedProperties, + KeywordType: keywords_Type, + KeywordEnum: Enum_Enum, + KeywordConst: keywords_Const, + KeywordConstraint: Constraint_Constraint, + KeywordDependentRequired: DependentRequired_DependentRequired, + KeywordContentSchema: keywords_ContentSchema, + KeywordTitle: Title_Title, + KeywordDescription: keywords_Description_Description, + KeywordDefault: keywords_Default, + KeywordDeprecated: keywords_Deprecated, + KeywordReadOnly: keywords_ReadOnly, + KeywordWriteOnly: keywords_WriteOnly, + Accordion: Accordion_Accordion, + ExpandDeepButton: ExpandDeepButton_ExpandDeepButton, + ChevronRightIcon: icons_ChevronRight }, + overrides.components), + + config: (0,objectSpread2_namespaceObject["default"])({ + default$schema: "https://json-schema.org/draft/2020-12/schema", + /** + * Defines an upper exclusive boundary of the level range for automatic expansion. + * + * 0 -> do nothing + * 1 -> [0]...(1) + * 2 -> [0]...(2) + * 3 -> [0]...(3) + */ + defaultExpandedLevels: 0 }, + overrides.config), + + fn: (0,objectSpread2_namespaceObject["default"])({ + upperFirst: fn_upperFirst, + getTitle: getTitle, + getType: getType, + isBooleanJSONSchema: isBooleanJSONSchema, + hasKeyword: hasKeyword, + isExpandable: isExpandable, + stringify: fn_stringify, + stringifyConstraints: stringifyConstraints, + getDependentRequired: getDependentRequired }, + overrides.fn) + + }; + + const HOC = (props) => /*#__PURE__*/ + external_react_namespaceObject["default"].createElement(JSONSchemaContext.Provider, { value: value }, /*#__PURE__*/ + external_react_namespaceObject["default"].createElement(Component, props) + ); + + HOC.contexts = { + JSONSchemaContext: JSONSchemaContext + }; + HOC.displayName = Component.displayName; + + return HOC; +}; +;// CONCATENATED MODULE: ./src/core/plugins/json-schema-2020-12/index.js +/** + * @prettier + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +const JSONSchema202012Plugin = () => ({ + components: { + JSONSchema202012: JSONSchema_JSONSchema, + JSONSchema202012Keyword$schema: keywords_$schema, + JSONSchema202012Keyword$vocabulary: $vocabulary_$vocabulary, + JSONSchema202012Keyword$id: keywords_$id, + JSONSchema202012Keyword$anchor: keywords_$anchor, + JSONSchema202012Keyword$dynamicAnchor: keywords_$dynamicAnchor, + JSONSchema202012Keyword$ref: keywords_$ref, + JSONSchema202012Keyword$dynamicRef: keywords_$dynamicRef, + JSONSchema202012Keyword$defs: keywords_$defs, + JSONSchema202012Keyword$comment: keywords_$comment, + JSONSchema202012KeywordAllOf: keywords_AllOf, + JSONSchema202012KeywordAnyOf: keywords_AnyOf, + JSONSchema202012KeywordOneOf: keywords_OneOf, + JSONSchema202012KeywordNot: keywords_Not, + JSONSchema202012KeywordIf: keywords_If, + JSONSchema202012KeywordThen: keywords_Then, + JSONSchema202012KeywordElse: keywords_Else, + JSONSchema202012KeywordDependentSchemas: keywords_DependentSchemas, + JSONSchema202012KeywordPrefixItems: keywords_PrefixItems, + JSONSchema202012KeywordItems: keywords_Items, + JSONSchema202012KeywordContains: keywords_Contains, + JSONSchema202012KeywordProperties: keywords_Properties_Properties, + JSONSchema202012KeywordPatternProperties: PatternProperties_PatternProperties, + JSONSchema202012KeywordAdditionalProperties: keywords_AdditionalProperties, + JSONSchema202012KeywordPropertyNames: keywords_PropertyNames, + JSONSchema202012KeywordUnevaluatedItems: keywords_UnevaluatedItems, + JSONSchema202012KeywordUnevaluatedProperties: keywords_UnevaluatedProperties, + JSONSchema202012KeywordType: keywords_Type, + JSONSchema202012KeywordEnum: Enum_Enum, + JSONSchema202012KeywordConst: keywords_Const, + JSONSchema202012KeywordConstraint: Constraint_Constraint, + JSONSchema202012KeywordDependentRequired: DependentRequired_DependentRequired, + JSONSchema202012KeywordContentSchema: keywords_ContentSchema, + JSONSchema202012KeywordTitle: Title_Title, + JSONSchema202012KeywordDescription: keywords_Description_Description, + JSONSchema202012KeywordDefault: keywords_Default, + JSONSchema202012KeywordDeprecated: keywords_Deprecated, + JSONSchema202012KeywordReadOnly: keywords_ReadOnly, + JSONSchema202012KeywordWriteOnly: keywords_WriteOnly, + JSONSchema202012Accordion: Accordion_Accordion, + JSONSchema202012ExpandDeepButton: ExpandDeepButton_ExpandDeepButton, + JSONSchema202012ChevronRightIcon: icons_ChevronRight, + withJSONSchema202012Context: withJSONSchemaContext, + JSONSchema202012DeepExpansionContext: () => JSONSchemaDeepExpansionContext + }, + fn: { + upperFirst: fn_upperFirst, + jsonSchema202012: { + isExpandable: isExpandable, + hasKeyword: hasKeyword, + useFn: useFn, + useConfig: useConfig, + useComponent: useComponent, + useIsExpandedDeeply: useIsExpandedDeeply, + sampleFromSchema: main_sampleFromSchema, + sampleFromSchemaGeneric: main_sampleFromSchemaGeneric, + sampleEncoderAPI: api_encoderAPI, + sampleFormatAPI: api_formatAPI, + sampleMediaTypeAPI: api_mediaTypeAPI, + createXMLExample: main_createXMLExample, + memoizedSampleFromSchema: main_memoizedSampleFromSchema, + memoizedCreateXMLExample: main_memoizedCreateXMLExample + } + } +}); + +/* harmony default export */ const json_schema_2020_12 = (JSONSchema202012Plugin); +;// CONCATENATED MODULE: ./src/core/presets/apis/index.js +/** + * @prettier + */ + + + + + +function PresetApis() { + return [base, oas3, json_schema_2020_12, oas31]; +} +;// CONCATENATED MODULE: ./src/core/index.js + + + +// presets + + +// plugins + + + + + + + + + + + + + + + + + + + + + + + + +// eslint-disable-next-line no-undef +const { GIT_DIRTY, GIT_COMMIT, PACKAGE_VERSION, BUILD_TIME } = {"PACKAGE_VERSION":"5.5.0","GIT_COMMIT":"g1ed1332d","GIT_DIRTY":true,"BUILD_TIME":"Mon, 04 Sep 2023 20:05:42 GMT"}; + +function SwaggerUI(opts) { + + core_window.versions = core_window.versions || {}; + core_window.versions.swaggerUi = { + version: PACKAGE_VERSION, + gitRevision: GIT_COMMIT, + gitDirty: GIT_DIRTY, + buildTimestamp: BUILD_TIME + }; + + const defaults = { + // Some general settings, that we floated to the top + dom_id: null, // eslint-disable-line camelcase + domNode: null, + spec: {}, + url: "", + urls: null, + layout: "BaseLayout", + docExpansion: "list", + maxDisplayedTags: null, + filter: null, + validatorUrl: "https://validator.swagger.io/validator", + oauth2RedirectUrl: `${window.location.protocol}//${window.location.host}${window.location.pathname.substring(0, window.location.pathname.lastIndexOf("/"))}/oauth2-redirect.html`, + persistAuthorization: false, + configs: {}, + custom: {}, + displayOperationId: false, + displayRequestDuration: false, + deepLinking: false, + tryItOutEnabled: false, + requestInterceptor: (a) => a, + responseInterceptor: (a) => a, + showMutatedRequest: true, + defaultModelRendering: "example", + defaultModelExpandDepth: 1, + defaultModelsExpandDepth: 1, + showExtensions: false, + showCommonExtensions: false, + withCredentials: undefined, + requestSnippetsEnabled: false, + requestSnippets: { + generators: { + "curl_bash": { + title: "cURL (bash)", + syntax: "bash" + }, + "curl_powershell": { + title: "cURL (PowerShell)", + syntax: "powershell" + }, + "curl_cmd": { + title: "cURL (CMD)", + syntax: "bash" + } + }, + defaultExpanded: true, + languages: null // e.g. only show curl bash = ["curl_bash"] + }, + supportedSubmitMethods: [ + "get", + "put", + "post", + "delete", + "options", + "head", + "patch", + "trace"], + + queryConfigEnabled: false, + + // Initial set of plugins ( TODO rename this, or refactor - we don't need presets _and_ plugins. Its just there for performance. + // Instead, we can compile the first plugin ( it can be a collection of plugins ), then batch the rest. + presets: [ + PresetApis], + + + // Plugins; ( loaded after presets ) + plugins: [], + + + pluginsOptions: { + // Behavior during plugin registration. Can be : + // - legacy (default) : the current behavior for backward compatibility – last plugin takes precedence over the others + // - chain : chain wrapComponents when targeting the same core component + pluginLoadType: "legacy" + }, + + // Initial state + initialState: {}, + + // Inline Plugin + fn: {}, + components: {}, + + syntaxHighlight: { + activated: true, + theme: "agate" + } + }; + + let queryConfig = opts.queryConfigEnabled ? parseSearch() : {}; + + const domNode = opts.domNode; + delete opts.domNode; + + const constructorConfig = deep_extend_default()({}, defaults, opts, queryConfig); + + const storeConfigs = { + system: { + configs: constructorConfig.configs + }, + plugins: constructorConfig.presets, + pluginsOptions: constructorConfig.pluginsOptions, + state: deep_extend_default()({ + layout: { + layout: constructorConfig.layout, + filter: constructorConfig.filter + }, + spec: { + spec: "", + url: constructorConfig.url + }, + requestSnippets: constructorConfig.requestSnippets + }, constructorConfig.initialState) + }; + + if (constructorConfig.initialState) { + // if the user sets a key as `undefined`, that signals to us that we + // should delete the key entirely. + // known usage: Swagger-Editor validate plugin tests + for (var key in constructorConfig.initialState) { + if ( + Object.prototype.hasOwnProperty.call(constructorConfig.initialState, key) && + constructorConfig.initialState[key] === undefined) + { + delete storeConfigs.state[key]; + } + } + } + + let inlinePlugin = () => { + return { + fn: constructorConfig.fn, + components: constructorConfig.components, + state: constructorConfig.state + }; + }; + + var store = new Store(storeConfigs); + store.register([constructorConfig.plugins, inlinePlugin]); + + var system = store.getSystem(); + + const downloadSpec = (fetchedConfig) => { + let localConfig = system.specSelectors.getLocalConfig ? system.specSelectors.getLocalConfig() : {}; + let mergedConfig = deep_extend_default()({}, localConfig, constructorConfig, fetchedConfig || {}, queryConfig); + + // deep extend mangles domNode, we need to set it manually + if (domNode) { + mergedConfig.domNode = domNode; + } + + store.setConfigs(mergedConfig); + system.configsActions.loaded(); + + if (fetchedConfig !== null) { + if (!queryConfig.url && typeof mergedConfig.spec === "object" && Object.keys(mergedConfig.spec).length) { + system.specActions.updateUrl(""); + system.specActions.updateLoadingStatus("success"); + system.specActions.updateSpec(JSON.stringify(mergedConfig.spec)); + } else if (system.specActions.download && mergedConfig.url && !mergedConfig.urls) { + system.specActions.updateUrl(mergedConfig.url); + system.specActions.download(mergedConfig.url); + } + } + + if (mergedConfig.domNode) { + system.render(mergedConfig.domNode, "App"); + } else if (mergedConfig.dom_id) { + let domNode = document.querySelector(mergedConfig.dom_id); + system.render(domNode, "App"); + } else if (mergedConfig.dom_id === null || mergedConfig.domNode === null) { + + + // do nothing + // this is useful for testing that does not need to do any rendering + } else {console.error("Skipped rendering: no `dom_id` or `domNode` was specified");} + + return system; + }; + + const configUrl = queryConfig.config || constructorConfig.configUrl; + + if (configUrl && system.specActions && system.specActions.getConfigByUrl) { + system.specActions.getConfigByUrl({ + url: configUrl, + loadRemoteConfig: true, + requestInterceptor: constructorConfig.requestInterceptor, + responseInterceptor: constructorConfig.responseInterceptor + }, downloadSpec); + } else { + return downloadSpec(); + } + + return system; +} + +SwaggerUI.presets = { + base: base, + apis: PresetApis +}; + +SwaggerUI.plugins = { + Auth: auth, + Configs: configsPlugin, + DeepLining: deep_linking, + Err: err, + Filter: filter, + Icons: icons, + JSONSchema202012: json_schema_2020_12, + Layout: plugins_layout, + Logs: logs, + OpenAPI30: oas3, + OpenAPI31: oas3, + OnComplete: on_complete, + RequestSnippets: plugins_request_snippets, + Samples: samples, + Spec: plugins_spec, + SwaggerClient: swagger_client, + Util: util, + View: view, + DownloadUrl: downloadUrlPlugin, + SafeRender: safe_render +}; +;// CONCATENATED MODULE: ./src/index.js + + +/* harmony default export */ const src = (SwaggerUI); +})(); + +var __webpack_exports__default = __webpack_exports__.Z; +export { __webpack_exports__default as default }; diff --git a/docs/README.md b/docs/README.md index d0438008c4d..9b42682eaa4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -17,6 +17,8 @@ Welcome to the Swagger UI documentation! - [Overview](customization/overview.md) - [Plugin API](customization/plugin-api.md) - [Custom layout](customization/custom-layout.md) +- [Adding plugin](customization/add-plugin.md) +- [Plug-Points](customization/plug-points.md) ## Development diff --git a/src/plugins/add-plugin.md b/docs/customization/add-plugin.md similarity index 100% rename from src/plugins/add-plugin.md rename to docs/customization/add-plugin.md diff --git a/package-lock.json b/package-lock.json index 02ddbc7001d..dfa24ea97e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -51,11 +51,10 @@ "@babel/cli": "=7.22.10", "@babel/core": "=7.22.11", "@babel/eslint-parser": "=7.22.11", - "@babel/plugin-proposal-class-properties": "=7.18.6", - "@babel/plugin-proposal-nullish-coalescing-operator": "=7.18.6", - "@babel/plugin-proposal-object-rest-spread": "=7.20.7", - "@babel/plugin-proposal-optional-chaining": "=7.21.0", - "@babel/plugin-transform-modules-commonjs": "=7.22.11", + "@babel/plugin-transform-class-properties": "=7.22.5", + "@babel/plugin-transform-nullish-coalescing-operator": "=7.22.11", + "@babel/plugin-transform-object-rest-spread": "=7.22.15", + "@babel/plugin-transform-optional-chaining": "=7.22.15", "@babel/plugin-transform-runtime": "=7.22.10", "@babel/preset-env": "=7.22.14", "@babel/preset-react": "=7.22.5", @@ -96,6 +95,7 @@ "inspectpack": "=4.7.1", "jest": "=29.6.3", "jest-environment-jsdom": "=29.6.4", + "jest-transform-stub": "=2.0.0", "jsdom": "=22.1.0", "json-loader": "^0.5.7", "json-merger": "^1.1.10", @@ -309,13 +309,13 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.10.tgz", - "integrity": "sha512-JMSwHD4J7SLod0idLq5PKgI+6g/hLD/iuWBq08ZX49xE14VpVEojJ5rHWptpirV2j020MvypRLAXAO50igCJ5Q==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.15.tgz", + "integrity": "sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==", "dev": true, "dependencies": { "@babel/compat-data": "^7.22.9", - "@babel/helper-validator-option": "^7.22.5", + "@babel/helper-validator-option": "^7.22.15", "browserslist": "^4.21.9", "lru-cache": "^5.1.1", "semver": "^6.3.1" @@ -567,9 +567,9 @@ } }, "node_modules/@babel/helper-validator-option": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", - "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.15.tgz", + "integrity": "sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==", "dev": true, "engines": { "node": ">=6.9.0" @@ -661,74 +661,6 @@ "@babel/core": "^7.13.0" } }, - "node_modules/@babel/plugin-proposal-class-properties": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", - "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", - "dev": true, - "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", - "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-object-rest-spread": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", - "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", - "dev": true, - "dependencies": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.20.7" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, - "node_modules/@babel/plugin-proposal-optional-chaining": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz", - "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==", - "dev": true, - "dependencies": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" - }, - "engines": { - "node": ">=6.9.0" - }, - "peerDependencies": { - "@babel/core": "^7.0.0-0" - } - }, "node_modules/@babel/plugin-proposal-private-property-in-object": { "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", @@ -1489,16 +1421,16 @@ } }, "node_modules/@babel/plugin-transform-object-rest-spread": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.22.11.tgz", - "integrity": "sha512-nX8cPFa6+UmbepISvlf5jhQyaC7ASs/7UxHmMkuJ/k5xSHvDPPaibMo+v3TXwU/Pjqhep/nFNpd3zn4YR59pnw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.22.15.tgz", + "integrity": "sha512-fEB+I1+gAmfAyxZcX1+ZUwLeAuuf8VIg67CTznZE0MqVFumWkh8xWtn58I4dxdVf080wn7gzWoF8vndOViJe9Q==", "dev": true, "dependencies": { "@babel/compat-data": "^7.22.9", - "@babel/helper-compilation-targets": "^7.22.10", + "@babel/helper-compilation-targets": "^7.22.15", "@babel/helper-plugin-utils": "^7.22.5", "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.22.5" + "@babel/plugin-transform-parameters": "^7.22.15" }, "engines": { "node": ">=6.9.0" @@ -1540,9 +1472,9 @@ } }, "node_modules/@babel/plugin-transform-optional-chaining": { - "version": "7.22.12", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.22.12.tgz", - "integrity": "sha512-7XXCVqZtyFWqjDsYDY4T45w4mlx1rf7aOgkc/Ww76xkgBiOlmjPkx36PBLHa1k1rwWvVgYMPsbuVnIamx2ZQJw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.22.15.tgz", + "integrity": "sha512-ngQ2tBhq5vvSJw2Q2Z9i7ealNkpDMU0rGWnHPKqRZO0tzZ5tlaoz4hDvhXioOoaE0X2vfNss1djwg0DXlfu30A==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.22.5", @@ -1557,9 +1489,9 @@ } }, "node_modules/@babel/plugin-transform-parameters": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.22.5.tgz", - "integrity": "sha512-AVkFUBurORBREOmHRKo06FjHYgjrabpdqRSwq6+C7R5iTCZOsM4QbcB27St0a4U6fffyAOqh3s/qEfybAhfivg==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.22.15.tgz", + "integrity": "sha512-hjk7qKIqhyzhhUvRT683TYQOFa/4cQKwQy7ALvTpODswN40MljzNDa0YldevS6tGbxwaEKVn502JmY0dP7qEtQ==", "dev": true, "dependencies": { "@babel/helper-plugin-utils": "^7.22.5" @@ -17312,6 +17244,12 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, + "node_modules/jest-transform-stub": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jest-transform-stub/-/jest-transform-stub-2.0.0.tgz", + "integrity": "sha512-lspHaCRx/mBbnm3h4uMMS3R5aZzMwyNpNIJLXj4cEsV0mIUtS4IjYJLSoyjRCtnxb6RIGJ4NL2quZzfIeNhbkg==", + "dev": true + }, "node_modules/jest-util": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.3.tgz", @@ -30129,13 +30067,13 @@ } }, "@babel/helper-compilation-targets": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.10.tgz", - "integrity": "sha512-JMSwHD4J7SLod0idLq5PKgI+6g/hLD/iuWBq08ZX49xE14VpVEojJ5rHWptpirV2j020MvypRLAXAO50igCJ5Q==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.15.tgz", + "integrity": "sha512-y6EEzULok0Qvz8yyLkCvVX+02ic+By2UdOhylwUOvOn9dvYc9mKICJuuU1n1XBI02YWsNsnrY1kc6DVbjcXbtw==", "dev": true, "requires": { "@babel/compat-data": "^7.22.9", - "@babel/helper-validator-option": "^7.22.5", + "@babel/helper-validator-option": "^7.22.15", "browserslist": "^4.21.9", "lru-cache": "^5.1.1", "semver": "^6.3.1" @@ -30315,9 +30253,9 @@ "dev": true }, "@babel/helper-validator-option": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz", - "integrity": "sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.22.15.tgz", + "integrity": "sha512-bMn7RmyFjY/mdECUbgn9eoSY4vqvacUnS9i9vGAGttgFWesO6B4CYWA7XlpbWgBt71iv/hfbPlynohStqnu5hA==", "dev": true }, "@babel/helper-wrap-function": { @@ -30379,50 +30317,6 @@ "@babel/plugin-transform-optional-chaining": "^7.22.5" } }, - "@babel/plugin-proposal-class-properties": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.18.6.tgz", - "integrity": "sha512-cumfXOF0+nzZrrN8Rf0t7M+tF6sZc7vhQwYQck9q1/5w2OExlD+b4v4RpMJFaV1Z7WcDRgO6FqvxqxGlwo+RHQ==", - "dev": true, - "requires": { - "@babel/helper-create-class-features-plugin": "^7.18.6", - "@babel/helper-plugin-utils": "^7.18.6" - } - }, - "@babel/plugin-proposal-nullish-coalescing-operator": { - "version": "7.18.6", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.18.6.tgz", - "integrity": "sha512-wQxQzxYeJqHcfppzBDnm1yAY0jSRkUXR2z8RePZYrKwMKgMlE8+Z6LUno+bd6LvbGh8Gltvy74+9pIYkr+XkKA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.18.6", - "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" - } - }, - "@babel/plugin-proposal-object-rest-spread": { - "version": "7.20.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.20.7.tgz", - "integrity": "sha512-d2S98yCiLxDVmBmE8UjGcfPvNEUbA1U5q5WxaWFUGRzJSVAZqm5W6MbPct0jxnegUZ0niLeNX+IOzEs7wYg9Dg==", - "dev": true, - "requires": { - "@babel/compat-data": "^7.20.5", - "@babel/helper-compilation-targets": "^7.20.7", - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.20.7" - } - }, - "@babel/plugin-proposal-optional-chaining": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.21.0.tgz", - "integrity": "sha512-p4zeefM72gpmEe2fkUr/OnOXpWEf8nAgk7ZYVqqfFiyIG7oFfVZcCrU64hWn5xp4tQ9LkV4bTIa5rD0KANpKNA==", - "dev": true, - "requires": { - "@babel/helper-plugin-utils": "^7.20.2", - "@babel/helper-skip-transparent-expression-wrappers": "^7.20.0", - "@babel/plugin-syntax-optional-chaining": "^7.8.3" - } - }, "@babel/plugin-proposal-private-property-in-object": { "version": "7.21.0-placeholder-for-preset-env.2", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", @@ -30917,16 +30811,16 @@ } }, "@babel/plugin-transform-object-rest-spread": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.22.11.tgz", - "integrity": "sha512-nX8cPFa6+UmbepISvlf5jhQyaC7ASs/7UxHmMkuJ/k5xSHvDPPaibMo+v3TXwU/Pjqhep/nFNpd3zn4YR59pnw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.22.15.tgz", + "integrity": "sha512-fEB+I1+gAmfAyxZcX1+ZUwLeAuuf8VIg67CTznZE0MqVFumWkh8xWtn58I4dxdVf080wn7gzWoF8vndOViJe9Q==", "dev": true, "requires": { "@babel/compat-data": "^7.22.9", - "@babel/helper-compilation-targets": "^7.22.10", + "@babel/helper-compilation-targets": "^7.22.15", "@babel/helper-plugin-utils": "^7.22.5", "@babel/plugin-syntax-object-rest-spread": "^7.8.3", - "@babel/plugin-transform-parameters": "^7.22.5" + "@babel/plugin-transform-parameters": "^7.22.15" } }, "@babel/plugin-transform-object-super": { @@ -30950,9 +30844,9 @@ } }, "@babel/plugin-transform-optional-chaining": { - "version": "7.22.12", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.22.12.tgz", - "integrity": "sha512-7XXCVqZtyFWqjDsYDY4T45w4mlx1rf7aOgkc/Ww76xkgBiOlmjPkx36PBLHa1k1rwWvVgYMPsbuVnIamx2ZQJw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.22.15.tgz", + "integrity": "sha512-ngQ2tBhq5vvSJw2Q2Z9i7ealNkpDMU0rGWnHPKqRZO0tzZ5tlaoz4hDvhXioOoaE0X2vfNss1djwg0DXlfu30A==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.22.5", @@ -30961,9 +30855,9 @@ } }, "@babel/plugin-transform-parameters": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.22.5.tgz", - "integrity": "sha512-AVkFUBurORBREOmHRKo06FjHYgjrabpdqRSwq6+C7R5iTCZOsM4QbcB27St0a4U6fffyAOqh3s/qEfybAhfivg==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.22.15.tgz", + "integrity": "sha512-hjk7qKIqhyzhhUvRT683TYQOFa/4cQKwQy7ALvTpODswN40MljzNDa0YldevS6tGbxwaEKVn502JmY0dP7qEtQ==", "dev": true, "requires": { "@babel/helper-plugin-utils": "^7.22.5" @@ -42495,6 +42389,12 @@ } } }, + "jest-transform-stub": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jest-transform-stub/-/jest-transform-stub-2.0.0.tgz", + "integrity": "sha512-lspHaCRx/mBbnm3h4uMMS3R5aZzMwyNpNIJLXj4cEsV0mIUtS4IjYJLSoyjRCtnxb6RIGJ4NL2quZzfIeNhbkg==", + "dev": true + }, "jest-util": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.6.3.tgz", diff --git a/package.json b/package.json index e7123a569f8..a5df3572892 100644 --- a/package.json +++ b/package.json @@ -39,28 +39,28 @@ "automated-release": "release-it -VV --config ./release/.release-it.json", "build": "npm run build-stylesheets && rimraf ./dist/swagger-ui.js ./dist/swagger-ui.js.map && npm run build-all-bundles", "build-all-bundles": "run-p --aggregate-output build:core build:bundle build:standalone build:es:bundle build:es:bundle:core", - "build-stylesheets": "webpack --color --config webpack/stylesheets.babel.js", - "build:bundle": "webpack --color --config webpack/bundle.babel.js", - "build:core": "webpack --color --config webpack/core.babel.js", - "build:standalone": "webpack --color --config webpack/standalone.babel.js", - "build:es:bundle": "webpack --color --config webpack/es-bundle.babel.js", - "build:es:bundle:core": "webpack --color --config webpack/es-bundle-core.babel.js", + "build-stylesheets": "cross-env NODE_ENV=production webpack --color --config webpack/stylesheets.js", + "build:bundle": "cross-env NODE_ENV=production webpack --color --config webpack/bundle.js", + "build:core": "cross-env NODE_ENV=production webpack --color --config webpack/core.js", + "build:standalone": "cross-env NODE_ENV=production webpack --color --config webpack/standalone.js", + "build:es:bundle": "cross-env NODE_ENV=production webpack --color --config webpack/es-bundle.js", + "build:es:bundle:core": "cross-env NODE_ENV=production BABEL_ENV=esm webpack --color --config webpack/es-bundle-core.js", "clean": "rimraf ./dist", "postinstall": "patch-package", - "dev": "webpack serve --config webpack/dev.babel.js", + "dev": "cross-env NODE_ENV=development webpack serve --config webpack/dev.js", "deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv", - "deps-size": "webpack -p --config webpack/bundle.babel.js --json | webpack-bundle-size-analyzer >| $npm_package_config_deps_check_dir/sizes.txt", + "deps-size": "cross-env NODE_ENV=development webpack -p --config webpack/bundle.js --json | webpack-bundle-size-analyzer >| $npm_package_config_deps_check_dir/sizes.txt", "deps-check": "run-s deps-license deps-size", "lint": "eslint --ext \".js,.jsx\" src test dev-helpers flavors", "lint-errors": "eslint --quiet --ext \".js,.jsx\" src test dev-helpers flavors", "lint-fix": "eslint --ext \".js,.jsx\" src test dev-helpers flavors --fix", "test": "run-s lint-errors just-test-in-node test:unit-jest cy:ci", "test-in-node": "run-s lint-errors just-test-in-node", - "just-test-in-node": "cross-env BABEL_ENV=test mocha \"test/mocha/**/*.{js,jsx}\"", - "test:artifact": "jest --config ./config/jest/jest.artifact.config.js", - "test:unit-jest": "cross-env BABEL_ENV=test jest --config ./config/jest/jest.unit.config.js", + "just-test-in-node": "cross-env NODE_ENV=test mocha \"test/mocha/**/*.{js,jsx}\"", + "test:artifact": "cross-env NODE_ENV=production jest --config ./config/jest/jest.artifact.config.js", + "test:unit-jest": "cross-env NODE_ENV=test jest --config ./config/jest/jest.unit.config.js", "cy:mock-api": "json-server --watch test/e2e-selenium/db.json --port 3204", - "cy:server": "webpack serve --config webpack/dev-e2e.babel.js", + "cy:server": "cross-env NODE_ENV=production webpack serve --config webpack/dev-e2e.js", "cy:start": "run-p -r cy:server cy:mock-api", "cy:open": "cypress open", "cy:run": "cypress run", @@ -115,11 +115,10 @@ "@babel/cli": "=7.22.10", "@babel/core": "=7.22.11", "@babel/eslint-parser": "=7.22.11", - "@babel/plugin-proposal-class-properties": "=7.18.6", - "@babel/plugin-proposal-nullish-coalescing-operator": "=7.18.6", - "@babel/plugin-proposal-object-rest-spread": "=7.20.7", - "@babel/plugin-proposal-optional-chaining": "=7.21.0", - "@babel/plugin-transform-modules-commonjs": "=7.22.11", + "@babel/plugin-transform-class-properties": "=7.22.5", + "@babel/plugin-transform-nullish-coalescing-operator": "=7.22.11", + "@babel/plugin-transform-object-rest-spread": "=7.22.15", + "@babel/plugin-transform-optional-chaining": "=7.22.15", "@babel/plugin-transform-runtime": "=7.22.10", "@babel/preset-env": "=7.22.14", "@babel/preset-react": "=7.22.5", @@ -160,6 +159,7 @@ "inspectpack": "=4.7.1", "jest": "=29.6.3", "jest-environment-jsdom": "=29.6.4", + "jest-transform-stub": "=2.0.0", "jsdom": "=22.1.0", "json-loader": "^0.5.7", "json-merger": "^1.1.10", diff --git a/src/img/rolling-load.svg b/src/core/assets/rolling-load.svg similarity index 100% rename from src/img/rolling-load.svg rename to src/core/assets/rolling-load.svg diff --git a/src/core/brace-snippets-yaml.js b/src/core/brace-snippets-yaml.js deleted file mode 100644 index 1130e70c252..00000000000 --- a/src/core/brace-snippets-yaml.js +++ /dev/null @@ -1,6 +0,0 @@ -/* global ace */ -ace.define("ace/snippets/yaml", - ["require","exports","module"], function(e,t,n){ // eslint-disable-line no-unused-vars - t.snippetText=undefined - t.scope="yaml" - }) diff --git a/src/core/json-schema-components.jsx b/src/core/components/json-schema-components.jsx similarity index 100% rename from src/core/json-schema-components.jsx rename to src/core/components/json-schema-components.jsx diff --git a/src/core/components/model.jsx b/src/core/components/model.jsx index 4b420f367e6..a5e505da67f 100644 --- a/src/core/components/model.jsx +++ b/src/core/components/model.jsx @@ -3,6 +3,8 @@ import ImmutablePureComponent from "react-immutable-pure-component" import ImPropTypes from "react-immutable-proptypes" import PropTypes from "prop-types" +import RollingLoadSVG from "core/assets/rolling-load.svg" + const decodeRefName = uri => { const unescaped = uri.replace(/~1/g, "/").replace(/~0/g, "~") @@ -66,7 +68,7 @@ export default class Model extends ImmutablePureComponent { if(!schema) { return { displayName || name } - + } diff --git a/src/core/components/operation.jsx b/src/core/components/operation.jsx index f0c9e5129de..6e3f2f8a969 100644 --- a/src/core/components/operation.jsx +++ b/src/core/components/operation.jsx @@ -6,6 +6,7 @@ import { safeBuildUrl } from "core/utils/url" import { Iterable, List } from "immutable" import ImPropTypes from "react-immutable-proptypes" +import RollingLoadSVG from "core/assets/rolling-load.svg" export default class Operation extends PureComponent { static propTypes = { @@ -122,7 +123,7 @@ export default class Operation extends PureComponent {