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
Allow booleans to be scalar refs #215
Conversation
The JSON validation breaks when one uses `\1` or `\0` when using the serializion in conjuction with JSON::XS, Mojo::JSON and others. Signed-off-by: Wesley Schwengle <wesley@opndev.io>
I don't see any reason to accept this, since scalar refs is not a thing in JSON. Please provide a better argument for why/when this is needed. |
They all serialize \1 and \0 to true and false. Which is why I think the validation must respect this syntax as well. |
You still haven't given me any argument for when this is beneficial. |
If I use \1 or \0 in code somewhere and I pass it to the Mojolious Plugin for OpenAPI and I set it to validate the JSON before sending it out it croaks. I dug around and saw that the JSON validator which is used by that plugin doesn't allow this syntax. So when I try to validate the output the output is considered invalid while when I disable the validation it works fine and returns a boolean value as shown in the json-bool.pl example with the various serializers. Which leads me to 1) Not use the validation 2) Patch the validator that is accepts such values. I opted for 2 because I want to know when I do something wrong. Another workaround would be to serialize to json, deserialize it and then pass it to the validator after which another round of serialization happens. Which I find a bit counter intuitive. |
Ooops! Closed the wrong issue :( |
You should really just use Keeping it open a bit longer though in case other people have relevant information. |
And when I say |
From the documentation of Mojo::JSON:
From the documentation of Types::Serializer (used by JSON::XS):
I think Mojo::JSON is used by Mojo and thus by the OpenAPI plugin. So you are saying you don't want to support that native serializer? Seems odd but ok. |
Mojo::JSON doesn't use JSON::XS. |
I never said that. I just quoted their documentation and the docs of JSON::XS. |
- JSON::Validator::schema() now holds a JSON::Validator::Schema object instead of Mojo::JSON::Pointer - Add schema classes for Draft4, Draft6 and Draft7 - Add "duration" and "uuid" formats #210 - Fix coercing boolean "false" #215 - Fix not matching "null" should also be a "type" error #217 - Deprecated JSON::Validator::joi() - Deprecated JSON::Validator::singleton() - Deprecated JSON::Validator::validate_json() - Deprecated JSON::Validator::version() - Removed JSON::Validator::generate_definitions_path() - Removed support for JSON::Validator::bundle({ref_key => ...})
Going to close this issue, since I don't agree with the arguments given. |
The JSON validation breaks when one uses
\1
or\0
when using theserializion in conjuction with JSON::XS, Mojo::JSON and others.
Signed-off-by: Wesley Schwengle wesley@opndev.io