Skip to content
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

With YAML::Syck, additionalProperties: false is treated as true #27

Closed
perlpunk opened this issue Aug 13, 2016 · 1 comment
Closed

With YAML::Syck, additionalProperties: false is treated as true #27

perlpunk opened this issue Aug 13, 2016 · 1 comment
Assignees
Labels

Comments

@perlpunk
Copy link

perlpunk commented Aug 13, 2016

When using YAML::Syck, the validator does not complain about
additional properties, despite additionalProperties: false

use JSON::Validator;
my $validator = JSON::Validator->new;

my $schema_file = $ARGV[0] || "/path/to/schema.yaml";
$validator->schema($schema_file);

my @errors = $validator->validate(
    {
        firstName => "Jan Henning",
        lastName => "Thorsen",
        age => 42,
    },
);
# YAML::XS: like expected: "/: Properties not allowed: age."
# YAML::Syck: no errors
say for @errors;

schema.yaml:

---
type: object
required: [firstName, lastName]
additionalProperties: false
properties:
    firstName: { type: string }
    lastName: { type: string }

https://github.com/jhthorsen/json-validator/blob/master/lib/JSON/Validator.pm#L548
here $additional has the value false as a string.

@jhthorsen jhthorsen added the bug label Aug 16, 2016
@jhthorsen jhthorsen self-assigned this Aug 16, 2016
@jhthorsen
Copy link
Owner

Thanks for the excellent test case! 👍

Going to make a new release on CPAN in a couple of hours.

jhthorsen pushed a commit that referenced this issue Aug 16, 2016
 - Fix handling of true/false in schema, when loaded with YAML::Syck #27
 - Add EXPERIMENTAL support for passing $json_path to validate()
jhthorsen pushed a commit that referenced this issue Oct 23, 2018
 - Add EXPERIMENTAL naming of swagger routes #27
 - Add "swagger_operation_spec" to route defaults #30
 - Allow x-mojo-around-action to be inherited #30
 - Allow x-mojo-controller to be inherited
 - Swagger2::SchemaValidator is back because JSON::Validator cannot be Swagger specific
jhthorsen pushed a commit that referenced this issue Oct 23, 2018
 - Add support for using operationId instead of x-mojo-controller #36 #37
 - Add "swagger_route_added" event #27
 - Remove "valid" from standard error structure since it was redundant
 - Documented how to include http://git.io/vcKD4
elcamlost pushed a commit to elcamlost/json-validator that referenced this issue Aug 30, 2019
elcamlost pushed a commit to elcamlost/json-validator that referenced this issue Aug 30, 2019
elcamlost pushed a commit to elcamlost/json-validator that referenced this issue Aug 30, 2019
 - Fix handling of true/false in schema, when loaded with YAML::Syck jhthorsen#27
 - Add EXPERIMENTAL support for passing $json_path to validate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants