Created
July 12, 2016 04:01
-
-
Save takaki/17a66ffb42e648d565d7bd24c11230f0 to your computer and use it in GitHub Desktop.
PythonのDSLでJSON Schemaを書く ref: http://qiita.com/takaki@github/items/2d92c5ce00869aa8d432
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"title": "Example Schema", | |
"type": "object", | |
"properties": { | |
"firstName": { | |
"type": "string" | |
}, | |
"lastName": { | |
"type": "string" | |
}, | |
"age": { | |
"description": "Age in years", | |
"type": "integer", | |
"minimum": 0 | |
} | |
}, | |
"required": ["firstName", "lastName"] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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