feat: handle binary responses with proper byte handling#29
Merged
santiagomed merged 1 commit intomainfrom Mar 12, 2026
Merged
Conversation
dd580e3 to
6333160
Compare
e4b174f to
a496b9a
Compare
Detect binary response types directly from the OpenAPI responses field in templates (no extra Rust field needed). Template changes: - TypeScript: Check for 'application/octet-stream' in responses content, pass 'binary: true' to request(), return ArrayBuffer - Python: Check for 'application/octet-stream' in responses content, return response.content as bytes The binary check is derived at template render time from: operation.responses['200'].content['application/octet-stream'] Supported binary content types: - application/octet-stream This provides: - Better type safety (ArrayBuffer/bytes return types) - No runtime content-type parsing overhead - Correct IDE autocomplete and type inference - No redundant data in the operation model
a496b9a to
ea429d0
Compare
tcaldwell-x
approved these changes
Mar 12, 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.
Summary
Previously, binary responses (e.g.,
application/octet-stream, images, audio, video) were processed incorrectly:response.text()corrupts bytes > 127 due to UTF-8 encodingresponse.json()fails on binary dataChanges
Now both SDKs detect binary content types and handle them properly:
response.arrayBuffer()ArrayBufferresponse.contentbytesSupported Binary Content Types
application/octet-streamimage/*audio/*video/*Usage
TypeScript
Python
Testing
cargo run -- typescript --latest truecargo run -- python --latest trueFiles Changed
xdk-gen/templates/typescript/main_client.j2- Added ArrayBuffer handlingxdk-gen/templates/python/client_macros.j2- Added bytes handling