Bear MAN
11/28/2022, 7:48 AMhttp4k-contract
, is it possible to generate array of enum query parameter, e.g.
"schema": {
"type": "array",
"items":{
"type": "string",
"enum": ["foo", "soo", "doo", "coo"]
}
}
Bear MAN
11/28/2022, 7:59 AMQuery.enum<TypeEnum>().multi.defaulted("type", emptyList())
which render into
{
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"in": "query",
"name": "type",
"required": false
}
which lose the information about the enum (request validation still works though, i.e. invalid enum string is rejected)
So I was thinking if I can use array of enum string instead, like the one in original question.Andrew O'Hara
11/28/2022, 3:14 PMmulti
is attempting to retain that type data, but I can't say for sure. Maybe an issue with the renderer.
Maybe David has a suggestion, but if not, this might be a bug to raise.Bear MAN
11/30/2022, 10:35 AMQuery.enum<TypeEnum>().multi.defaulted("type", emptyList(), "Allowed values: ${TypeEnum.values().joinToString()}")
Simply put a description message about the allowed values (enum strings).
"parameters": [
{
"schema": {
"type": "array",
"items": {
"type": "string"
}
},
"in": "query",
"name": "type",
"required": false,
"description": "Allowed values: FOO, SOO, DOO, COO"
}
Not a good solution, but good enough for now, at least client-side developers have some ideas.dave
12/01/2022, 1:55 PMdave
12/03/2022, 12:18 PM