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

pyyaml 6.0 breaks loading of yaml files #4

Open
OysteinBrandt opened this issue Nov 29, 2021 · 1 comment
Open

pyyaml 6.0 breaks loading of yaml files #4

OysteinBrandt opened this issue Nov 29, 2021 · 1 comment

Comments

@OysteinBrandt
Copy link

  • aiohttp swagger plugin version: 0.1.0
  • aiohttp version: 3.7.4.post0
  • pyyaml version: 6.0

Description

Tried to render Swagger UI for my service at the /api/doc/ endpoint.

What happened

Swagger IU renders Internal Server Error (Failed to load API definition).

What went wrong

Loading of yaml file fails because of breaking changes in PyYAML 6.0.

Expected to happen

Provided yaml is rendered in Swagger UI.

What I Did

[29/Nov/2021:13:28:52 +0000] "GET /api/doc/ HTTP/1.1" 200 2046 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
[ERROR]	load() missing 1 required positional argument: 'Loader'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp_middlewares/error.py", line 208, in middleware
    return await handler(request)
  File "/usr/local/lib/python3.8/site-packages/jibrel_aiohttp_swagger/handlers.py", line 11, in spec_handler
    json_content = load_spec_file(spec_path)
  File "/usr/local/lib/python3.8/site-packages/jibrel_aiohttp_swagger/utils.py", line 29, in _wrapped
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/jibrel_aiohttp_swagger/utils.py", line 39, in load_spec_file
    content = yaml.load(fp)
TypeError: load() missing 1 required positional argument: 'Loader'

Related issue at PyYAML

yaml/pyyaml#576

@OysteinBrandt
Copy link
Author

A temporary workaround is to set a fixed version of pyyaml in your requirements file.
I.e. pyyaml ~= 5.4.1
Then the Swagger UI renders as expected.

Log output:

[29/Nov/2021:15:49:00 +0000] "GET /api/doc/ HTTP/1.1" 200 2046 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"
/usr/local/lib/python3.8/site-packages/jibrel_aiohttp_swagger/utils.py:39: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  content = yaml.load(fp)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant