Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
reffu42 opened this issue Jul 24, 2014 · 1 comment
Open

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

reffu42 opened this issue Jul 24, 2014 · 1 comment

Comments

@reffu42
Copy link

reffu42 commented Jul 24, 2014

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)
@geraintluff
Copy link
Contributor

Ooh, hairy. :) I'll try and have a look at it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants