Problem
I have the following OpenAPI 3.1 schema:
{
...,
"/v1/resource/": {
"get": {
"operationId": "getPage",
"parameters": [
{
"in": "query",
"name": "slug",
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"explode": false,
"style": "form"
}
]
}
}
According to the OpenAPI docs, "style": "form" with "explode": false should produce a comma separated list of values, e.g. ?slug=one,two,three, but the generated Feign client ends up creating a request with exploded parameters.
Generated client method looks something like this:
@RequestLine("GET /v1/reagent/?slug={slug}")
@Headers("Accept: application/json")
public fun getResourcePage(
@Param("slug") slug: List<String>? = null,
@HeaderMap additionalHeaders: Map<String, String> = emptyMap(),
@QueryMap additionalQueryParameters: Map<String, String> = emptyMap(),
): PaginatedResource
The suggested fix for Spring OpenFeign clients is to use the @CollectionFormat(feign.CollectionFormat.CSV) annotation to the @FeignClient class (docs), however, this seems to only work for methods/classes annotated with @RequestMapping (source).
@RequestLine instead accepts a collectionFormat parameter on the annotation to provide this configuration (source), however, each parameter in an OpenAPI spec can define explode independently, and feign doesn't seem to have the same collectionFormat configuration available on the @Param annotation. Instead, to configure the behavior on a per parameter basis, we'd probably have to utilize the expand parameter on the @Param annotation.
Problem
I have the following OpenAPI 3.1 schema:
{ ..., "/v1/resource/": { "get": { "operationId": "getPage", "parameters": [ { "in": "query", "name": "slug", "schema": { "type": "array", "items": { "type": "string" } }, "explode": false, "style": "form" } ] } }According to the OpenAPI docs,
"style": "form"with"explode": falseshould produce a comma separated list of values, e.g.?slug=one,two,three, but the generated Feign client ends up creating a request with exploded parameters.Generated client method looks something like this:
The suggested fix for Spring OpenFeign clients is to use the
@CollectionFormat(feign.CollectionFormat.CSV)annotation to the@FeignClientclass (docs), however, this seems to only work for methods/classes annotated with@RequestMapping(source).@RequestLineinstead accepts acollectionFormatparameter on the annotation to provide this configuration (source), however, each parameter in an OpenAPI spec can defineexplodeindependently, and feign doesn't seem to have the samecollectionFormatconfiguration available on the@Paramannotation. Instead, to configure the behavior on a per parameter basis, we'd probably have to utilize theexpandparameter on the@Paramannotation.