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

AttributeError is thrown when response does not have content defined in the spec file #12

Open
robert-dzikowski opened this issue Mar 23, 2020 · 1 comment

Comments

@robert-dzikowski
Copy link

robert-dzikowski commented Mar 23, 2020

openapi: 3.0.0

paths:
  /aggregationtypes:
    get:
      responses:
        "200":
          description: OK
          content:
            "*/*":
              schema:
                items:
                  $ref: "#/components/schemas/AggregationTypeDTO"
                type: array
        "401":
          description: Authorization token missing or invalid.
        "404":
          description: added by me -RD        
        "500":
          description: Unknown Error.
      tags:
        - aggregationtypes
      operationId: GetAggregationTypes
      summary: Returns a collection of AggregationTypeDTO

As you can see in the above specification 401, 404, 500 responses have no content, which is valid OpenAPI specification (https://swagger.io/docs/specification/describing-responses/). But when I call this Get request I get the following error for cases when status code is 401 or 404:

Traceback (most recent call last):
  File "C:/working/openapi3/my_main.py", line 49, in <module>
    main()
  File "C:/working/openapi3/my_main.py", line 16, in main
    make_http_requests(api, get_list)
  File "C:/working/openapi3/my_main.py", line 36, in make_http_requests
    response = function()
  File "C:\working\openapi3\openapi3\openapi.py", line 193, in __call__
    **kwargs)
  File "C:\working\openapi3\openapi3\paths.py", line 266, in request
    expected_media = expected_response.content.get(content_type, None)
AttributeError: 'NoneType' object has no attribute 'get'

@robert-dzikowski robert-dzikowski changed the title AttributeError is thrown when response does not have content defined AttributeError is thrown when response does not have content defined in the spec file Mar 23, 2020
@commonism
Copy link

should be fixed by #56

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