Open sohilpandya opened 8 years ago
npm i -g bower
. (strange decision by developer to have dependencies across both bower
and npm
. You will notice that the documentation for getting a simple schema up and running is not so straight forward, so here is what I suggest:
schemas
folder with the following structure:
{
"id": "schema.json#",
"$schema": "http://json-schema.org/draft-04/schema#",
"version": "1.1.3",
"description": "schema for ADIwg mdJSON metadata",
"type": "object",
"required": ["version", "contact", "metadata"],
"properties": {
"user": {
"$ref": "sub-schema/user.json",
"example": "../schema-example/user.json"
}
}
}
{
"id": "user.json#",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Contains user details",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"address": {
"type":"object",
"properties": {
"billing_address": {
"$ref": "address.json",
"example": "../schema-example/address.json"
},
"delivery_address": {
"$ref": "address.json",
"example": "../schema-example/address.json"
}
}
},
"age": {
"type":"number",
"maxValue": 100
}
}
}
{
"id": "address.json#",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Contains user address",
"properties": {
"street_name": {
"type": "string"
},
"city": {
"type": "string"
},
"postcode": {
"type": "string"
},
"country": {
"type": "string"
}
}
}
json-schema-viewer.json
filegrunt prod
npm i -g grunt
grunt connect:server:keepalive
_And it should look something like this 🎉 _
To add examples for each json file, simple add some examples in json file and link it to the schema
user.json
{
"id": "user.json#",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Contains user details",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"address": {
"type":"object",
"properties": {
"billing_address": {
"$ref": "address.json",
"example": "../schema-example/address.json"
},
"delivery_address": {
"$ref": "address.json",
"example": "../schema-example/address.json"
}
}
},
"age": {
"type":"number",
"maxValue": 100
}
}
}
Having experimented with this a little more, I feel that JSON Schema Viewer is rough around the edges, It works great if your schema is not too complex.
Why You have a really great schema in place, which is understood by all the technical people in your team, but what about the non-technical people? Visualisation of a schema will lead to better understanding of the schema across the team.
How We will use JSON Schema Viewer to visualise the schema