nuxt-open-fetch icon indicating copy to clipboard operation
nuxt-open-fetch copied to clipboard

Same schema on different request Methods

Open schillerenrico opened this issue 1 year ago • 6 comments

Environment

Reproduction

using a swagger.json like this

...

"/api/health/logs": {
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "Show logs",
        "description": "Show all application logs",
        "operationId": "ApplicationLogEndpoint",
        "parameters": [
          {
            "name": "user",
            "in": "query",
            "schema": {
              "type": "string",
              "default": "SYSTEM",
              "nullable": true
            }
          },
          {
            "name": "logLevel",
            "in": "query",
            "schema": {
              "default": "INFO",
              "nullable": true,
              "$ref": "#/components/schemas/LogLevelType"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginationResponseOfLog"
                },
                "example": [
                  {
                    "logLevel": "TRACE",
                    "eventUser": "SYSTEM",
                    "message": "Trace Log",
                    "data": null,
                    "created": "2024-07-11T09:19:00.6673497+02:00"
                  },
                  {
                    "logLevel": "DEBUG",
                    "eventUser": "SYSTEM",
                    "message": "Debug Log",
                    "data": null,
                    "created": "2024-07-11T09:19:00.6674457+02:00"
                  }
                ]
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiBadRequestResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiExceptionResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "JWTBearerAuth": []
          }
        ]
      },
      "delete": {
        "tags": [
          "Health"
        ],
        "summary": "Clear all logs",
        "description": "Clear all collected logs",
        "operationId": "ClearApplicationLogsEndpoint",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmptyResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiBadRequestResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiExceptionResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "JWTBearerAuth": []
          }
        ]
      }
    },

...

Describe the bug

When I request the "GET" the generated schema wanted me to provide "query" with pagesize and page. Thats totally fine. But if I request the "DELETE" it uses the same schema and wants me to provide page and pagesize as well.

Is this a bug or a swagger misconfiguration. Cause in swagger no parameters are needed for the "DELETE" method

Additional context

No response

Logs

No response

schillerenrico avatar Jul 11 '24 08:07 schillerenrico

image image

schillerenrico avatar Jul 12 '24 17:07 schillerenrico

hope this repo is still maintained 🙏 cause this module is helping so much

schillerenrico avatar Jul 30 '24 01:07 schillerenrico

We really need a solution for this problem. If we use an endpoint with different methods like POST PUT and GET and each one is giving another response, typescript is not distinguish between those methods in the response.

The typescript response schema is the same for ALL methods and thats wrong. I dont know how to solve this problem and it looks like a typescript bug in your module

schillerenrico avatar Oct 16 '24 12:10 schillerenrico

Hi @schillerenrico, Sorry for long delay. Could you please make a repro or provide an OpenAPI file?

enkot avatar Oct 31 '24 22:10 enkot

Hello @enkot, sure here is a bit of the json which results into the error openapi.json

When using the DELETE method typescript requires it to have a query property but that should not be the case for DELETE, just for the GET method image image

schillerenrico avatar Nov 04 '24 07:11 schillerenrico

Hi, is this problem solvable? Or do you need more information?

schillerenrico avatar Oct 01 '25 13:10 schillerenrico