papsign / Ktor-OpenAPI-Generator

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

Models: `minimum: null/maximum: null` for `string` and `boolean` seem redundant #15

Closed SerVB closed 4 years ago

SerVB commented 4 years ago

In the models section, there are redundant fields:

image

Current workaround is activating mapper.setSerializationInclusion(Include.NON_NULL) for Jackson.

However, it changes the way the server answers, so it's not a solution in some cases.

I think the solution can be just to omit generating minimum and maximum for string and boolean in the models section.

This is an issue extracted from #12.

Wicpar commented 4 years ago

made appropriate modifications in the rewoked-model branch.

implementation 'com.github.papsign:Ktor-OpenAPI-Generator:reworked-model-SNAPSHOT' and to remove null and empty fields:

                get("/openapi.json") {
                    call.respond(application.openAPIGen.api.build())
                }

It will be merged into master when it is determined as clean and maintainable.

SerVB commented 4 years ago

Yep, this works! A small concern here that .build() is executed every time the request is performed. Maybe it's better to use a lazy property to store the built schema.

Wicpar commented 4 years ago

It is possible, in principle, to create new routes during runtime, so the model can in principle change. This is up to the user.