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

[question] where or how can I get the jsonix types schema #216

Open
joneldiablo opened this issue Mar 19, 2019 · 4 comments
Open

[question] where or how can I get the jsonix types schema #216

joneldiablo opened this issue Mar 19, 2019 · 4 comments

Comments

@joneldiablo
Copy link

Hi! I'm trying to convert an xml schema to graphql schema, everything goings fine but I have this problem: the Duration definition, for example is a jsonix definition, so I can't get the schema to describe it, where or how can I get the schema like this:

name: 'global',
typeInfos: [{
        localName: 'TheObjectName',
        typeName: {....},
        propertyInfos: [{
            name: 'theObjectName',
            required: true,
            .....
          }]

this fragment was extracted from class file generated with the jsonix-schema-compiler-full.jar
the Jsonix.Schema.XSD[.....].INSTANCE (Jsonix.Schema.XSD.Duration.Instance for example) not have enough information

@highsource
Copy link
Owner

There's no schema. Everything is documented here:

https://github.com/highsource/jsonix/wiki/Mapping-XML-to-JavaScript-Objects

@joneldiablo
Copy link
Author

how do you do this jsonschema? http://www.jsonix.org/jsonschemas/w3c/2001/XMLSchema.jsonschema hardcoded? o.O

@highsource
Copy link
Owner

Handwritten.

@bezany
Copy link

bezany commented Mar 22, 2019

@highsource Hello! I have one question without new issue about XMLSchema.jsonschema. Why all simple type like integer allow null value, even if required?
For example, I have XSD:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="element" type="ElementType">
  </xsd:element>
  <xsd:complexType name="ElementType">
    <xsd:sequence>
      <xsd:element maxOccurs="1" minOccurs="1" name="integerElement" type="xsd:int"></xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

I generate JSON scheme java -jar node_modules/jsonix/lib/jsonix-schema-compiler-full.jar -d "mappings" -generateJsonSchema -p Test "schema/test.xsd".
And use json-schema-ref-parser for resolve $ref.
I got this fragment:

"integerElement": {
     "title": "integerElement",
     "allOf": [
      {
       "anyOf": [
        {
         "type": "integer",
         "maximum": 2147483647,
         "minimum": -2147483648
        },
        {
         "type": "null"
        }
       ],
       "description": "http://www.w3.org/TR/xmlschema-2/#int"
      }
     ],
     "propertyType": "element",
     "elementName": {
      "localPart": "integerElement",
      "namespaceURI": ""
     }
    }

integerElement is required, but allow null.
The reason because required and non-required property use same schema?
It is not problem for me, I not use null in my cases. Simple interesting.

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

3 participants