Given the existence of the following endpoint:
public class Foo {
@ApiModelProperty(value = "Bar description", required = true)
private String bar;
...
@PostMapping(value = "/foo", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public void postFooAsMultiPart(Foo foo) {
...
If I mark Foo as a @RequestBody it will be presented as a single field:
"parameters": [
{
"in": "body",
"name": "foo",
"description": "foo",
"required": true,
"schema": {
"$ref": "#/definitions/Foo"
}
}
],
If I don't mark Foo as @RequestBody its attributes are presented as query fields:
"parameters": [
{
"name": "bar",
"in": "query",
"description": "Bar description",
"required": true,
"type": "string"
}
],
I would like the presence of a multipart form data header to render the request as:
"parameters": [
{
"name": "bar",
"in": "formData",
"description": "Bar description",
"required": true,
"type": "string"
}
],
I'm not sure if this is a bug or a feature or if it even makes sense to do!
Notes
- Reported behavior on 2.8.0
- I've posted a question on stackoverflow asking how this should be done, but I'm not optimistic about a positive response (hence this ticket)
- I assume this change would involve
OperationParameterReader.shouldExpand taking account of the consumes header and if multipart, passing data down to ExpandedParameterBuilder that would make the parameterType dynamic rather than hard-coded to "query".
Given the existence of the following endpoint:
If I mark Foo as a
@RequestBodyit will be presented as a single field:If I don't mark Foo as
@RequestBodyits attributes are presented as query fields:I would like the presence of a multipart form data header to render the request as:
I'm not sure if this is a bug or a feature or if it even makes sense to do!
Notes
OperationParameterReader.shouldExpandtaking account of theconsumesheader and if multipart, passing data down toExpandedParameterBuilderthat would make theparameterTypedynamic rather than hard-coded to"query".