Skip to content

meteorbites/jsonschema2xsd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

JSON Schema (Draft-03) conversion to XSD.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published