Collection responses
Opened this issue · 3 comments
I'm trying to add a list request to the Swagger documentation, so what I did was
get<something>(
"all".responds(ok<Collection<Something>>())
) {
call.respond(somethingService.list())
}
Here, somethingService.list()
returns a Collection<Something>
. But this doesn't work, it throws an exception:
Exception in thread "main" java.lang.IllegalArgumentException: invalid number of type parameters specified: expected 0, got 1
at de.nielsfalk.ktor.swagger.SwaggerParameterizedTypeKt.parameterize(SwaggerParameterizedType.kt:19)
Am I missing something, or is this not (yet) supported? The pet store example seems to sidestep this problem by wrapping the list responses in an object, I want to avoid this method, and just return a JSON array of objects.
Not currently supported.
I also, personally, don't use the reflection based schema generation. Just a heads up.
We're also actively looking for other maintainers who are looking to add additional features to this.
Ah ok, that's unfortunate ;) I'm not quite sure how to go about adding support for this. Are there any good examples of non-reflection-based schema generation? I've had a look through the unit tests, but based on those I don't really understand yet how to use it. The only good example is the pet store one, and that one is reflection-based.
I have examples in my own code, but that's all internal. I don't have the time to write up examples, unfortunately.
What I've been doing is passing in json pointers to externally, manually added schemas.