mongoose-to-swagger
mongoose-to-swagger copied to clipboard
Conversion fails if my model has a property named "description"
It looks like the algorithm can't differentiate a field named description from the attribute description.
I have a model like this:
//... more properties before here
date: { type: Date, default: Date.now },
servicesRendered: [{
_id: false,
Service: { type: mongoose.Schema.Types.ObjectId, ref: 'Service' },
description: String,
quantity: Number,
price: Number
}],
paymentTerms: String,
//more properties after...
the property "description" is not the description of the model but a property with type String. When converting it to swagger it generates as follows:
"date": {
"type": "string",
"format": "date-time"
},
"servicesRendered": {
"type": "array",
"items": {
"type": "object",
"description": function String() { [native code] },
"properties": {
"Service": {
"type": "string"
},
"description": {
"type": "string"
},
"quantity": {
"type": "number"
},
"price": {
"type": "number"
}
},
"required": []
}
},
"paymentTerms": {
"type": "string"
},
As you can see, it generates a description "description": function String() { [native code] },
and if failed to load the Swagger UI.