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

draft-8 output format #754

Closed
jbomer opened this issue Jun 24, 2019 · 8 comments
Closed

draft-8 output format #754

jbomer opened this issue Jun 24, 2019 · 8 comments

Comments

@jbomer
Copy link

jbomer commented Jun 24, 2019

output format is one(schema) to many(errors) type

better for me is one(schema) to one(error) type

type Error = {
valid:boolean,
schemaLocation:string,//keyword in description
absoluteSchemaLocation:string
description:[keyword, message, ?instanceProperties(Items)[]]
//ex. for object
description:[
['properties', 'properties subschema error', ['bar', 'foo']]
['additionalProperties', 'additionalProperties subschema error', ['x', 'y']]
]
//ex. for array
description:[
['items', 'items subschema error',[3, 5]]
['allOf', 'allOf logic subschema(s) error']
]
//ex. for string
description:['maxLength', 'some constraint error message']

instanceLocation:string
errors:Error[]

}

@awwright
Copy link
Member

@jbomer You need clarify what the problem is. Is this an issue with the JSON Schema specification, or a library that you're using?

@jbomer
Copy link
Author

jbomer commented Jun 24, 2019

Too complicated and large JSON Schema specification draft-8 output format for me. No problem, only my idea.

@awwright
Copy link
Member

@jbomer I'm not sure what you mean by "output format". Where do you see that? Be specific.

@jbomer
Copy link
Author

jbomer commented Jun 24, 2019 via email

@gregsdennis
Copy link
Member

gregsdennis commented Jun 24, 2019

@awwright, I think he means the new standard output format in draft 8.

@jbomer I wrote that part. There are four different output formats

  • flag - a simple boolean to indicate pass/fail
  • basic - all errors are organized in a simple list
  • details - errors are organized in a condensed format that mimicks the schema
  • verbose - same as detailed, but not condensed; matches schema structure exactly

Which one was too complicated for you?

In response to your suggestion of using a dictionary for the output, we needed something more complex because each keyword has several points of data to report on

  • pass/fail
  • location relative to the root of the schema
  • absolute (direct) location without $refs
  • an error message or annotation value

You can easily transform this structure into whatever you need.

If you'd like to play around with it, my implementation, Manatee.Json (.Net), has a beta version that supports draft 8, including the output format.

Lastly, feel free to go read the issues that were opened to discuss a standardized output format. There's plenty of discussion there as to why we made the decisions we did.

@gregsdennis gregsdennis changed the title draft-8 otput fromat draft-8 output format Jun 24, 2019
@jbomer
Copy link
Author

jbomer commented Jun 25, 2019

detailed output (in draft-8 12.4.3):

{
"valid": false,
"keywordLocation": "#",
"instanceLocation": "#",
"errors": [
{
"valid": false,
"keywordLocation": "#/items/$ref",
"absoluteKeywordLocation":
"http://example.com/polygon#/$defs/point",
"instanceLocation": "#/1",
"errors": [
{
"valid": false,
"keywordLocation": "#/items/$ref/required",
"absoluteKeywordLocation":
"http://example.com/polygon#/$defs/point/required",
"instanceLocation": "#/1",
"error": "Required property 'y' not found."
},
{
"valid": false,
"keywordLocation": "#/items/$ref/additionalProperties",
"absoluteKeywordLocation":
"http://example.com/polygon#/$defs/point/additionalProperties",
"instanceLocation": "#/1/z",
"error": "Additional property 'z' found but was invalid."
}
]
},
{
"valid": false,
"keywordLocation": "#/minItems",
"instanceLocation": "#",
"error": "Expected at least 3 items but found 2"
}
]
}

my idea of this output:

{
"valid": false,
"shemaLocation": "#",
"instanceLocation": "#",
"error": "MinItems error. Items [1] subschema error.",
"keywords": [
["minItem"],
["items", [1]]
],
"errors": [
{
"valid": false,
"schemaLocation": "#/items/$ref/",
"instanceLocation": "#/1",
"error": "Required properties ['y'] not found. Additional propertis ['z'] subschema error",
"keywords": [
["required", ["y"]],
["additionalProperties", ["z"]]
]
}
]
}

@gregsdennis
Copy link
Member

gregsdennis commented Jun 25, 2019

Please format large code blocks. That's nearly impossible to read.

  1. You don't give an absolute location. This was a requirement.
  2. You're comparing a hierarchical output to a list output. Of course the list is going to be terser.
  3. Your array format has a lot of inference going on as to what each item is based on it's location in the array. Generally it's better to be explicit.
  4. In combining the invalid data points into the array structure, you're also having to combine all of the error messages with no linkage between the invalid value, the error message, and the keyword that produced it.
  5. This format isn't great for object-oriented languages. A language-agnostic solution needs to be considered.

The issue I linked was opened almost exactly a year ago (1y1d). You've has plenty of time to suggest an alternative. We're in final approval and now you want to change it. It's just not going to happen.

Maybe in the next version, but you'll need to explain the logic you're using to build your output format and how it fulfills all of the same data points and requirements. (I suggest you read those issues to find out what the requirements are.)

@Relequestual
Copy link
Member

Closing this issue because it sounds like you're asking for something which will be possible due to the different levels of output support.

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

4 participants