genson-js icon indicating copy to clipboard operation
genson-js copied to clipboard

feat: option noAdditionalProperties

Open alanblins opened this issue 1 year ago • 0 comments

Adding option noAdditionalProperties Add additionalProperties=false to all object types

import { createSchema } from 'genson-js';
const schema = createSchema({ one: 1, two: 'second' }, { noAdditionalProperties: true });

The following schema will be created:

{
    type: 'object',
    additionalProperties: false,
    properties: { one: { type: 'integer' }, two: { type: 'string' } },
    required: [
        "one",
        "two",
    ]
}

alanblins avatar Dec 16 '23 21:12 alanblins