Skip to content

issue with select generated for multiple oneOfs inside an allOf #143

@reffu42

Description

@reffu42

When attempting to render some data with schemas containing multiple oneOfs inside an allOf, some of the schemas don't seem to be added to the schemaList correctly, which causes the selects to throw errors on changing to certain values. I don't think the schema draft v4 disallows it, and I can logically think of a few scenarios where you'd want multiple groups of multiple choices (e.g. choose one from this and one from this, etc...). I've included a quick schema that I made to exemplify the problem (which is contrived and not how I would structure actual data, but exhibits the bug I've encountered). I attempted to backtrace the issue, and I think it might have something to do with some calls to removeSchema when handling xorSchemas, but I'm not sure. If you'd like more or better examples, I can post those as well. Thanks.

{
    "title": "clothing",
    "type": "object",
    "allOf": [
    {
        "title": "pants type",
        "oneOf": [
        {
            "title":"jeans",
            "properties": {
            "length": { "type": "number"},
            "width": { "type": "number"}
            },
            "required": ["width", "length"]
        },
        {
            "title":"shorts",
            "properties": {
            "size": {"type": "string", "enum": ["xs","s","m","l","xl","xxl","3xl"]}
            },
            "required": ["size"]
        }
        ]
    },
    {
        "title": "Shoe type",
        "oneOf": [
        {
            "title": "sneakers",
            "properties": {
            "lace_type" : {"type":"string", "enum":["laces","velcro","slip_on"], "default":"laces"},
            "shoe_size": { "type": "number"}
            },
            "required": ["size"]
        },
        {
            "title":"sandals",
            "properties": {
            "strap_type": {"type": "string", "enum": ["sandal", "flipflop"]}
            },
            "required": ["strap_type"]
        }
        ]
    },
    {
        "properties": {
        "matches":{"type":"boolean"}
        },
        "required": ["matches"]
    }
    ]
}

I've been testing my schema with

var a = 'json schema data from file or server'
var data = Jsonary.create({})
var schema = Jsonary.createSchema(a)
data.addSchema(schema)
Jsonary.render($('#main')[0], data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions