mongoose-to-swagger
mongoose-to-swagger copied to clipboard
type: { type: "" } not handled
Hi there,
Just found a bug. For instance if having a schema like this :
{
address: {
type: { type: String },
postalCode: String
}
}
Your lib outputs :
{
address: {
type: String
}
}
All properties are lost.
I fixed it by modifying 2 places :
https://github.com/giddyinc/mongoose-to-swagger/blob/82808a449b339f79ce79274e87a4f1a057b0b0b1/lib/index.ts#L56
if (type.type != null) {
if (type.type != null && !type.type?.type) {
https://github.com/giddyinc/mongoose-to-swagger/blob/82808a449b339f79ce79274e87a4f1a057b0b0b1/lib/index.ts#L142
const subSchema = value.type ? value.type : value;
const subSchema = value.type && !value.type?.type ? value.type : value;
I can open a PR if you want.
Cheers
Hi @Cheyenne55! Would absolutely accept a PR to fix this as well as adding a regression test. Thanks!