Skip to content

Instantly share code, notes, and snippets.

@gazpachoking
Last active December 13, 2015 22:18
Show Gist options
  • Save gazpachoking/4983299 to your computer and use it in GitHub Desktop.
Save gazpachoking/4983299 to your computer and use it in GitHub Desktop.
[
{
"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
}
]
}
]
{
"integer.json": {"type": "integer"},
"subSchemas.json": {
"integer": {"type": "integer"},
"refToInteger": {"$ref": "#/integer"}
},
"folder/folderInteger.json": {"type": "integer"}
}
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