question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenApi annotation formParam

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
tobias-wallecommented, Oct 25, 2019

@sealedtx It seems like I completely forgot to implement this feature. I will add it this weekend. This shouldn’t be much work.

1reaction
tobias-wallecommented, Oct 29, 2019

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) {})
Read more comments on GitHub >

github_iconTop Results From Across the Web

@FormParam OpenAPI not displayed properly in Resteasy ...
Enquiry regarding the request dto, previously before migrating to resteasy reactive I used to have the @FormParam annotation providing the ...
Read more >
How to I read in Array formParams using Javalin's swagger ...
The current annotation I'm using is as follows: @OpenApi( summary = "Update Camera", tags = ["Camera"], formParams = [ OpenApiFormParam(name ...
Read more >
org.eclipse.microprofile.openapi.annotations.parameters ...
This page shows Java code examples of org.eclipse.microprofile.openapi.annotations.parameters.Parameter.
Read more >
Chapter 47. Passing Information into Resource Classes and ...
The javax.ws.rs.FormParam annotation extracts field values from form data and injects the value into resource method parameters. The annotation takes a single ...
Read more >
Solved: Specifying Encoding For Form Data Parameters
I've come to understand that swagger-jaxrs2 can handle turning method parameters annotated FormParam into the appropriate request body in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found