-
-
Notifications
You must be signed in to change notification settings - Fork 581
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
Support standard output formats #1008
Comments
Hi there! This is certainly welcome/desired, though the implementation is a bit different. The output formats are actually being restructured heavily still (see json-schema-org/json-schema-spec#1249 and json-schema-org/json-schema-spec#1320) for the next release of the specification. What this means here is that certainly for now, though implementing them is very much desired and will be done, that the mechanism is going to follow more closely the API that exists here and has existed forever -- meaning -- I want this library, in its My quick pass previously was that that's indeed either fully possible or very nearly possible to do already today, simply by taking a bunch of Someone (if no one else, eventually me) then should package functions into a package which depends on this one and generates the specific output format (and I'm happy to host+promote that package in this org). So, a from jsonschema.validators import Draft2020Validator
import jsonschema_output2020
errors = Draft2020Validator(schema).iter_errors(123)
output = jsonschema_output2020.detailed(errors=errors)
print(json.dumps(output)) is what I believe is the right next step here, along with collecting any missing things from the If/when things stabilize upstream, it's possible that the functionality can fully move into this library, though it's something we can independently think about.
These objects have backwards compatibility guarantees, so regardless of anything else, this sort of thing wouldn't change, not without long deprecations. Hope that clarifies, and very much could use some help if you're interested in giving such a thing a shot. |
Thank you for the detailed answer. I encountered some problems using Granted, that only applies to |
Yes |
The standard draft 2020-12 defines four standard output formats: https://json-schema.org/draft/2020-12/json-schema-core.html#name-output-formatting
jsonschema
should provide ways to emit them and integrate them with its error structure:Validator
method with aformat
keyword argument that just emits a Python dict conforming to the chosen formatiter_errors
should match the errors in theBasic
formatDetailed
/Verbose
formatThe text was updated successfully, but these errors were encountered: