connexion icon indicating copy to clipboard operation
connexion copied to clipboard

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

Open carloscbl opened this issue 1 year ago • 3 comments

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

carloscbl avatar Jul 31 '24 10:07 carloscbl

Is #2054 related to this?

In that issue I document how I cannot seen to return an octet-stream without getting this error unless I disable response validation.

alanbchristie avatar Jun 03 '25 13:06 alanbchristie

Would you please update this issue with a small self-contained code + spec example that exhibits the failure?

chrisinmtown avatar Jul 24 '25 13:07 chrisinmtown

Hi! Any chance for this issue to be resolved? We have the same problem

Boxap avatar Nov 03 '25 01:11 Boxap