diff --git a/lib/generator.js b/lib/generator.js index 5a441ab..227af06 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -22,6 +22,7 @@ generator.newModel = function (schema, definitions) { const schemaType = utils.getPrimitiveType(schema) const described = schema.describe() Hoek.assert(schemaType !== "array", "generator.newModel does not support array schema") + // Don"t generate model for primitive types! if (utils.isPrimitiveSwaggerType(schemaType)) { diff --git a/lib/utils.js b/lib/utils.js index 2bea2d7..343cf69 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -227,13 +227,13 @@ utils.getSetting = function (schema, key) { utils.getMeta = function (schema, key) { // merge meta objects - last one wins - const meta = schema ? _.extend.apply(null, schema._meta) : undefined + const meta = schema ? schema.$_terms.metas : undefined // Still fallback to settings for joi <6 return meta && !_.isUndefined(meta[key]) ? meta[key] : utils.getSetting(schema, key) } utils.generateName = function (schema) { - return utils.getMeta(schema, "className") || utils.generateNameFromSchema(schema) + return utils.getMeta(schema, 0) || utils.generateNameFromSchema(schema) } utils.generateNameWithFallback = function (schema, definitions, definition) { @@ -262,7 +262,7 @@ utils.getPrimitiveType = function (schema) { if (swaggerType != null) { return swaggerType } - + const isInteger = _.find(schema._tests, { name: "integer" }) != null return isInteger ? "integer" : schema.type }