-
-
Notifications
You must be signed in to change notification settings - Fork 780
Closed
Description
connexion/jsonref.py:from jsonschema import RefResolver
because it can't parse yaml schema files like https://opensource.zalando.com/problem/schema.yaml
I workaround'd it in the jsonschema module
+++ b/jsonschema/validators.py
@@ -2,6 +2,7 @@ from __future__ import division
import contextlib
import json
+import yaml
import numbers
try:
@@ -466,12 +467,15 @@ class RefResolver(object):
# Requests has support for detecting the correct encoding of
# json over http
if callable(requests.Response.json):
- result = requests.get(uri).json()
- else:
- result = requests.get(uri).json
+ try:
+ result = requests.get(uri).json()
+ except ValueError:
+ result = None
+ if not result:
+ result = yaml.load(requests.get(uri).content)
else:
# Otherwise, pass off to urllib and assume utf-8
- result = json.loads(urlopen(uri).read().decode("utf-8"))
+ result = yaml.load(urlopen(uri).read().decode("utf-8"))
if self.cache_remote:
But on https://github.com/Julian/jsonschema/issues/420 it seems yaml is currently out of scope.
Can we fix it in connexion subclassing RefResolver?
Originally posted by @ioggstream in #678 (comment)
Guru67724
Metadata
Metadata
Assignees
Labels
No labels