I always use ajv with removeAdditional='all', it works almost all the time for me.
but I cannot handle the case there is some object in object is free style, and it's content should not removed.
and I don't want to write additionalProperties=false in every schema. so if additionalProperties is default false, that will work.
can it be ?
@taojoe making additionalProperties default to false would deviate from JSON schema specification and I don't won't to create options that facilitate it. So writing additionalProperties: false is the correct approach as it makes it explicit to all people who will read your code... The alternative is to traverse your schema programmatically (with json-schema-traverse) and assign additionalProperties: false to all subschemas that don't have additionalProperties: true.
Most helpful comment
@taojoe making additionalProperties default to
falsewould deviate from JSON schema specification and I don't won't to create options that facilitate it. So writingadditionalProperties: falseis the correct approach as it makes it explicit to all people who will read your code... The alternative is to traverse your schema programmatically (with json-schema-traverse) and assignadditionalProperties: falseto all subschemas that don't haveadditionalProperties: true.