Class ByteArraySerializer

  • All Implemented Interfaces:
    com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable, com.fasterxml.jackson.databind.jsonschema.SchemaAware, Serializable

    public class ByteArraySerializer
    extends com.fasterxml.jackson.databind.ser.std.StdSerializer<byte[]>
    Serializes byte[] as a UTF-8 string, preserving the original base64 representation of an OpenAPI format: byte example. swagger-parser stores format: byte examples as the raw bytes of the input base64 string (not the decoded content), so writing those bytes back as a string round-trips to the user's original value. This prevents Jackson's default YAML behavior of emitting a !!binary block with a re-encoded payload.

    Load-bearing assumption: this only round-trips correctly because swagger-parser stores the raw input bytes. If swagger-parser ever decodes format: byte examples internally, this serializer must switch to Base64.getEncoder().encodeToString(value).

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonSerializer

        com.fasterxml.jackson.databind.JsonSerializer.None
    • Field Summary

      • Fields inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

        _handledType
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void serialize​(byte[] value, com.fasterxml.jackson.core.JsonGenerator gen, com.fasterxml.jackson.databind.SerializerProvider serializers)  
      • Methods inherited from class com.fasterxml.jackson.databind.ser.std.StdSerializer

        _neitherNull, _nonEmpty, acceptJsonFormatVisitor, createSchemaNode, createSchemaNode, findAnnotatedContentSerializer, findContextualConvertingSerializer, findConvertingContentSerializer, findFormatFeature, findFormatOverrides, findIncludeOverrides, findPropertyFilter, getSchema, getSchema, handledType, isDefaultSerializer, visitArrayFormat, visitArrayFormat, visitFloatFormat, visitIntFormat, visitIntFormat, visitStringFormat, visitStringFormat, wrapAndThrow, wrapAndThrow
      • Methods inherited from class com.fasterxml.jackson.databind.JsonSerializer

        getDelegatee, isEmpty, isEmpty, isUnwrappingSerializer, properties, replaceDelegatee, serializeWithType, unwrappingSerializer, usesObjectId, withFilterId, withIgnoredProperties
    • Constructor Detail

      • ByteArraySerializer

        public ByteArraySerializer()
    • Method Detail

      • serialize

        public void serialize​(byte[] value,
                              com.fasterxml.jackson.core.JsonGenerator gen,
                              com.fasterxml.jackson.databind.SerializerProvider serializers)
                       throws IOException
        Specified by:
        serialize in class com.fasterxml.jackson.databind.ser.std.StdSerializer<byte[]>
        Throws:
        IOException