Description
A raw binary request/response body — type: string, format: binary not wrapped in a multipart object (e.g. application/octet-stream) — is generated as String instead of a binary type.
Binary → file type was only applied to object properties (MultipartFile, via ModelBuilder) and, after #387, to array items. The top-level content path (MapperPathUtil.getObjectOrType) has no binary detection.
Steps to reproduce
paths:
/upload:
post:
operationId: uploadBinary
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
format: binary
responses:
'200':
description: OK
Actual result
default ResponseEntity<Void> uploadBinary(@Valid @RequestBody String resource) { ... }
Expected result
A streaming binary type:
default ResponseEntity<Void> uploadBinary(@Valid @RequestBody Resource resource) { ... }
(org.springframework.core.io.Resource; the reactive flavor wraps it as Mono<Resource>.)
Root cause
MapperPathUtil.getObjectOrType switches on the schema type and, for type: string, falls through to the default -> String branch without ever calling ApiTool.isBinary. MapperPathUtil.mapContentObject only builds a wrapping schema object for form-data media types, so a non-multipart binary body is typed purely by getObjectOrType.
Notes
Resource is used (not MultipartFile) because MultipartFile is a multipart-part type; a raw @RequestBody binary payload is idiomatically a streaming Resource.
Environment
- OpenAPI code generator (
multiapi-engine), annotated + reactive server interface templates.
- Reproduced on
main.
Description
A raw binary request/response body —
type: string, format: binarynot wrapped in a multipart object (e.g.application/octet-stream) — is generated asStringinstead of a binary type.Binary → file type was only applied to object properties (
MultipartFile, viaModelBuilder) and, after #387, to array items. The top-level content path (MapperPathUtil.getObjectOrType) has no binary detection.Steps to reproduce
Actual result
Expected result
A streaming binary type:
(
org.springframework.core.io.Resource; the reactive flavor wraps it asMono<Resource>.)Root cause
MapperPathUtil.getObjectOrTypeswitches on the schema type and, fortype: string, falls through to thedefault -> Stringbranch without ever callingApiTool.isBinary.MapperPathUtil.mapContentObjectonly builds a wrapping schema object for form-data media types, so a non-multipart binary body is typed purely bygetObjectOrType.Notes
Resourceis used (notMultipartFile) becauseMultipartFileis a multipart-part type; a raw@RequestBodybinary payload is idiomatically a streamingResource.Environment
multiapi-engine), annotated + reactive server interface templates.main.