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

Validate response body fails on empty response with Python 3 #134

Open
gabisurita opened this issue Dec 5, 2016 · 1 comment
Open

Validate response body fails on empty response with Python 3 #134

gabisurita opened this issue Dec 5, 2016 · 1 comment

Comments

@gabisurita
Copy link

gabisurita commented Dec 5, 2016

I'm writing a test suite with .tox to validate a spec against an existing API and this error is raised with Python 3.4 and Python3.5. Apparently empty bytearrays aren't considered on EMPTY_BODIES.

    def validate_response_body(op, response_spec, response):
        """Validate an outgoing response's body against the response's Swagger
        specification.
        :type op: :class:`bravado_core.operation.Operation`
        :type response_spec: dict
        :type response: :class:`bravado_core.response.OutgoingResponse`
        :raises: SwaggerMappingError
        """

        deref = op.swagger_spec.deref
        # response that returns nothing in the body
        response_body_spec = deref(response_spec.get('schema'))
        if response_body_spec is None:
            if response.text in EMPTY_BODIES:
                return
            raise SwaggerMappingError(
>               "Response body should be empty: {0}".format(response.text))
E           bravado_core.exception.SwaggerMappingError: Response body should be empty: b''
@ngaya-ll
Copy link

Currently EMPTY_BODIES is defined as (None, '', '{}', 'null'). For Python 3 compatibility, this should probably be (None, b'', u'', '{}', 'null').

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