Map raw binary request/response bodies to Resource - #394
Merged
jemacineiras merged 2 commits intoJul 31, 2026
Conversation
MapperPathUtil.getObjectOrType typed a top-level `type: string, format: binary` body (e.g. application/octet-stream, not wrapped in a multipart object) as String, because it never checked ApiTool.isBinary. Binary -> file type was only applied to object properties and array items. Add a RESOURCE type (org.springframework.core.io.Resource) and return it from getObjectOrType for binary schemas. Resource (not MultipartFile) is used because a raw @RequestBody binary payload is a streaming resource, not a multipart part; the reactive template wraps it as Mono<Resource>. Both server templates import Resource on demand. Adds testBinaryBodyResource and testReactiveBinaryBodyResource fixtures. Fixes sngular#393 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jemacineiras
approved these changes
Jul 31, 2026
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
jemacineiras
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Maps a raw binary request/response body (
type: string, format: binarynot wrapped in a multipart object, e.g.application/octet-stream) toResourceinstead ofString. Closes #393.Why
Binary → file type was only applied to object properties and (since #387) array items. The top-level content path
MapperPathUtil.getObjectOrTypehad no binary detection, so a raw binary body fell through toString.Change
TypeConstants.RESOURCEtype mapped toorg.springframework.core.io.Resource(type / import / impl mappings).getObjectOrType: returnResourcewhenApiTool.isBinary(schema).template.ftlh,templateReactive.ftlh): importorg.springframework.core.io.Resourceon demand when a body/response uses it.Resourceis used rather thanMultipartFile, since a raw@RequestBodybinary payload is a streaming resource, not a multipart part. The annotated flavor emits@RequestBody Resource, the reactive flavor@RequestBody Mono<Resource>.Generated output
Test
testBinaryBodyResourceandtestReactiveBinaryBodyResourcefixtures + goldens.Tests run: 121, Failures: 0, Errors: 0.Version
Bumps
6.6.3→6.6.4across engine, Maven plugin and Gradle plugin.🤖 Generated with Claude Code