-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] [JAVA] Using an object to pass query params ends up using the toString of that class #4808
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@lwlee2608 @Zomzog @karismann is there any update regarding this? Wanted to know if this is a known issue that will be fixed soon |
Maybe this can be fixed by modifying |
There is a similar issue when sending POST data parameters that should be JSON-encoded - e.g.
This is valid in OpenAPI 3 according to https://swagger.io/docs/specification/describing-request-body/ (see "Complex Serialization in Form Data"). However, this does not work because the |
+1 |
I'm experiencing the same issue, though I'm not sure what @mtohmaz would expect regarding the key. I would expect the client to translate it to This lines up with how the parameters are serialized in a spring backend, since #2655 is fixed. A recent issue is #8352, which addresses the same issue, but then without specifying explicit properties on the object. In that case a Map is generated. The PR over there won't fix this issue. |
I am also experiencing this issue, is anybody trying to fix it with a PR? |
I also have this problem, I have to edit the source code after generated. |
I opened a PR that should fix this issue. |
I still see this issue in latest release. When will the fix be released? |
Seems to still be an issue, and is presumably related to #907 The Here's my stripped down API definition in which I end up seeing it as well: {
"openapi": "3.0.1",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"paths": {
"/v2/folders/{folderName}/search": {
"get": {
"operationId": "searchFolderGet",
"parameters": [
{
"description": "Case-sensitive folder name",
"in": "path",
"name": "folderName",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "All search criteria to use for searching",
"in": "query",
"name": "allSearchCriteria",
"required": true,
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/SearchCriteria"
}
},
"style": "form"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SearchResults"
}
}
},
"description": "OK"
}
},
"summary": "Search the 'folderName' folder for documents based on the provided search criteria"
}
}
},
"components": {
"schemas": {
"Hit": {
"type": "object",
"properties": {
"content": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
}
},
"displayValues": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"docId": {
"type": "string"
},
"mimeType": {
"type": "string",
"enum": [
"PDF",
"TIFF",
"ZIP"
]
}
}
},
"SearchCriteria": {
"title": "SearchCriteria",
"required": [
"name",
"operator",
"searchValue1"
],
"type": "object",
"properties": {
"name": {
"title": "name",
"type": "string",
"description": "Search criteria name"
},
"operator": {
"title": "operator",
"type": "string",
"description": "Search criteria operator",
"enum": [
"EQUAL",
"NOT_EQUAL",
"LESS_THAN",
"LESS_THAN_EQUAL",
"GREATER_THAN",
"GREATER_THAN_EQUAL",
"IN",
"NOT_IN",
"LIKE",
"NOT_LIKE",
"BETWEEN",
"NOT_BETWEEN"
]
},
"searchValue1": {
"title": "searchValue1",
"type": "string",
"description": "Search criteria search value 1"
},
"searchValue2": {
"title": "searchValue2",
"type": "string",
"description": "Search criteria search value 2 (optional)",
"nullable": true
}
},
"description": "A single search criteria entity"
},
"SearchResults": {
"type": "object",
"properties": {
"hits": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Hit"
}
},
"searchMessage": {
"type": "string"
}
}
}
}
}
} I've tried different |
@tomcruise81 Which generator are you using? |
@sorin-florea - any ideas? |
I fell into the same issue with
|
@tomcruise81 sorry if I was not clear, do you use the native or apachehttpclient generators? Or something else? |
@BenderRodrigez, this is not fixed for retrofit. The native generator should work though it still has some edge cases in which it doesn't properly work (using Ping me on the openapi-generator slack if you need any help with it. |
I was providing: "library": "resttemplate",
"openApiNullable": false |
@tomcruise81 only native and apachehttp are fixed. |
@wing328 - as stated by @sorin-florea, this issue isn't fully resolved. Please re-open it as it has only been partially fixed. Thanks! |
Doesn't work with java weblient generation in openapi-generator-maven-plugin:6.40. Generates same error as #4808 (comment) ie In Swagger UI it creates the expected
|
If you're using WebClient, you want the bug over at #14691 |
Description
When specifying the query parameters for an endpoint as an object and generate a Java SDK using openapi-generator-cli, it will actually use the class's toString as the query parameter values instead. For example, here is a sample config I have for openapi version 3.
After generating the java SDK and make a request like so:
The request is received by my endpoint, but this is what the query params look like:
{"query_params"=>"class QueryParams {\n to: Person\n from: null\n}"}
openapi-generator version
4.2.1-SNAPSHOT
Command line used for generation
The text was updated successfully, but these errors were encountered: