papsign/Ktor-OpenAPI-Generator

is it possible to have an endpoint with multiple query params?

Closed this issue · 2 comments

is it possible to have an endpoint with multiple query params?

for example, the following:

@Request("Query Params")
data class QueryParams(@QueryParam("a") val  a: String?, @QueryParam("b") val b: String?)
    apiRouting {
        route("/data/get") {
            get<QueryParams, List<Data>>(
                info("Query Params Endpoint", "This is a Query Params Endpoint"),
                example = mutableListOf(Data("SomeData"))
            ) { params -> 
                respond( Data("SomeData") )
            }
        }
    }

results in:

Exception in thread "main" java.lang.IllegalStateException: Only data classes are currently supported for Parameter objects
        at com.papsign.ktor.openapigen.parameters.parsers.converters.object.ObjectConverter.<init>(ObjectConverter.kt:25)
        at com.papsign.ktor.openapigen.parameters.parsers.converters.object.ObjectConverter$Companion.create(ObjectConverter.kt:44)
        at com.papsign.ktor.openapigen.parameters.parsers.converters.object.ObjectConverter$Companion.create(ObjectConverter.kt:37)
        at com.papsign.ktor.openapigen.parameters.parsers.converters.ConverterSelectorFactory.buildConverter(ConverterSelectorFactory.kt:7)
        at com.papsign.ktor.openapigen.parameters.parsers.builders.query.form.ConverterFormBuilder$Selector.canHandle(ConverterFormBuilder.kt:20)
        at com.papsign.ktor.openapigen.parameters.parsers.builders.BuilderSelectorFactory.buildBuilder(BuilderSelectorFactory.kt:9)
        at com.papsign.ktor.openapigen.parameters.parsers.builders.BuilderFactory$DefaultImpls.buildBuilderForced(BuilderFactory.kt:8)
        at com.papsign.ktor.openapigen.parameters.parsers.builders.BuilderSelectorFactory.buildBuilderForced(BuilderSelectorFactory.kt:6)

Also, could you point me in the right direction of how to do this if it is possible?

It is possible,
You may have mixed up imports, the type you specified is not a data class according to the error message, but your definition declares it as such.

@likewhatevs have you managed to get it to work ? I'll reopen if not.