Fix additionalProperties on nested schemas
See original GitHub issueWhen a schema is nested (not on a first level), When the iteration of properties uses an expression
tpl(`if(%s.properties.hasOwnProperty(${property})) continue;`, tpl.schema);
Then a schema is taken from the context of the generated validation function, Then it is a single start point schema. When additoonalProperties is used on a nested level Then it will fail to validate
Example @see utils/index:makeSchema.js
return {
properties: required.reduce((memo, key) => (
Object.assign({}, memo, {
[key]: makeSchema(instance[key])
})
), {}),
required,
// other properties should be valid by `false` schema, aka not exist at all
// additionalProperties: false,
};
uncomment additionalProperties -> error
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
v2.4+ silently removes additionalProperties from nested objects
Nested object properties are removed from the request body if a properties block is present in the object's schema unless they are ...
Read more >`additionalProperties` rule in JSON schema is not applied to ...
Is the additionalProperties JSON schema definition only applies to top-level fields and not to any nested level fields?
Read more >Schema allows additional properties
If you have nested combining operations inside each other (for example, allOf with anyOf nested in the properties), the correct additionalProperties value ...
Read more >Schema generation rules · GitBook - Goswagger.Io
To map this to go it creates a struct that has fixed names and a custom json ... "additionalProperties": {schema}, Y, Y, Y,...
Read more >Structuring a complex schema — Understanding JSON ...
Likewise in JSON Schema, for anything but the most trivial schema, ... A schema document that includes embedded schemas is called a Compound...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was trying
djv
but i will have to bring backajv
because i meet this issue on all my schema 😦@korzio would this issue be the cause of the following error?
Result from errorHandler:
From schema:
With data:
The error handlers I have for both ajv and tv4 pass the test with no objects added to the error array.