SMILEY4 / ktor-swagger-ui

Kotlin Ktor plugin to generate OpenAPI and provide Swagger UI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to document body parameters?

ScottPierce opened this issue · comments

Thank you for providing this library! It's very clean.

How would I describe a Body parameter, and what the acceptable values are for it?

            body<ExampleRequest> {
                required = true
            }

Lets say that ExampleRequest has a parameter limit that has a max value of 100. Or if I wanted to document the acceptable formats for a Date String that was sent. Is that possible currently?

Hi,
Thanks. You can customize the schema-objects with the @Schema-annotation and add for example add the annotation on the limit-field and set the maximum-property. You can find more information here: https://github.com/SMILEY4/ktor-swagger-ui/wiki/Documenting-Routes-(Bodies)#swagger-schema-annotation.

@SMILEY4 The models are multiplatform models that are shared between platforms. I can't put annotations on them. Is there another way that I can do this?

Unfortunately, there is currently no other way besides annotations.
I'm currently in the process of rewriting the code responsible for handling schemas and objects, so that (describing attributes without annotations/touching the model) might be something i could add in the future.