[Fix][scala-sttp][circe] Add Base64OrArrayByteDecoder for format:byte and format:binary JSON properties#23619
Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom Apr 25, 2026
Conversation
Contributor
Author
|
@wing328 Here is another targeted bug fix which is low risk. I know 7.22.0 is due today. Can this PR make it or is it too late? :) Thank you so much for all the reviews so far, btw 🙏 |
format:byte and format:binary JSON propertiesformat:byte and format:binary JSON properties
…erialize - Decoder[Array[Byte]] expects JSON array
613205f to
caffe64
Compare
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.
Fixes #23618.
cc @clasnake (2017/07), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @Fish86 (2023/06)
Adds
FlexibleByteArrayDecoder: Decoder[Array[Byte]]toadditionalTypeSerializers.mustachefor thescala-sttpcirce generator.Problem: Properties with
format: bytegenerateOption[Array[Byte]], but circe's derivedDecoder[Array[Byte]]expects a JSON number array. Jackson serializesbyte[]fields as Base64 strings, so decoding always fails at runtime withDecodingFailure at .field: Array[Byte]. The existingFileDecoder(used forformat: binaryJSON properties) is also broken for the same reason, since it delegates toDecoder[Array[Byte]].Fix: The new decoder tries JSON array first (strict OAS compliance), then falls back to Base64 string decoding
PR checklist
master"fixes #123"present in the PR description)Summary by cubic
Fixes #23618. Adds
Base64OrArrayByteDecoderto thescala-sttpcircegenerator soformat: byteandformat: binaryfields decode from JSON arrays or Base64 strings without runtime failures.Base64OrArrayByteDecoder: Decoder[Array[Byte]](array-first, Base64 fallback).additionalTypeSerializers.mustachewith the decoder andjava.util.Base64import.checksum: bytetoOption[Array[Byte]].Written for commit caffe64. Summary will update on new commits.