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

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

Open
carloscbl opened this issue Jul 31, 2024 · 0 comments · May be fixed by #1957
Open

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

carloscbl opened this issue Jul 31, 2024 · 0 comments · May be fixed by #1957

Comments

@carloscbl
Copy link

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
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

Successfully merging a pull request may close this issue.

1 participant