python-jsonschema / python-jsonschema/jsonschema
Make json look prettier in errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5k
- Forks
- 671
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Description
I'm not sure if this is a real issue or not, but something that bothered me is that validation errors use "%r" as a format string which causes your json to look pretty ugly in the error message with all strings looking like {u'key':u'value'} instead of {"key":"value"}.
In my json API when I return an error it might be confusing for the developer using my API that there's suddenly and u in a string because that's not valid JSON.
Of course I could build a custom error message from all the errors I get, but that would be a bit tedious. Would it be something to consider to print the schemas and validated data as json strings instead of python dicts in error messages?
Perhaps it's something worth discussing.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to validation errors that use %r; start by locating that formatting path and reviewing how schemas and validated data are rendered. Decide how error messages should represent these values, then verify that the resulting output is valid JSON without Python representation artifacts such as u prefixes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100