Interface SubtypeResolver

All Superinterfaces:
StatefulConfig
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface SubtypeResolver extends StatefulConfig
Resolver for looking up a declared type's subtypes in order to list those specifically (in an SchemaKeyword.TAG_ANYOF).
Assumption being that SchemaKeyword.TAG_ONEOF would require a schema validator to unnecessarily check against all listed sub-schemas to ensure that only a single one is matching a given JSON instance. By making the sub-schemas mutually exclusive, the same semantics can be achieved, but allowing the schema validator to ignore any sub-schemas after the first match was found.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<com.fasterxml.classmate.ResolvedType>
    findSubtypes(com.fasterxml.classmate.ResolvedType declaredType, SchemaGenerationContext context)
    Look-up the subtypes for a given type, that should be listed independently.

    Methods inherited from interface com.github.victools.jsonschema.generator.StatefulConfig

    resetAfterSchemaGenerationFinished
  • Method Details

    • findSubtypes

      List<com.fasterxml.classmate.ResolvedType> findSubtypes(com.fasterxml.classmate.ResolvedType declaredType, SchemaGenerationContext context)
      Look-up the subtypes for a given type, that should be listed independently.
      If it returns null, the next subtype resolver is expected to be applied. An empty list will result only in the originally declared type to be considered.
      Returning a list with a single entry will treat the declared type as one-to-one alias for the returned type. Alternatively, you may want to only replace it in the context of a particular field/method through target type overrides.
      Parameters:
      declaredType - declared type (i.e. without type parameter information)
      context - generation context (including a reference to the TypeContext for deriving a ResolvedType from a Class)
      Returns:
      list of subtypes to represent as separate schemas (may return null)
      See Also: