Improve handling of $ref in swagger files

It turns out that swagger merges $refed attributes with those defined inline,
so do the same here.
pull/977/head
Richard van der Hoff 9 years ago
parent 4c46c95d0e
commit 262c9ea113

@ -36,14 +36,18 @@ logger = logging.getLogger(__name__)
def resolve_references(path, schema):
if isinstance(schema, dict):
result = {}
for key, value in schema.items():
if key == "$ref":
# do $ref first
if '$ref' in schema:
value = schema['$ref']
path = os.path.join(os.path.dirname(path), value)
with open(path) as f:
schema = yaml.load(f)
return resolve_references(path, schema)
ref = yaml.load(f)
result = resolve_references(path, ref)
del schema['$ref']
else:
result = {}
for key, value in schema.items():
result[key] = resolve_references(path, value)
return result
elif isinstance(schema, list):

Loading…
Cancel
Save