jsonix icon indicating copy to clipboard operation
jsonix copied to clipboard

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

Open joneldiablo opened this issue 6 years ago • 4 comments
trafficstars

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

joneldiablo avatar Mar 19 '19 20:03 joneldiablo

There's no schema. Everything is documented here:

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

highsource avatar Mar 19 '19 20:03 highsource

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

joneldiablo avatar Mar 19 '19 21:03 joneldiablo

Handwritten.

highsource avatar Mar 19 '19 21:03 highsource

@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.

bezany avatar Mar 22 '19 13:03 bezany