hyperjump-io / json-schema

JSON Schema Validation, Annotation, and Bundling. Supports Draft 04, 06, 07, 2019-09, 2020-12, OpenAPI 3.0, and OpenAPI 3.1
https://json-schema.hyperjump.io/
MIT License
221 stars 21 forks source link

Validation output does not contain errors and other information after upgrading from 1.7.3 to 1.9.2 #64

Closed JeelRajodiya closed 4 months ago

JeelRajodiya commented 4 months ago

Output object in version 1.7.3

image

Output Object in version 1.9.2

image

I am trying to get the error messages in both the data validation and schema validation. but after upgrading these field seems to be disappeared. Is there any option I should pass to the validation function to get those error messages?

Code for hyperjump

image

Data

[1,2,3]

Schema

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
}
jdesrosiers commented 4 months ago

You get the FLAG output format by default. This format only contains information about whether the validation succeeded or failed. You need to use the BASIC output format to get details about what failed. Previously, the FLAG format was returning some properties that aren't part of the FLAG format. I removed that in the latest release because they don't provide any useful information anyway.

Documentation on how to set the output format is in the README

JeelRajodiya commented 4 months ago

Oh, Thanks! It is returning the errors now.

JeelRajodiya commented 4 months ago

I have was able to produce the errors for the data. But I also wish to produce the errors for the schema itself. as you have mentioned I have set the output format to BASIC. please see the code below

image

I am trying to get errors for the schema as well. for example if the user sets the type to stringg (which is invalid). I want to point that it is invalid. currently as per my code above hyperjump is throwing InvalidSchemaError: Invalid Schema. Which does not contain the information why the schema is invalid (please see the screenshot below)

image

Sorry, if I have missed something from the docs. But Is there any option which can give some information about why the schema is invalid? (in this case stingg is not a valid type)

jdesrosiers commented 4 months ago

InvalidSchemaError has a property called "output" that contains the validation results you're looking for. See the "Change the schema validation output format" section in the Output Formats documentation for an example.

JeelRajodiya commented 4 months ago

Thank you