SMILEY4 / ktor-swagger-ui

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

Add annotation to add description to default generated schema #100

Closed Him188 closed 2 months ago

Him188 commented 3 months ago

I loved the annotation @Example (and this library! very intuitive and useful)

Creating a custom schema can be a bit verbose when we only want to add a simple description. Why not add a @Description?

Sample usage:

@Serializable
data class CreateAppRequest(
    @Example("My app")
    @Description("Name of the application, max length is 20 chars")
    val name: String,
    @Example("true")
    @Description("Whether this application can be searched by anyone")
    val isPublic: Boolean,
)
Him188 commented 3 months ago

Oh I found https://github.com/SMILEY4/ktor-swagger-ui/wiki/Request-and-Response-Bodies-Basics#swagger-schema-annotation which worked for my use case.

However I had to manually add swagger dependency like

implementation("io.swagger.core.v3:swagger-core:2.2.21")
SMILEY4 commented 2 months ago

Hi, thank you. I'm currently working on version 3 which will have some more own annotations besides the swagger ones.

SMILEY4 commented 2 months ago

Should be resolved with 3.0.0-beta3 (https://github.com/SMILEY4/ktor-swagger-ui/releases/tag/3.0.0-beta3)