Class SimpleTypeModule

  • All Implemented Interfaces:
    Module

    public class SimpleTypeModule
    extends Object
    implements Module
    Default module being included for the Option.ADDITIONAL_FIXED_TYPES.
    • Constructor Detail

      • SimpleTypeModule

        public SimpleTypeModule()
    • Method Detail

      • forPrimitiveTypes

        public static SimpleTypeModule forPrimitiveTypes()
        Factory method: creating an instance of the SimpleTypeModule containing mappings for various primitive types and their non-primitive counter parts (e.g. boolean and Boolean).
        Returns:
        created module instance
        See Also:
        forPrimitiveAndAdditionalTypes()
      • forPrimitiveAndAdditionalTypes

        public static SimpleTypeModule forPrimitiveAndAdditionalTypes()
        Factory method: creating an instance of the SimpleTypeModule containing mappings for various primitive types and their non-primitive counterparts (e.g. boolean and Boolean) as well as other classes that are normally serialised in a JSON as non-objects, e.g.
        BigDecimal, BigInteger, UUID, LocalDate, LocalDateTime, and a number of other date-time types.
        Returns:
        created module instance
        See Also:
        forPrimitiveTypes()
      • withEmptySchema

        public final SimpleTypeModule withEmptySchema​(Class<?> javaType)
        Add the given mapping for a (simple) java class that should be represented by an empty schema.
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        Returns:
        this module instance (for chaining)
      • withObjectType

        @Deprecated
        public final SimpleTypeModule withObjectType​(Class<?> javaType)
        Deprecated.
        rather use withEmptySchema(Class) instead to really allow any value
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_OBJECT".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        Returns:
        this module instance (for chaining)
      • withStringType

        public final SimpleTypeModule withStringType​(Class<?> javaType)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_STRING".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        Returns:
        this module instance (for chaining)
      • withStringType

        public final SimpleTypeModule withStringType​(Class<?> javaType,
                                                     String openApiFormat)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_STRING".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        openApiFormat - optional SchemaKeyword.TAG_FORMAT value, to set if respective Option is enabled
        Returns:
        this module instance (for chaining)
      • withStandardStringType

        public final SimpleTypeModule withStandardStringType​(Class<?> javaType,
                                                             String standardFormat)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_STRING".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        standardFormat - optional SchemaKeyword.TAG_FORMAT value, to set if one of the respective Options is enabled
        Returns:
        this module instance (for chaining)
      • withBooleanType

        public final SimpleTypeModule withBooleanType​(Class<?> javaType)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_BOOLEAN".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        Returns:
        this module instance (for chaining)
      • withIntegerType

        public final SimpleTypeModule withIntegerType​(Class<?> javaType)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_INTEGER".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        Returns:
        this module instance (for chaining)
      • withIntegerType

        public final SimpleTypeModule withIntegerType​(Class<?> javaType,
                                                      String openApiFormat)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "SchemaKeyword.TAG_TYPE_INTEGER".
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        openApiFormat - optional SchemaKeyword.TAG_FORMAT value, to set if respective Option is enabled
        Returns:
        this module instance (for chaining)
      • withNumberType

        public final SimpleTypeModule withNumberType​(Class<?> javaType)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute SchemaKeyword.TAG_TYPE_NUMBER.
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        Returns:
        this module instance (for chaining)
      • withNumberType

        public final SimpleTypeModule withNumberType​(Class<?> javaType,
                                                     String openApiFormat)
        Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute SchemaKeyword.TAG_TYPE_NUMBER.
        Parameters:
        javaType - java class to map to a fixed JSON schema definition
        openApiFormat - optional SchemaKeyword.TAG_FORMAT value, to set if respective Option is enabled
        Returns:
        this module instance (for chaining)
      • applyToConfigBuilder

        public void applyToConfigBuilder​(SchemaGeneratorConfigBuilder builder)
        Description copied from interface: Module
        Apply this module to the given configuration builder instance.
        Specified by:
        applyToConfigBuilder in interface Module
        Parameters:
        builder - configuration builder instance to which to apply this module