gregsdennis/Manatee.Json

Validation fails when schema has examples key in properties.

juanlizarazo opened this issue · 6 comments

A basic schema like:

{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "type": "object",
  "properties": {
    "test": {
      "$id": "/properties/test",
      "type": "string",
      "title": "Test property",
      "description": "Test property",
      "default": "",
      "examples": [ "any string" ]
    }
  }
}

Where the examples key is included, fails validation and includes an error that reads:
Expected: Array; Actual: String though I am not defining any array in my schema.

If I remove the "examples" key from the schema, validation works as expected.

This works as expected with other validators as "examples" should have no effect in the validation.

array of examples with no validation effect;
http://json-schema.org/draft-06/json-schema-migration-faq.htmlce

Here I created a basic console app that reproduces the issue with both success and fail case (with and without the examples key):

Repo
Program.cs

Thanks for the report. I'll add a test and see if I can work this one out.

I've been able to replicate the issue on branch bug/141-examples.

Looking at this again, I'm not sure that the examples keyword really needs any validation. I might have gotten overzealous with creating validators.

I'll check the spec and return.

Yeah, it's just annotation. There's no validation that needs to occur for this keyword. I'll remove the validator and push a bug fix release to Nuget later today.

@juanlizarazo please see v9.7.1

Thank you @gregsdennis 🥇 !