Skip to content

Add binary (Bytes) response support to Spring integration#617

Open
nsmnds wants to merge 2 commits into
masterfrom
claude/add-excel-export-endpoint-NucQc
Open

Add binary (Bytes) response support to Spring integration#617
nsmnds wants to merge 2 commits into
masterfrom
claude/add-excel-export-endpoint-NucQc

Conversation

@nsmnds

@nsmnds nsmnds commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Parser: Infer application/octet-stream content type when the body type is Bytes (instead of hardcoded application/json)
  • Jackson serialization: Add ByteArray/byte[] passthrough in both Kotlin and Java WirespecSerialization so binary data skips JSON encoding
  • Spring ResponseBodyAdvice: Handle binary responses by writing directly to the output stream with Content-Type: application/octet-stream, instead of wrapping in RawJsonBody
  • Bug fix: Fix concatGenerics() in Utils.kt to handle Java array bracket notation (byte[]byte instead of invalid byte[] in interface names)

This enables defining endpoints like:

endpoint DownloadReport GET /api/report -> {
    200 -> Bytes
}

Test plan

  • Parser tests: verify Bytes body infers application/octet-stream content type for both request and response
  • Spring Kotlin emitter test: verify generated code includes correct handler interface
  • Spring Java emitter test: verify generated code includes correct handler interface
  • Kotlin Spring integration test: verify binary response returns correct bytes via MockMvc
  • Java Spring integration test: verify binary response returns correct bytes via MockMvc
  • Existing CRUD, query parameter, and multipart tests still pass

https://claude.ai/code/session_01JNutdTfvBVFQXNDPx9Xb7H

claude added 2 commits April 16, 2026 13:48
Support Wirespec endpoints that return `Bytes` type by:
- Inferring `application/octet-stream` content type for Bytes in the parser
- Adding ByteArray/byte[] passthrough in Jackson serialization (skip JSON encoding)
- Handling binary responses in WirespecResponseBodyAdvice by writing directly
  to the output stream instead of wrapping in RawJsonBody
- Fixing `concatGenerics()` to handle array bracket notation in Java identifiers

https://claude.ai/code/session_01JNutdTfvBVFQXNDPx9Xb7H
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants