Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multipart and @FormParam annotation #444

Open
jamfor352 opened this issue Jun 28, 2024 · 3 comments
Open

Add support for multipart and @FormParam annotation #444

jamfor352 opened this issue Jun 28, 2024 · 3 comments
Assignees
Labels
type: enhancement New feature or request

Comments

@jamfor352
Copy link

Expected Behavior

@FormParam should not be transposed to @QueryValue in a multipart endpoint.

As per https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1.html#consuming_multipart_formdata:

@Path("widgets4")
public class WidgetsResource4 {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response postWidget(@FormParam("part1Name") String part1,
                               @FormParam("part2Name") InputStream part2,
                               @FormParam("part3Name") EntityPart part3) {...}
}

@FormParam represents a part of a Multipart request, not a QueryValue. But, here, the code is translating it to @QueryValue - this is wrong and will break HTTP clients.

Actual Behaviour

The above snippet should work correctly, with the @FormParam values being interpreted as part of the multipart form, not as query parameters.

Steps To Reproduce

  1. Write a JAX-RS controller which uses @FormParam to indicate multipart form data
  2. Test, it will break

Environment Information

No response

Example Application

I cannot provide a sample application right now as this was noticed in an enterprise setting.

Version

4.4.0

@graemerocher graemerocher changed the title Multipart/form-data not working correctly Add support for multipart and @FormParam annotation Jun 28, 2024
@graemerocher graemerocher added the type: enhancement New feature or request label Jun 28, 2024
@graemerocher
Copy link
Contributor

Micronaut is not currently a JAX-RS implementation, the annotations are designed to aid in porting code from JAX-RS. We are currently working to see if greater compatibility can be achieved but currently @FormParam is not supported and this should be a compilation error.

@jamfor352
Copy link
Author

Micronaut is not currently a JAX-RS implementation, the annotations are designed to aid in porting code from JAX-RS. We are currently working to see if greater compatibility can be achieved but currently @FormParam is not supported and this should be a compilation error.

That's unfortunate that isn't supported. I couldn't find docs which specify how Multipart endpoints should be handled using this library, is it the List<EntityPart> approach?
(Also, are there other libraries that work as JAX-RS implementations for Micronaut? This was the only one that I can find that even related to JAX-RS)

@graemerocher
Copy link
Contributor

the list of supported annotations and interfaces is documented here https://micronaut-projects.github.io/micronaut-jaxrs/latest/guide/#supportedApi

Note that you can use any Micronaut specific annotation like @Part CompletedFileUpload file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants