jsonsystems / json-schema

JSONSchema.Net Public Repository
Apache License 2.0
663 stars 64 forks source link

Superfluous anyOf wrappers for array items. #113

Closed jdesrosiers closed 2 years ago

jdesrosiers commented 3 years ago

When using the default setting for "Array Validation", "AnyOf (single schema)" , schemas for arrays with only one type are generated with a superfluous singleton anyOf wrapper. This leads to confusion. It would be nice if the anyOf wrapper was only generated if there is more than one type.

jackwootton commented 3 years ago

I agree. Thank you for pointing this out. The backend is currently being rewritten and I will factor this into this requirements. Just to be sure, that instead of this

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "items": {
        "anyOf": [
            {
                "type": "string",
                "default": "",
                "examples": [
                    "home",
                    "green"
                ]
            }
        ]
    }
}

It's preferable to have

{
    "$schema": "http://json-schema.org/draft-07/schema",
    "items": {
        "type": "string",
        "default": "",
        "examples": [
            "home",
            "green"
        ]
    }
}
jackwootton commented 2 years ago

This has been fixed in the new version available at www.jsonschema.net