INNER CODE UNIT · JavaScript
normalizeSchemaObject
serverless/serverless · packages/serverless/lib/classes/config-schema-handler/index.js:12
const normalizeSchemaObject = (object, instanceSchema) => {
for (const [key, value] of Object.entries(object)) {
if (!_.isObject(value)) continue
if (!value.$ref) {
normalizeSchemaObject(value, instanceSchema)
continue
}
if (!value.$ref.startsWith('#/definitions/')) {
throw new Error(`Unsupported reference ${value.$ref}`)
}
object[key] = _.get(instanceSchema, value.$ref.slice(2).split('/'))
}
}
// Normalizer is introduced to workaround https://github.com/ajv-validator/ajv/issues/1287
// normalizedObjectsMap allows to handle circular structures without issues
const normalizeUserConfig = (userConfig) => {
const normalizedObjectsSet = new WeakSet()