giddyinc / mongoose-to-swagger

Conversion library for transforming Mongoose schema objects into Swagger schema definitions.
MIT License
54 stars 29 forks source link

Error when specifying the Array type #47

Open blasdfaa opened 2 years ago

blasdfaa commented 2 years ago

const userSchema = mongoose.Schema({ movies_ids: Array }) When specifying the field as "Array", I get this error:

const arraySchema = Array.isArray(value) ? value[0] : value.type[0];
                                                                ^
TypeError: Cannot read properties of undefined (reading '0')

But if you specify so, then everything works const userSchema = mongoose.Schema({ movies_ids: [] })