connexion icon indicating copy to clipboard operation
connexion copied to clipboard

Text content type always json

Open manoadamro opened this issue 5 years ago • 0 comments

Description

No matter which text type is under 'content', the response will always be aplication/json

Expected behaviour

text content types should be returned as text.

Actual behaviour

text content types are returned as invalid json.

Steps to reproduce

  /app:
    get:
      description: ""
      operationId: pyke.webapp.app.landing
      responses:
        200:
          description: ""
          content:
            text/html:
              schema:
                type: string
        default:
          $ref: '#/components/responses/Error'

response:

HTTP/1.0 200 OK
Content-Type: application/json
Content-Length: 3054
Server: Werkzeug/1.0.1 Python/3.8.2
Date: Tue, 12 May 2020 16:55:26 GMT
"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  ...  \n</html>"

Additional info:

CSS and Javascrript appear to work fine. Is there any reason why html does not?

Output of the commands:

  • python --version 3.8.2
  • pip show connexion | grep "^Version\:" 2.7.0

When I put a print statement here in OpenAPIOperation:

        for _, defn in self._responses.items():
            print(defn)
            response_content_types += defn.get('content', {}).keys()
        self._produces = response_content_types or ['application/json']

it prints:

{'x-scope': [''], 'description': '', 'content': {'text/css': {'schema': {'type': 'string'}}}}
{'x-scope': [''], 'description': '', 'content': {'text/html': {'schema': {'type': 'string'}}}}

{'x-scope': [''], 'description': '', 'content': {'text/css': {'schema': {'type': 'string'}}}}
{'x-scope': [''], 'description': '', 'content': {'text/html': {'schema': {'type': 'string'}}}}

{'x-scope': [''], 'description': '', 'content': {'text/html': {'schema': {'type': 'string'}}}}
{'x-scope': [''], 'description': '', 'content': {'text/html': {'schema': {'type': 'string'}}}}

{'x-scope': [''], 'description': '', 'content': {'text/html': {'schema': {'type': 'string'}}}}
{'x-scope': [''], 'description': '', 'content': {'text/html': {'schema': {'type': 'string'}}}}

basically each endpoint twice, sometimes with two different content types, each endpoint has exactly one method and one content type.

manoadamro avatar May 12 '20 17:05 manoadamro