-
Notifications
You must be signed in to change notification settings - Fork 161
Don't allow specify undefined property as required in schema #106
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
Comments
This is a good suggestion for a validation rule. Thanks! |
Just to be clear, const ZSchema = require('z-schema');
const validator = new ZSchema();
const schema = {
type: 'object',
properties: {
foo: {
type: 'string'
}
},
additionalProperties: false,
required: ['bar']
};
console.log(validator.validateSchema(schema)); // true |
Just to understanda the issue... why the schema in the OP is supposed to be wrong?? |
Right. It's more of a lint rule than a schema violation |
Isn't this kind of error a sign that the specification is incorrect. Trying to understand how can a property can be "required" but not defined in the schema. The swagger 2.0 validation option should treat this case as an error, right ? (validate options - Late edit: Functionality is present in the last version, apollogies for confusion i thought it was removed. |
Fixed in #179 - All the spec consistency checks were only used to work on Swagger 2.0 specs; All fixed now for OpenAPI v3.0 specs; Might get a chance to look into v3.1 changes later. |
Versions
8.12.0
6.0.2
Code example
API specification:
Expected behavior
Validation error: property
bar
is required, but it's not defined.Actual behavior
No errors.
The text was updated successfully, but these errors were encountered: