papsign / Ktor-OpenAPI-Generator

Ktor OpenAPI/Swagger 3 Generator
Apache License 2.0
241 stars 42 forks source link

Default values on @QueryParam #118

Open choffa opened 2 years ago

choffa commented 2 years ago

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?

Wicpar commented 2 years ago

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()

choffa commented 2 years ago

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 :)

Wicpar commented 2 years ago

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

HuiiBuh commented 2 years ago

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