Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#60 fix pyaml load file #65

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions aiohttp_swagger/helpers/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _extract_swagger_docs(end_point_doc, method="get"):
# Build JSON YAML Obj
try:
end_point_swagger_doc = (
yaml.load("\n".join(end_point_doc[end_point_swagger_start:]))
yaml.full_load("\n".join(end_point_doc[end_point_swagger_start:]))
)
except yaml.YAMLError:
end_point_swagger_doc = {
Expand Down Expand Up @@ -101,7 +101,7 @@ def nesteddict2yaml(d, indent=10, result=""):
)

# The Swagger OBJ
swagger = yaml.load(swagger_base)
swagger = yaml.full_load(swagger_base)
swagger["paths"] = defaultdict(dict)

for route in app.router.routes():
Expand All @@ -114,7 +114,7 @@ def nesteddict2yaml(d, indent=10, result=""):
with open(route.handler.swagger_file, "r") as f:
end_point_doc = {
route.method.lower():
yaml.load(f.read())
yaml.full_load(f.read())
}
except yaml.YAMLError:
end_point_doc = {
Expand Down Expand Up @@ -152,7 +152,7 @@ def nesteddict2yaml(d, indent=10, result=""):


def load_doc_from_yaml_file(doc_path: str):
loaded_yaml = yaml.load(open(doc_path, "r").read())
loaded_yaml = yaml.full_load(open(doc_path, "r").read())
return json.dumps(loaded_yaml)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def test_swagger_def_decorator(test_client, loop):
@pytest.fixture
def swagger_info():
filename = abspath(join(dirname(__file__))) + "/data/example_swagger.yaml"
return yaml.load(open(filename).read())
return yaml.full_load(open(filename).read())


@asyncio.coroutine
Expand Down