Class CryptoModelConverter

java.lang.Object
com.bld.crypto.openapi.CryptoModelConverter
All Implemented Interfaces:
io.swagger.v3.core.converter.ModelConverter, org.springframework.core.Ordered

public class CryptoModelConverter extends Object implements io.swagger.v3.core.converter.ModelConverter, org.springframework.core.Ordered
SpringDoc/OpenAPI ModelConverter that overrides the schema type to string for fields annotated with any crypto annotation (@CryptoJks, @CryptoAes, @CryptoPkcs12, @CryptoHmac, @CryptoPubKey).

The encrypted/signed wire value is always a Base64-encoded ciphertext or token string, regardless of the underlying Java type (e.g. Integer, Long). Without this converter, Swagger would document the field with its Java type instead of the actual serialized type.

Implements Ordered with Ordered.LOWEST_PRECEDENCE so that any ModelConverter defined in the consuming microservice is placed earlier in the chain. The microservice converter can call chain.next() to reach this converter, receive back the StringSchema, and then add further customisations (description, example, etc.) without conflict.

This bean is registered automatically by CryptoSwaggerAutoConfiguration only when swagger-core-jakarta is on the classpath.

  • Field Summary

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    io.swagger.v3.oas.models.media.Schema<?>
    resolve(io.swagger.v3.core.converter.AnnotatedType annotatedType, io.swagger.v3.core.converter.ModelConverterContext context, Iterator<io.swagger.v3.core.converter.ModelConverter> chain)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.swagger.v3.core.converter.ModelConverter

    isOpenapi31
  • Constructor Details

    • CryptoModelConverter

      public CryptoModelConverter()
  • Method Details

    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • resolve

      public io.swagger.v3.oas.models.media.Schema<?> resolve(io.swagger.v3.core.converter.AnnotatedType annotatedType, io.swagger.v3.core.converter.ModelConverterContext context, Iterator<io.swagger.v3.core.converter.ModelConverter> chain)
      Specified by:
      resolve in interface io.swagger.v3.core.converter.ModelConverter