Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested fields is not omitted #44

Open
tyz-crazy opened this issue Apr 18, 2022 · 0 comments
Open

Nested fields is not omitted #44

tyz-crazy opened this issue Apr 18, 2022 · 0 comments
Labels

Comments

@tyz-crazy
Copy link

Hi. I found the bug when nested fields in the schema are not omitted, for example:

const User = mongoose.model("User", { name: { type: String }, phone: { type: String }, email: { title: "email", type: String, lowercase: true, required: false }, address: { default: {}, required: true, type: new mongoose.Schema({ country: { title: "Country", type: String } }) } });

const swaggerSchema = m2s(User, { props: ["title"], omitFields: ["address.country"] }); console.log(swaggerSchema);

So the swaggerSchema.address.country not omitted.
The bug in this line

It happens, because the country field is not exists in the root schema, country field has another path: schema.tree.address.type.tree.country

@James1x0 James1x0 added the bug label Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants