Ktor-OpenAPI-Generator icon indicating copy to clipboard operation
Ktor-OpenAPI-Generator copied to clipboard

Default values on @QueryParam

Open choffa opened this issue 2 years ago • 4 comments

Would it be possible to support default values for optional query params? Either as a value in the @QueryParam annotation, or by using a default value from the constructor?

choffa avatar Nov 18 '21 14:11 choffa

the obvious way to do it if you are willing to do a one liner is to do something like this, with params.param as a nullable type: val param = params.param ?: getDefaultValue()

Wicpar avatar Nov 30 '21 18:11 Wicpar

Yes, that is what I am doing today. I was more interested in knowing if there is a way to set the default field in the schema, as described here or if you would be interested in implementing such a feature :)

choffa avatar Dec 01 '21 08:12 choffa

If you want to do a pr to add it i would accept it :)

Wicpar avatar Dec 01 '21 09:12 Wicpar

I am really interested in contributing (especially #122), but I am having some problems understanding the setup.

Where exactly does the collection of the schemas happen and how do they get collected. It does not seem to be near the route functions which handle the requests.

I think I am looking for some basic description which describes the work flow involved in creating the OpenAPI file

HuiiBuh avatar Feb 08 '22 14:02 HuiiBuh