Skip to content

Provide the ability to specify the Content Type of a non-named Multipart Part #1888

Open
@adrianhj

Description

@adrianhj

Is your feature request related to a problem? Please describe.

When utilising @RequestPart on a Controller argument in Spring for working with multipart/form-data requests consisting of e.g. a file part and a JSON part—and expecting the JSON part to be correctly deserialised to a POJO—it relies on the Content-Type of the request part to find and apply the relevant HttpMessagingConverter; defaulting to application/octet-stream if none was provided.

From the client perspective these parts are not files as such and do not have file names. MultipartBodyBuilder.part(String name, Object part, MediaType contentType) for example allows specifying such a part with a relevant content type when working with the WebClient.

Describe the solution you'd like

Provide the ability to specify the content type of a multipart part without a filename within a contract so as to generate valid requests.

Describe alternatives you've considered

Utilising the named(name, content, contentType) method, however this puts the burden onto any integrating party to provide a dummy name to satisfy the generated WireMock mappings as it is not optional whilst not being required by the endpoint.

Additional context

REST Assured seems to have various flavours of multiPart, some providing the ability to specify a multipart part with a relevant content type as desired which is probably of interest as compared to the currently used param method which seems more intended for form params.

In the process of attempting to provide a part(content, contentType) method or the like, but figured I'd open for discussion if this is something that has been covered previously or whether I have misunderstood any aspect of verifying a JSON encoded @RequestPart via Spring Cloud Contract.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions