RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.4k stars 534 forks source link

BooleanExpected schema validation failure using Yaml #1627

Open buzzbonner opened 1 year ago

buzzbonner commented 1 year ago

Hi,

Version: NJsonSchema and NJsonSchema.Yaml v10.9.0

When generating a schema from Yaml that contains boolean values, such the Source Object shown below. The generated schema defines an object with a single property Visible of type boolean.

However, when running validation this fails with an BooleanExpected message.

Note: No validation message is generated if the generated schema output is modified from "boolean" to "bool".

Source Object Options: Visible: true

Schema Object "Options": { "type": "object" "properties": {" "Visible": { "type": "boolean" } } }

Question:

  1. Should the generator have created "boolean" types as "bool"?
  2. Can the generator be configured so it generates booleans as "bool"?
  3. Can the validation to configured so it accepts "boolean", rather than "bool" so no BooleanExpected failure occurs?
trejjam commented 1 year ago

OpenApi knows bool type as Boolean, so the Validation should be probably fixed. Not the other way around

buzzbonner commented 1 year ago

Thanks for the reply!!

On Mon, 30 Oct 2023, 22:31 Jan Trejbal, @.***> wrote:

OpenApi knows bool type as Boolean https://swagger.io/docs/specification/data-models/data-types/#boolean, so the Validation should be probably fixed. Not the other way around

— Reply to this email directly, view it on GitHub https://github.com/RicoSuter/NJsonSchema/issues/1627#issuecomment-1786149150, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABUPFGA3EWHFMRXL4Y4LPJTYCATFZAVCNFSM6AAAAAA5C5MBO2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBWGE2DSMJVGA . You are receiving this because you authored the thread.Message ID: @.***>