-
-
Notifications
You must be signed in to change notification settings - Fork 559
Description
Describe the bug
Explicitly specifying request body properties by putting @Content(schemaProperties=...) in a method-level @RequestBody doesn't cause the properties to be included in the generated schema.
To Reproduce
- Spring Boot 2.6.7
- Springdoc-openapi 1.6.8
- Modules: kotlin, security, ui (and their transitive dependencies)
@RestController
class ExampleController {
@PostMapping("/upload", consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
@RequestBody(content = [
Content(
schema = Schema(type = "object", requiredProperties = ["file"]),
schemaProperties = [
SchemaProperty(name = "file", schema = Schema(type = "string", format = "binary"))],
encoding = [Encoding(name = "file", contentType = "text/csv")])],
)
fun uploadCsv(request: HttpServletRequest): String {
return "OK"
}
}Expected behavior
The above code should result in the following (leaving off the responses section for brevity):
/upload:
post:
tags:
- example-controller
operationId: uploadCsv
requestBody:
content:
multipart/form-data:
schema:
required:
- file
type: object
properties:
file:
type: string
format: binary
encoding:
file:
contentType: text/csvThe actual output is missing the properties section of the schema:
/upload:
post:
tags:
- example-controller
operationId: uploadCsv
requestBody:
content:
multipart/form-data:
schema:
required:
- file
type: object
encoding:
file:
contentType: text/csvAdditional context
I'm not using a FilePart or a RequestPart parameter here because the uploaded files are machine-generated output and can be multiple gigabytes in size. Spring (or Jetty) reads the entire request body from the client before calling the controller method if you declare one of those parameters. Instead I'm using Apache FileUpload to stream the contents of the file into my application code as it arrives from the client, but I want the API schema to be identical to what it would look like if I were using FilePart.