Closed SerVB closed 4 years ago
you can specify it per request like this:
get<Unit, Response>(example = Response(...)) {
}
post<Unit, Response, Request>(
exampleRequest = Request(...),
exampleResponse = Response(...)
) { params, request ->
}
No mechanism exists yet to provide examples per model globally.
Yeah, I use examples for methods. I'm not an experienced user of OpenAPI, so I don't know if examples of fields are also usually defined...
If yes, I want an opportunity to define them.
If no, just remove these "example" fields.
i will add such a mechanism as it is part of the standard.
until then you can use the new branch with the reworked models. null fields are now filtered when you use OpenAPIModel.build()
it will generate the appropriate hashmaps and remove empty and null values
Added @WithExample
in the latest commit.
SwagerUI doesn't handle it properly anyway.
@WithExample
class C(val l: @Clamp(0, 10) Long) : Base() {
companion object: ExampleProvider<C> {
override val example: C? = C(5)
}
}
or
@WithExample(CExampleProvider::class)
class C(val l: @Clamp(0, 10) Long) : Base()
...
object CExampleProvider: ExampleProvider<C> {
override val example: C? = C(5)
}
implementation 'com.github.papsign:Ktor-OpenAPI-Generator:0.2-beta.0-experimental'
In the models section, there is a field called "example". Currently it is equal to
null
for all fields in all classes:There should be a way to specify this field. Also, I think if the field is not specified, it shouldn't be presented in the models section.
This is an issue extracted from #12.