nuxt-open-fetch
nuxt-open-fetch copied to clipboard
Same schema on different request Methods
Environment
- Operating System: Windows_NT
- Node Version: v20.15.0
- Nuxt Version: 3.12.3
- CLI Version: 3.12.0
- Nitro Version: 2.9.7
- Package Manager: [email protected]
- Builder: -
- User Config: css, ssr, devtools, modules, runtimeConfig, ui, colorMode, app, openFetch, vue, compatibilityDate, future, srcDir
- Runtime Modules: @nuxt/[email protected], @vueuse/[email protected], [email protected], [email protected]
- Build Modules: -
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
hope this repo is still maintained 🙏 cause this module is helping so much
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
Hi @schillerenrico, Sorry for long delay. Could you please make a repro or provide an OpenAPI file?
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
Hi, is this problem solvable? Or do you need more information?