Skip to content

Commit

Permalink
couple updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickity committed Jul 21, 2020
1 parent 0f74fc8 commit 5d7477f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 5d7477f

Please sign in to comment.