Interface SchemaParser

All Known Implementing Classes:
SchemaParserV30, SchemaParserV31

public interface SchemaParser
OpenApi Schema parser. Specifications are available at https://spec.openapis.org/
  • Method Summary

    Modifier and Type
    Method
    Description
    default List<io.swagger.v3.oas.models.media.Schema>
    Returns the anyOf schemas.
    default List<String>
    Returns enumeration values.
    @Nullable String
    Returns the schema format, or null.
    default io.swagger.v3.oas.models.media.Schema<?>
    Returns the schema defining the inner type of a map.
    default boolean
    Returns true if this schema represents a combination of types.
    boolean
    Returns true if the schema defines a composition by anyOf.
    boolean
    Returns true if the schema defines an array.
    boolean
    Returns true if the schema is a binary stream of data.
    boolean
    isDate(boolean acceptBrokenType)
    Returns true if the schema defines a date.
    boolean
    isDateTime(boolean acceptBrokenType)
    Returns if the schema defines a date-time.
    default boolean
    Returns true if this schema defines an enumeration.
    default boolean
    Detects free-form objects.
    boolean
    Returns true if the schema defines a map.
    boolean
    Returns true if the type is nullable.
    boolean
    Returns true if the schema defines a number.
    boolean
    Returns true if the schema defines an object.
    boolean
    Returns true if the schema defines a composition by oneOf.
    default boolean
    Returns true if the schema contains a reference to another type.
    boolean
    Returns true if the schema defines a string.
    default boolean
    Returns true if this schema defines (just) time.
    default boolean
    Returns true if no type is defined for the schema.
    default boolean
    Returns true if the schema defines unique items (is a set).
    default io.swagger.v3.oas.models.media.Schema<?>
    Returns the schema for the contained items.
    default @Nullable String
    Returns the schema name, or null.
    of(io.swagger.v3.oas.models.media.Schema<?> schema)
    Returns a parser suitable for the given schema.
    default List<io.swagger.v3.oas.models.media.Schema>
    Returns the oneOf schemas.
    io.swagger.v3.oas.models.media.Schema<?>
    Returns the OpenApi schema this parser operates on.
    @Nullable String
    Returns the schema type, or null.
  • Method Details

    • schema

      io.swagger.v3.oas.models.media.Schema<?> schema()
      Returns the OpenApi schema this parser operates on.
      Returns:
      the OpenApi schema this parser operates on
    • name

      default @Nullable String name()
      Returns the schema name, or null.
      Returns:
      the schema name, or null
    • type

      @Nullable String type()
      Returns the schema type, or null.
      Returns:
      the schema type, or null
    • isTypeless

      default boolean isTypeless()
      Returns true if no type is defined for the schema. This is used to recognize the empty, non-boolean variant of free-form objects:
       schema:
        type: object
        additionalProperties: {}
       
      Returns:
      true if no type is defined for the schema
    • format

      @Nullable String format()
      Returns the schema format, or null.
      Returns:
      the schema format, or null
    • itemsSchema

      default io.swagger.v3.oas.models.media.Schema<?> itemsSchema()
      Returns the schema for the contained items.
      Returns:
      the schema for the contained items
    • isAnyOf

      boolean isAnyOf()
      Returns true if the schema defines a composition by anyOf.
      Returns:
      true if the schema defines a composition by anyOf
    • anyOfSchemas

      default List<io.swagger.v3.oas.models.media.Schema> anyOfSchemas()
      Returns the anyOf schemas.
      Returns:
      the anyOf schemas
    • isOneOf

      boolean isOneOf()
      Returns true if the schema defines a composition by oneOf.
      Returns:
      true if the schema defines a composition by oneOf
    • oneOfSchemas

      default List<io.swagger.v3.oas.models.media.Schema> oneOfSchemas()
      Returns the oneOf schemas.
      Returns:
      the oneOf schemas
    • isArray

      boolean isArray()
      Returns true if the schema defines an array.
      Returns:
      true if the schema defines an array
    • isDate

      boolean isDate(boolean acceptBrokenType)
      Returns true if the schema defines a date.
      Parameters:
      acceptBrokenType - if true, allows null/date to be recognized as a date
      Returns:
      true if the schema defines a date
    • isDateTime

      boolean isDateTime(boolean acceptBrokenType)
      Returns if the schema defines a date-time.
      Parameters:
      acceptBrokenType - if true, allows null/date-time to be recognized as a date-time
      Returns:
      if the schema defines a date-time
    • isMap

      boolean isMap()
      Returns true if the schema defines a map.
      Returns:
      true if the schema defines a map
    • getMapInnerSchema

      default io.swagger.v3.oas.models.media.Schema<?> getMapInnerSchema()
      Returns the schema defining the inner type of a map. This should only be called if the map is not a free-form object.
      Returns:
      the schema defining the inner type of a map
      See Also:
    • isFreeFormObject

      default boolean isFreeFormObject()
      Detects free-form objects. This is only relevant for map-types. See https://swagger.io/docs/specification/v3_0/data-models/dictionaries/ (search for Free-Form Objects)
      Returns:
      true if the schema looks like a free-form object
    • isNullable

      boolean isNullable()
      Returns true if the type is nullable.
      Returns:
      true if the type is nullable
    • isNumber

      boolean isNumber()
      Returns true if the schema defines a number.
      Returns:
      true if the schema defines a number
    • isObject

      boolean isObject()
      Returns true if the schema defines an object.
      Returns:
      true if the schema defines an object
    • isRef

      default boolean isRef()
      Returns true if the schema contains a reference to another type.
      Returns:
      true if the schema contains a reference to another type
    • isString

      boolean isString()
      Returns true if the schema defines a string.
      Returns:
      true if the schema defines a string
    • isTime

      default boolean isTime()
      Returns true if this schema defines (just) time.
      Returns:
      true if this schema defines (just) time
    • isUnique

      default boolean isUnique()
      Returns true if the schema defines unique items (is a set).
      Returns:
      true if the schema defines unique items (is a set)
    • isAllOf

      default boolean isAllOf()
      Returns true if this schema represents a combination of types. TODO: probably close to new array of types? TODO: rename, something like isCombinedType
      Returns:
      true if this schema represents a combination of types
    • isBinary

      boolean isBinary()
      Returns true if the schema is a binary stream of data.
      Returns:
      true if the schema is a binary stream of data
    • isEnumeration

      default boolean isEnumeration()
      Returns true if this schema defines an enumeration.
      Returns:
      true if this schema defines an enumeration
    • enumerationValues

      default List<String> enumerationValues()
      Returns enumeration values.
      Returns:
      enumeration values
    • of

      static SchemaParser of(io.swagger.v3.oas.models.media.Schema<?> schema)
      Returns a parser suitable for the given schema. Uses the schema's specification version to determine the parser implementation to use.
      Parameters:
      schema - the schema to provide a parser for
      Returns:
      a parser suitable for the given schema