-
Notifications
You must be signed in to change notification settings - Fork 439
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
Provide the ability to specify the Content Type of a non-named Multipart Part #1888
Comments
Do you have a small Java-Maven sample that you could show with such client - server communication? |
@marcingrzejszczak I have built a small example in https://github.com/adrianhj/spring-cloud-contract-1888, hopefully this helps showcase the gap (issue?) utilising Spring. Areas of interest:
For the RestTemplate backed test, I have upped the logging to easily see what is sent over the wire:
The area of particular interest is the
|
I started some work on #1929 at the time but it fell dormant. I have opened it for commentary around whether the approach would be of interest to be progressed. |
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 toapplication/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 usedparam
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.The text was updated successfully, but these errors were encountered: