Skip to content

Instantly share code, notes, and snippets.

@takaki
Created July 12, 2016 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takaki/17a66ffb42e648d565d7bd24c11230f0 to your computer and use it in GitHub Desktop.
Save takaki/17a66ffb42e648d565d7bd24c11230f0 to your computer and use it in GitHub Desktop.
PythonのDSLでJSON Schemaを書く ref: http://qiita.com/takaki@github/items/2d92c5ce00869aa8d432
{
"title": "Example Schema",
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"description": "Age in years",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName"]
}
import jsl
class Example(jsl.Document):
class Options(object):
title = "Example Schema"
firstName = jsl.StringField(required=True)
lastName = jsl.StringField(required=True)
age = jsl.IntField(description="Age in years", minimum=0)
import json
print(json.dumps(Example.get_schema(ordered=True), indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment