Open kronstein opened 3 years ago
Kotlin openapi-generator ignores style: deepObject explode: true query param options.
style: deepObject
explode: true
``` openapi: 3.0.0 ... paths: /tags/: get: summary: Get all tags parameters: - $ref: '#/components/parameters/TagsFilter' responses: "200": description: Array of tags content: application/json: schema: type: object properties: meta: $ref: '#/components/schemas/ListMetaInfo' data: type: array items: $ref: '#/components/schemas/TagModel' "400": $ref: '#/components/responses/BadRequest' default: $ref: '#/components/responses/ServerError' ... parameters: TagsFilter: name: filter description: | Tag filter. Should be serialized as: filter[filter1name]=filter1val&filter[filter2name]=filter2val. in: query required: false schema: type: object properties: important: type: boolean description: | Important tags only. example: true style: deepObject explode: true ... ```
The output produced:
data class Filter ( @Json(name = "important") val important: kotlin.Boolean? = null ) @GET("tags/") suspend fun tagsGet(@Query("filter") filter: Filter? = null): Response<InlineResponse2001>
Actual: https://host/tags/?filter=Filter%28important%3Dtrue%29 Expected: https://host/tags/?filter[important]=true
https://host/tags/?filter=Filter%28important%3Dtrue%29
https://host/tags/?filter[important]=true
Unfortunately, retrofit2 doesn't have advanced custom parameter type handling yet. See https://github.com/square/retrofit/issues/626 for details.
Suggested workaround:
suspend fun tagsGet(filter: Filter? = null) = tagsGet(filter?.important) @GET("tags/") suspend fun tagsGet(@Query("filter[important]") filterImportant: Boolean? = null): Response<InlineResponse2001>
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Is your feature request related to a problem? Please describe.
Kotlin openapi-generator ignores
style: deepObject
explode: true
query param options.Spec (click to view)
``` openapi: 3.0.0 ... paths: /tags/: get: summary: Get all tags parameters: - $ref: '#/components/parameters/TagsFilter' responses: "200": description: Array of tags content: application/json: schema: type: object properties: meta: $ref: '#/components/schemas/ListMetaInfo' data: type: array items: $ref: '#/components/schemas/TagModel' "400": $ref: '#/components/responses/BadRequest' default: $ref: '#/components/responses/ServerError' ... parameters: TagsFilter: name: filter description: | Tag filter. Should be serialized as: filter[filter1name]=filter1val&filter[filter2name]=filter2val. in: query required: false schema: type: object properties: important: type: boolean description: | Important tags only. example: true style: deepObject explode: true ... ```
The output produced:
Actual:
https://host/tags/?filter=Filter%28important%3Dtrue%29
Expected:https://host/tags/?filter[important]=true
Describe the solution you'd like
Unfortunately, retrofit2 doesn't have advanced custom parameter type handling yet. See https://github.com/square/retrofit/issues/626 for details.
Suggested workaround: