Class AbstractNullablePropertyCustomizer

java.lang.Object
org.springdoc.core.customizers.AbstractNullablePropertyCustomizer
All Implemented Interfaces:
io.swagger.v3.core.converter.ModelConverter
Direct Known Subclasses:
JavaNullablePropertyCustomizer

public abstract class AbstractNullablePropertyCustomizer extends Object implements io.swagger.v3.core.converter.ModelConverter
Base model converter marking the schema properties of a model as nullable, for the properties a subclass identifies as nullable.

Handles both OAS 3.0 and OAS 3.1 nullable semantics:

  • OAS 3.0: Sets nullable: true on the property. For $ref properties, wraps in allOf since $ref and nullable are mutually exclusive.
  • OAS 3.1: Adds "null" to the type array, or a type: "null" alternative to a oneOf. For $ref properties, wraps in oneOf with a type: "null" alternative.
Author:
Jeffrey Blayney, Mattias-Sehlstedt, bnasslahsen
  • Constructor Details

    • AbstractNullablePropertyCustomizer

      protected AbstractNullablePropertyCustomizer(ObjectMapperProvider objectMapperProvider)
      Instantiates a new Abstract nullable property customizer.
      Parameters:
      objectMapperProvider - the object mapper provider
  • Method Details

    • resolve

      public io.swagger.v3.oas.models.media.Schema resolve(io.swagger.v3.core.converter.AnnotatedType type, 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
    • findNullableProperties

      protected abstract Set<String> findNullableProperties(com.fasterxml.jackson.databind.JavaType javaType)
      Finds the names of the properties of the model that are nullable.
      Parameters:
      javaType - the java type of the model
      Returns:
      the names of the nullable properties, possibly empty
    • getObjectMapperProvider

      protected ObjectMapperProvider getObjectMapperProvider()
      Gets object mapper provider.
      Returns:
      the object mapper provider