Skip to content

Latest commit

 

History

History
61 lines (52 loc) · 1.5 KB

README.md

File metadata and controls

61 lines (52 loc) · 1.5 KB

XSD To JSON Schema

Transforming XSD files into JSON Schema

Python script that converts XSD files into JSON Schema.

For example, transforming:

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="example" type="xs:string" nillable="true" />
</xs:schema>

Into:

{
    "properties": {
        "example": {
            "type": "string"
        }
    },
    "required": [
        "example"
    ],
    "$schema": "http://json-schema.org/schema#"
}

USAGE

CLI

Output JSON schema to stdout.

xsdtojson [PATH TO XSD FILE] --pretty

Output JSON schema to file

xsdtojson [PATH TO XSD FILE] > [PATH TO JSON OUTPUT FILE]

PYTHON

from xsdtojson import xsd_to_json_schema
json_schema = xsd_to_json_schema([PATH TO XSD FILE])

TODO