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

Python tuples fail to validate as Json lists #94

Open
micpalmia opened this issue Sep 19, 2016 · 1 comment
Open

Python tuples fail to validate as Json lists #94

micpalmia opened this issue Sep 19, 2016 · 1 comment

Comments

@micpalmia
Copy link

micpalmia commented Sep 19, 2016

We are using @schema.validate on our controllers.
A property defined as

"properties": {
  "probability_list": {
    "type": "array"
  }
}

will unfortunately fail in case a Python tuple is passed instead of a list. json.dumps will always transform Python tuples to list, so I don't see why validate should raise an exception on encountering a tuple.

Any insight on how to solve this without having to transform all of my tuples into list before outputting them?

@micpalmia
Copy link
Author

micpalmia commented Sep 19, 2016

According to python-jsonschema/jsonschema#148 , a custom validator can be used to solve this issue. tornado-json's validate already allows to pass a format_checker, but this is only use for input validation, not for the output. Was this done on purpose? What would be the issue to passing the same checker when validating the output too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant