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

xsd choice with an element and a sequence generates an array type! #69

Open
veepuris opened this issue Jun 23, 2016 · 2 comments
Open

Comments

@veepuris
Copy link

Please see the Input XSD and the Output JSON below.
The "BackStub" is a choice between a single element("None") and a sequence("Period", "Calculation"). However, the generated JSON schema suggests the "BackStub" is an array with minItems=1 & maxItems=2.
This seems wrong to me, could you please advise?

Input XSD:

<xsd:complexType name="FloatingLegStubs">
    <xsd:sequence>
        <xsd:element name="FrontStub">
            <xsd:complexType>
                <xsd:choice>
                    <xsd:element name="None" type="ctr:None"/>
                    <xsd:sequence>
                        <xsd:element name="Period" type="ctr:FrontStubPeriod"/>
                        <xsd:element name="Calculation" type="ctr:StubCalculationStyle"/>
                    </xsd:sequence>
                </xsd:choice>
            </xsd:complexType>
        </xsd:element>
        <xsd:element name="BackStub">
            <xsd:complexType>
                <xsd:choice>
                    <xsd:element name="None" type="ctr:None"/>
                    <xsd:sequence>
                        <xsd:element name="Period" type="ctr:BackStubPeriod"/>
                        <xsd:element name="Calculation" type="ctr:StubCalculationStyle"/>
                    </xsd:sequence>
                </xsd:choice>
            </xsd:complexType>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

Output JSON:

    "FloatingLegStubs.BackStub":{
        "type":"object",
        "title":"FloatingLegStubs.BackStub",
        "required":[
            "noneOrPeriodAndCalculation"
        ],
        "properties":{
            "noneOrPeriodAndCalculation":{
                "title":"noneOrPeriodAndCalculation",
                "allOf":[
                    {
                        "type":"array",
                        "items":{
                            "anyOf":[
                                {
                                    "anyOf":[
                                        {
                                            "$ref":"#/definitions/None"
                                        }
                                    ],
                                    "elementName":{
                                        "localPart":"None",
                                        "namespaceURI":""
                                    }
                                },
                                {
                                    "anyOf":[
                                        {
                                            "$ref":"#/definitions/BackStubPeriod"
                                        }
                                    ],
                                    "elementName":{
                                        "localPart":"Period",
                                        "namespaceURI":""
                                    }
                                },
                                {
                                    "anyOf":[
                                        {
                                            "$ref":"#/definitions/StubCalculationStyle"
                                        }
                                    ],
                                    "elementName":{
                                        "localPart":"Calculation",
                                        "namespaceURI":""
                                    }
                                }
                            ]
                        },
                        "maxItems":2,
                        "minItems":1
                    }
                ],
                "propertyType":"elements"
            }
        },
        "typeType":"classInfo",
        "propertiesOrder":[
            "noneOrPeriodAndCalculation"
        ]
    }
@highsource
Copy link
Owner

Why (or what exactly) do you think it is wrong? Cardinality is correct, minimum is 1 element, maximum is 2 (Period, Calculation).

@veepuris
Copy link
Author

In my opinion, the representation is a bit misleading and cardinality is not of much help.

type:array
items/anyOf: [{None}, {Period}, {calculation}]
minItems:1
maxItems:2

Based on the excerpt from the above JSON,
it appears the array can possibly contain 2 "None" elements or 1 "Period" or 1 "Calculation" element which is incorrect..

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