new proposed output format #195
Replies: 6 comments 27 replies
This comment has been hidden.
This comment has been hidden.
-
Can you post the schema/instance that generated that output? I'll run it through my implementation, which now has a branch for the proposal at #63. I'd like to see what that shows for comparison. |
Beta Was this translation helpful? Give feedback.
-
What would annotations look like in this format? For those you need to know the keyword that generated the annotation. You can discern this with only data location and annotation value. {
"properties": {
"foo": {
"default": "this might be the description",
"description": "or this could be"
}
}
} |
Beta Was this translation helpful? Give feedback.
-
So that it's not buried in Slack, copy pasting my brief opinion (brief in the sense that I have not thought hard here so if I'm way off on the key topic being discussed feel free to say so):
|
Beta Was this translation helpful? Give feedback.
-
In a (rather heated and lengthy) discussion in Slack, I expressed that I would be okay with a format like this being in supplementary material as mere guidance for applications that consume JSON Schema, but it does not belong in the spec. The spec cannot be expected to prescribe what applications show to their users. The needs of an application's users are something that only the designers & developers of that application can fully understand. Historically, the spec has been firmly grounded in the validation of JSON data. This is why we have shied away from alternate uses like forms or code generation. The language in the spec is already validation-centric rather than application-centric. Applications using JSON Schema are related but separate. As such the spec can and should define an output format implementations can use in order to communicate the results of a validation to a host application. This interaction is solely between machines, namely the implementation, which is the representative of the specification, and the application that is consuming it. The specification cannot define output for:
The prescribed output need only apply to implementations of the specification which are made available for general use (i.e. for unknown consumers). These unknown consumers would need to be designed to accept the prescribed output and manipulate it to suit their consumers' (whether machine or human) needs, which is outside the purview of the spec. |
Beta Was this translation helpful? Give feedback.
-
Here's a use in the wild of an output format very similar to this: OAI/OpenAPI-Specification#2983 I am going ahead and adding this format to my own implementation, and will make more refinements going forward after it sees some use in the wild. I see no way of closing this discussion. |
Beta Was this translation helpful? Give feedback.
-
I've been using this output format in my implementation for quite some time -- it only shows the data location of an error, not the keyword location, and is suitable for situations where the schema is not published and therefore keyword locations are not helpful, or as a quick way to show the source of all errors (for example when the schema itself has an error and cannot be validated).
Here's an example from one of my schemas where I had an
allOf
indented at the wrong level in the openapi yaml file, and therefore loading it into an openapi tool throws an exception:Here is the same result in 'basic' format -- as you can see it is much more verbose, and more difficult for a poor user to figure out what went wrong:
The format is essentially
sprintf("at '%s': %s", instanceLocation, error)
, in the standard evaluation order, with any duplicate lines removed (sometimes several errors are issued at the same instance location (the first error is actually repeated 7 times in the original because it comes from the top level of every vocabulary -- "I expected to see a schema here, but instead got an array").I would like to formalize this into the spec as a format called something like 'compact' or 'abridged', as I find it quite useful in some applications - e.g. I use it in the exception message thrown when a schema is not considered valid by my implementation. Note that this is a string, not a json object (although it can be used as a json array simply enough, where each line is an array item).
Beta Was this translation helpful? Give feedback.
All reactions