DScheglov / mongoose-schema-jsonschema

Mongoose extension that allows to build json schema for mongoose models, schemes and queries
MIT License
107 stars 31 forks source link

additionalProperties configuration #13

Open saggiyogesh opened 6 years ago

saggiyogesh commented 6 years ago

Hi, didn't find any docs / example related to additionalProperties. By default, MongoDB keeps this as true.

How can make it additionalProperties: false globally, so that child objects are also validated.
Is this possible

DScheglov commented 6 years ago

Hi, I will add support for strict-option of mongoose-schema (https://mongoosejs.com/docs/guide.html#strict)

In case when strict equals "throw" the json schema will get additionalProperties: false (the same behavior will be repeated for all nested mongoose schemas, but it could be overrided in the nested schema).

It is also possible that the global flag could be added to define default behavior).

saggiyogesh commented 6 years ago

Hi. Thanks for considering it. For time being I've forked the repo & implemented this.

abarriel commented 4 years ago

up