Last active
December 13, 2015 22:18
-
-
Save gazpachoking/4983299 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[ | |
{ | |
"description": "remote ref", | |
"schema": {"$ref": "http://localhost:1234/integer.json"}, | |
"tests": [ | |
{ | |
"description": "remote ref valid", | |
"data": 1, | |
"valid": true | |
}, | |
{ | |
"description": "remote ref invalid", | |
"data": "a", | |
"valid": false | |
} | |
] | |
}, | |
{ | |
"description": "fragment within remote ref", | |
"schema": {"$ref": "http://localhost:1234/subSchemas.json#/integer"}, | |
"tests": [ | |
{ | |
"description": "remote fragment valid", | |
"data": 1, | |
"valid": true | |
}, | |
{ | |
"description": "remote fragment invalid", | |
"data": "a", | |
"valid": false | |
} | |
] | |
}, | |
{ | |
"description": "ref within remote ref", | |
"schema": { | |
"$ref": "http://localhost:1234/subSchemas.json#/refToInteger" | |
}, | |
"tests": [ | |
{ | |
"description": "ref within ref valid", | |
"data": 1, | |
"valid": true | |
}, | |
{ | |
"description": "ref within ref invalid", | |
"data": "a", | |
"valid": false | |
} | |
] | |
}, | |
{ | |
"description": "change resolution scope", | |
"schema": { | |
"items": { | |
"id": "folder/", | |
"anyOf": [{"$ref": "folderInteger.json"}] | |
} | |
}, | |
"tests": [ | |
{ | |
"description": "changed scope ref valid", | |
"data": [1], | |
"valid": true | |
}, | |
{ | |
"description": "changed scope ref invalid", | |
"data": ["a"], | |
"valid": false | |
} | |
] | |
} | |
] |
This file contains hidden or 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
{ | |
"integer.json": {"type": "integer"}, | |
"subSchemas.json": { | |
"integer": {"type": "integer"}, | |
"refToInteger": {"$ref": "#/integer"} | |
}, | |
"folder/folderInteger.json": {"type": "integer"} | |
} |
This file contains hidden or 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
from flask import Flask, jsonify | |
app = Flask(__name__) | |
schemas_to_serve = json.load('schemasToServe.json') | |
for url, schema in schemas_to_serve: | |
app.route(url)(lambda: jsonify(schema)) | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment