Skip to content

Failing to infer content when application/problem+json is present in another response code #1956

@carloscbl

Description

@carloscbl

Description

When having 2 reponse types one is problem+json is unable to infer response

Expected behaviour

Should be able to infer that is a dictionary with no header and asume is json response or just check 200 response is always application/json

Actual behaviour

if another response like 401 is present with a different content type like application/problem+json should still be able to infer is a json

Steps to reproduce

as API

  /potato/advanced-configuration:
    get:
      summary: xxx
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/xxx'
        '401':
          description: Returned if the calling user does not have permission to perform the operation.
          content:
            application/problem+json:
              schema:
                $ref: ../common/models/error.v1.yaml
      operationId: configuration.get_configuration
def get_configuration():
    try:
        response = cb_conf.read_conf() or {}
        status_code = 200

    except Exception as ex:
        logging.error(f"Error getting configuration: {ex}")
        response, status_code = unexpected_exception(ex), 400
    print(response, status_code)
    return response, status_code

Additional info:

{"time": "2024-07-31T10:51:30Z", "format_version": 1, "level": "ERROR", "message": "NonConformingResponseHeaders(status_code=500, detail='Multiple response content types are defined in the operation spec, but the handler response did not specify which one to return.')", "microservice": "cbclient", "funcName": "problem_handler", "threadName": "AnyIO worker thread"}

Output of the commands:

  • python --version 3.11
  • pip show connexion | grep "^Version\:" 3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions