Comparing version 0.6.6 to 0.6.7
@@ -10,11 +10,15 @@ // This is a Controller mixin to add methods for generating Swagger data. | ||
function swaggerTypeFor (type) { | ||
if (!type) return null; | ||
if (type === String) return 'string'; | ||
if (type === Number) return 'double'; | ||
if (type === Date) return 'Date'; | ||
if (type === mongoose.Schema.Types.Buffer) throw new Error('Not implemented'); | ||
if (type === Boolean) return 'boolean'; | ||
if (type === mongoose.Schema.Types.Mixed) throw new Error('Not implemented'); | ||
if (type === mongoose.Schema.Types.ObjectId) return 'string'; | ||
if (type === mongoose.Schema.Types.Oid) return 'string'; | ||
if (type === mongoose.Schema.Types.Array) return 'Array'; | ||
if (Array.isArray(type)) return 'Array'; | ||
if (type === Object) return null; | ||
if (type instanceof Object) return null; | ||
if (type === mongoose.Schema.Types.Mixed) return null; | ||
if (type === mongoose.Schema.Types.Buffer) return null; | ||
throw new Error('Unrecognized type: ' + type); | ||
@@ -48,2 +52,3 @@ }; | ||
var select = that.get('select'); | ||
var type = swaggerTypeFor(path.options.type); | ||
@@ -54,5 +59,15 @@ // Keep deselected paths private | ||
property.type = swaggerTypeFor(path.options.type); | ||
if (!type) { | ||
console.log('Warning: That field type is not yet supported in baucis Swagger definitions, using "string."'); | ||
console.log('Path name: %s.%s', definition.id, name); | ||
console.log('Mongoose type: %s', path.options.type); | ||
property.type = 'string'; | ||
} | ||
else { | ||
property.type = swaggerTypeFor(path.options.type); | ||
} | ||
property.required = path.options.required || (name === '_id'); | ||
// Set enum values if applicable | ||
@@ -59,0 +74,0 @@ if (path.enumValues && path.enumValues.length > 0) { |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://github.com/wprl/baucis", | ||
"version": "0.6.6", | ||
"version": "0.6.7", | ||
"main": "index.js", | ||
@@ -8,0 +8,0 @@ "scripts": { |
@@ -1,2 +0,2 @@ | ||
baucis v0.6.6 | ||
baucis v0.6.7 | ||
============= | ||
@@ -3,0 +3,0 @@ |
248082
2359