/jsonschema2xsd

JSON Schema (Draft-03) conversion to XSD.

Primary LanguageJavaScript

jsonschema2xsd

JSON Schema (Draft-03) conversion to XSD.

Install

$ git clone https://github.com/donniegallardo/jsonschema2xsd.git
$ cd  jsonschema2xsd/
$ npm install -g

Running the program

$ jsonschema2xsd

Example command usage:

Command Description
jsonschema2xsd -h Displays help
jsonschema2xsd schema.xsd Converts schema file to xsd
jsonschema2xsd -f schema.xsd Converts schema file to xsd
jsonschema2xsd -u https://.../basicschema.json Converts schema to xsd
`cat schema.json jsonschema2xsd`

Sample JSON Schema

{
    "title": "Person",
    "type": "object",
    "properties": {
        "firstName": {
            "type": "string"
        },
        "lastName": {
            "type": "string"
        },
        "age": {
            "description": "Age in years",
            "type": "integer",
            "minimum": 0
        }
    }
}

Sample XSD Schema generated by the tool

<?xml version="1.0"?>
<xs:schema 
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Person">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="firstName" type="xs:string"/>
        <xs:element name="lastName" type="xs:string"/>
        <!--Age in years-->
        <xs:element name="age">
          <xs:simpleType>
            <xs:restriction base="xs:integer">
              <xs:minInclusive value="0"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

LIMITATIONS

REFERENCES

It's still a work in progress... Code has not been refactored, prettified or modularized as of this moment. Currently on prototyping phase. No automated test as of the moment.