@f5devcentral/f5-fast-core
Advanced tools
Comparing version 0.13.0 to 0.14.0
@@ -0,1 +1,13 @@ | ||
# v0.14.0 | ||
## Fixed | ||
* template: Fix merging array items definitions with custom types | ||
* template: Fix over-aggressive cleaning of definitions referenced in "items" keyword | ||
* template: Fix losing definitions from merged in templates | ||
* template: Fix missing description when merging templates | ||
## Changed | ||
* ResourceCache: Improve cache utilization for concurrent requests | ||
* template: Do not mark properties with defaults as required | ||
* template: Do not automatically supply default values for primitive types | ||
# v0.13.0 | ||
@@ -2,0 +14,0 @@ ## Added |
@@ -122,3 +122,3 @@ /* Copyright 2021 F5 Networks, Inc. | ||
mergeWith(schema, ...schema.allOf, (objValue, srcValue, key) => { | ||
if (key === 'title') { | ||
if (key === 'title' || key === 'description') { | ||
return objValue; | ||
@@ -125,0 +125,0 @@ } |
@@ -30,3 +30,3 @@ /* Copyright 2021 F5 Networks, Inc. | ||
if (!this.cached[key]) { | ||
return this.asyncFetch(key) | ||
this.cached[key] = this.asyncFetch(key) | ||
.then((resource) => { | ||
@@ -33,0 +33,0 @@ this.cached[key] = resource; |
@@ -51,4 +51,4 @@ /* Copyright 2021 F5 Networks, Inc. | ||
if (prop.items && prop.items.$ref) { | ||
props.push(cleanRef(prop.items.$ref)); | ||
if (prop.items) { | ||
props.push(...getRefDefs(prop.items)); | ||
} | ||
@@ -341,30 +341,23 @@ | ||
acc.properties[defName] = Object.assign({}, schemaDef); | ||
} else if (defType === 'text') { | ||
acc.properties[defName] = { | ||
type: 'string', | ||
format: 'text' | ||
}; | ||
} else if (defType === 'array') { | ||
acc.properties[defName] = { | ||
type: defType, | ||
items: { | ||
type: 'string' | ||
} | ||
}; | ||
} else if (defType === 'hidden') { | ||
acc.properties[defName] = { | ||
type: 'string', | ||
format: 'hidden' | ||
}; | ||
} else { | ||
if (defType === 'text') { | ||
acc.properties[defName] = { | ||
type: 'string', | ||
format: 'text' | ||
}; | ||
} else if (defType === 'array') { | ||
acc.properties[defName] = { | ||
type: defType, | ||
items: { | ||
type: 'string' | ||
} | ||
}; | ||
} else if (defType === 'hidden') { | ||
acc.properties[defName] = { | ||
type: 'string', | ||
format: 'hidden' | ||
}; | ||
} else { | ||
acc.properties[defName] = { | ||
type: defType | ||
}; | ||
} | ||
const propType = acc.properties[defName].type; | ||
if (!this.definitions[defName] && typeof primitives[propType] !== 'undefined') { | ||
acc.properties[defName].default = primitives[propType]; | ||
} | ||
acc.properties[defName] = { | ||
type: defType | ||
}; | ||
} | ||
@@ -375,3 +368,9 @@ if (this.definitions[defName]) { | ||
const propDef = acc.properties[defName]; | ||
if (propDef.format !== 'hidden' && propDef.format !== 'info' && !propDef.mathExpression) { | ||
const isRequired = ( | ||
propDef.format !== 'hidden' | ||
&& propDef.format !== 'info' | ||
&& !propDef.mathExpression | ||
&& typeof propDef.default === 'undefined' | ||
); | ||
if (isRequired) { | ||
required.add(defName); | ||
@@ -409,3 +408,3 @@ } | ||
const items = this._handleParsed(curr[4], typeSchemas); | ||
const schemaDef = Object.assign( | ||
const schemaDef = deepmerge( | ||
this._typeDefinitions[type] || {}, | ||
@@ -418,4 +417,9 @@ this.definitions[defName] || {} | ||
if (defType === 'array') { | ||
newDef.items = newDef.items || {}; | ||
newDef.skip_xform = true; | ||
newDef.items = Object.assign({}, items, newDef.items); | ||
newDef.items = deepmerge(items || {}, newDef.items || {}); | ||
if (newDef.items.required) { | ||
newDef.items.required = newDef.items.required | ||
.filter(x => typeof newDef.items.properties[x].default === 'undefined'); | ||
} | ||
} else if (defType === 'object') { | ||
@@ -439,5 +443,2 @@ Object.assign(newDef, items); | ||
this._mergeSchemaInto(acc, items, dependencies); | ||
if (typeof newDef.default === 'undefined') { | ||
newDef.default = primitives[newDef.type]; | ||
} | ||
} | ||
@@ -459,4 +460,3 @@ | ||
acc.properties[defName] = Object.assign({ | ||
type: 'boolean', | ||
default: primitives.boolean | ||
type: 'boolean' | ||
}, | ||
@@ -510,4 +510,3 @@ schemaDef); | ||
return { | ||
type: 'string', | ||
default: primitives.string | ||
type: 'string' | ||
}; | ||
@@ -633,3 +632,3 @@ } | ||
// Cleanup unneeded definitions | ||
const refDefs = getRefDefs(this._parametersSchema); | ||
const refDefs = getRefDefs(this.getParametersSchema()); | ||
this.definitions = Object.keys(this.definitions).reduce((acc, key) => { | ||
@@ -659,3 +658,4 @@ if (refDefs.includes(key)) { | ||
loadSchema, | ||
unknownFormats: 'ignore' | ||
unknownFormats: 'ignore', | ||
useDefaults: true | ||
}); | ||
@@ -662,0 +662,0 @@ ajv.addFormat('text', /.*/); |
{ | ||
"name": "@f5devcentral/f5-fast-core", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"author": "F5 Networks", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
121141
2431