Skip to content

Correct way to spec response by status code #4

@Farenheith

Description

@Farenheith

Hello!

I'm testing your solution and it worked really well, but I got some problems and hope you could give me some guidance.

I have issues with status code 400 and 500 responses. Every time the api fails, the mcp fails as well with the following message:

TypeError: o.content is not iterable

In the container logs, I found the following

2025/11/04 16:11:11 [ExecuteToolCall] Request executed. Status Code: 400
2025/11/04 16:11:11 Received response body for tool 'getProductsBySearch': {"statusCode":400,"timestamp":"2025-11-04T16:11:11.711Z","path":"/v1/product/search","message":"Bad Request Exception","explicitMessage":"","data":["page must be a number conforming to the specified constraints","limit must be a number conforming to the specified constraints"]}

So, a structured return was detected, but maybe I did something wrong in the openai json.

"/v1/product/search": {
      "get": {
        "operationId": "getProductsBySearch",
        "parameters": [
          {
            "name": "application",
            "in": "header",
            "description": "Identificador da aplicação",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token-user-id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "token-user",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Esta chamada é usada para consultar produtos por termo de busca",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequestProductResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Requisição inválida ou erro de negócio.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDto"
                }
              }
            }
          },
          "500": {
            "description": "Erro interno do servidor.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponseDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "access-token": []
          }
        ],
        "summary": "Consultar produtos pelo termo de busca",
        "tags": [
          "Product"
        ]
      }
    },

Do you have any tips I could work on to adjust my open ai spec, or is it a bug that need to be fixed (I could try to contribute if that's the case)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions