SMILEY4 / ktor-swagger-ui

Kotlin Ktor plugin to generate OpenAPI and provide Swagger UI
Apache License 2.0
150 stars 25 forks source link

How to set a queryParameter as type List<String> #98

Closed tobyworks closed 2 months ago

tobyworks commented 3 months ago

I have a call that expect a list of strings as a query parameter, as following:

endpoint?v=abc&v=xyz

but i can't define it as:

request{
  queryParameter("v", List<String>::class)
}

i can only define it as:

request{
  queryParameter("v",List::class)
}

but then the swagger docs expects a array [object] however im looking for a array[String]

SMILEY4 commented 3 months ago

Hi,

you can specify types as generic type parameters. So writing it like this

queryParameter<List<String>>("v")

should solve your problem