SMILEY4 / ktor-swagger-ui

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

Schema(name) annotation fails to apply in certain cases #96

Closed clragon closed 2 months ago

clragon commented 3 months ago

My server has DTO models, but I would like the API to have names without the DTO suffix. Because of that, I would like to annotate the models as so:

@Schema(name = "MyModel")
data class MyModelDto(
  // ...
)

however, this does not seem to work well with the generator:

SMILEY4 commented 3 months ago

Hi,

sorry for the late response.

I think it should be title instead of name.

@Schema(title = "MyModel")
data class MyModelDto(
  // ...
)

Can you check if that solves the problem?

clragon commented 3 months ago

Hi, Thanks for your reply.

Unfortunately, its not title either. The title property only changes the display name of the Model in the Swagger UI, but the Model itself is not renamed, therefore, shows up as Dto when later read by generators.

From what I have understood from the docs, it is meant to be name. but it doesnt appear to work correctly.

SMILEY4 commented 3 months ago

Hi,

i misunderstood the issue. You are correct, it should be name and it does work for nested objects but not for the root object. Unfortunately this is not an easy fix with the current setup and how schemas are generated. I am working on a version 3 of the plugin which should be ready to test in the next few days and should make this possible.

I hope this could be a possible solution for you.