Closed
Description
I'm using.
- Spring Boot
v3.4.1
- Springdoc OpenAPI
v2.8.1
- OAS
v3.1
In my example I'm using @Schema(types = "boolean")
.
Here's a code that will generate a valid Swagger definition.
@PostMapping(path = "/dummy", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public String dummy(
@RequestPart(value = "file", required = false) MultipartFile file,
@Parameter(description = "There is dummy param", schema = @Schema(types = "boolean")) @RequestParam(name = "is_dummy") String isDummy
) {
return "";
}
The param definition is as follows. It's valid.
"parameters": [
{
"name": "is_dummy",
"in": "query",
"description": "There is dummy param",
"required": true,
"schema": {
"type": "boolean"
}
}
],
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
}
}
}
}
}
}
Then let's try to set true
for springdoc.default-support-form-data
config option. We will get a param definition as follows.
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"format": "binary"
},
"is_dummy": {
"description": "There is dummy param"
}
}
}
}
}
}
The schema
to is_dummy
field is not added anymore.
Another example properly working example. Code below. POST
with application/x-www-form-urlencoded
content type.
@PostMapping(path = "/dummy", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@ResponseStatus(value = HttpStatus.OK)
public String dummy(
@Parameter(description = "There is dummy param", schema = @Schema(types = "boolean")) @RequestParam(name = "is_dummy") String isDummy
) {
return "";
}
It produces valid param definition.
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "boolean",
"description": "There is dummy param"
}
}
}
},
Metadata
Metadata
Assignees
Labels
No labels