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

Always get AssertionError or KeyError in aiohttp #22

Open
CMCDragonkai opened this issue Aug 14, 2020 · 2 comments
Open

Always get AssertionError or KeyError in aiohttp #22

CMCDragonkai opened this issue Aug 14, 2020 · 2 comments

Comments

@CMCDragonkai
Copy link

I'm using this in aiohttp like:

    api_doc(
        app,
        config_path=(current_dir / "openapi.yaml").as_posix(),
        url_prefix='/',
        title="IAO API"
    )

And the server starts up fine.

But when I visit /. I get:

ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
  File "/nix/store/xw8zl3qcl8zha6wi7fns5rzmz2p1mqim-python3.7-aiohttp-3.6.2/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/nix/store/xw8zl3qcl8zha6wi7fns5rzmz2p1mqim-python3.7-aiohttp-3.6.2/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/nix/store/b93vasrvq42s3nhvrhlkjlaz55ji6qn0-python3.7-swagger-ui-py-0.3.0/lib/python3.7/site-packages/swagger_ui/core.py", line 154, in swagger_config_handler
    return web.json_response(self.get_config(request.host))
  File "/nix/store/b93vasrvq42s3nhvrhlkjlaz55ji6qn0-python3.7-swagger-ui-py-0.3.0/lib/python3.7/site-packages/swagger_ui/core.py", line 78, in get_config
    for server in config['servers']:
KeyError: 'servers'

And also:

image

@CMCDragonkai CMCDragonkai changed the title ALways get AssertionError or KeyError in aiohttp Always get AssertionError or KeyError in aiohttp Aug 14, 2020
@CMCDragonkai
Copy link
Author

Actually I realized it's because of openapi.yaml was not correct.

Wish the error reporting was a bit more obvious.

@PWZER
Copy link
Owner

PWZER commented Sep 27, 2021

@CMCDragonkai I think the validation of openapi.yaml should be done at editing time.

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

No branches or pull requests

2 participants