Hello, I have this kind of request handler:
@OpenApi(
path = "/activate",
method = HttpMethod.POST
)
public void activateWithKey(Context ctx) {
String key = ctx.formParam("key");
do_smth(key);
}
I can't find what OpenApiRequestBody annotation should I use for requestBody with formdata key=value? Can you help me?
@tipsy any thoughts, is it possible to document formparams?
@sealedtx I would imagine it is, but I don't have an overview of the capabilities of the OpenAPI plugin. You can try tagging some of the people who have been working on it?
@TobiasWalle, excuse me, can you help with this question? How can I document formparams with OpenAPI?
@sealedtx It seems like I completely forgot to implement this feature. I will add it this weekend. This shouldn't be much work.
@TobiasWalle Did you have time at weekend to implement it?
@sealedtx Not on the weekend but today. I just opened a PR.
After the merge you can document form parameters with annotations:
@OpenApi(
formParams = [
OpenApiFormParam(name = "name", type = String::class, required = true),
OpenApiFormParam(name = "age", type = Int::class)
],
responses = [
OpenApiResponse(status = "200")
]
)
fun putFormDataHandler(ctx: Context) {
}
@OpenApi(
requestBody = OpenApiRequestBody(content = [OpenApiContent(Address::class, type = ContentType.FORM_DATA)]),
responses = [
OpenApiResponse(status = "200")
]
)
fun putFormDataSchemaHandler(ctx: Context) {
}
or the DSL:
val getFormDataDocumentation = document()
.formParam<String>("name", required = true)
.formParam<Int>("age")
.result<Unit>("200")
app.put("/form-data", documented(getFormDataDocumentation) {})
val getFormDataSchemaDocumentation = document()
.formParamBody<Address>()
.result<Unit>("200")
app.put("/form-data-schema", documented(getFormDataSchemaDocumentation) {})
Most helpful comment
@sealedtx It seems like I completely forgot to implement this feature. I will add it this weekend. This shouldn't be much work.