Class JsonSubTypesResolver

java.lang.Object
com.github.victools.jsonschema.module.jackson.JsonSubTypesResolver
All Implemented Interfaces:
com.github.victools.jsonschema.generator.CustomDefinitionProviderV2, com.github.victools.jsonschema.generator.StatefulConfig, com.github.victools.jsonschema.generator.SubtypeResolver

public class JsonSubTypesResolver extends Object implements com.github.victools.jsonschema.generator.SubtypeResolver, com.github.victools.jsonschema.generator.CustomDefinitionProviderV2
Look-up of subtypes from a JsonSubTypes annotation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor equivalent to calling new JsonSubTypesResolver(Collections.emptyList()).
    Constructor expecting list of enabled module options.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<com.fasterxml.classmate.ResolvedType>
    findSubtypes(com.fasterxml.classmate.ResolvedType declaredType, com.github.victools.jsonschema.generator.SchemaGenerationContext context)
     
    List<com.fasterxml.classmate.ResolvedType>
    findTargetTypeOverrides(com.github.victools.jsonschema.generator.MemberScope<?,?> property)
    Look-up applicable subtypes for the given field/method if there is a JsonSubTypes annotation.
    List<com.fasterxml.classmate.ResolvedType>
    lookUpSubtypesFromAnnotation(com.fasterxml.classmate.ResolvedType declaredType, com.fasterxml.jackson.annotation.JsonSubTypes subtypesAnnotation, com.github.victools.jsonschema.generator.TypeContext context)
    Mapping the declared erased types from the annotation to resolved types.
    com.github.victools.jsonschema.generator.CustomPropertyDefinition
    provideCustomPropertySchemaDefinition(com.github.victools.jsonschema.generator.MemberScope<?,?> scope, com.github.victools.jsonschema.generator.SchemaGenerationContext context)
    Providing custom schema definition for field/method in case of a per-property override of the applicable subtypes or how they are serialized.
    com.github.victools.jsonschema.generator.CustomDefinition
    provideCustomSchemaDefinition(com.fasterxml.classmate.ResolvedType javaType, com.github.victools.jsonschema.generator.SchemaGenerationContext context)
     

    Methods inherited from class java.lang.Object

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

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

    resetAfterSchemaGenerationFinished
  • Constructor Details

    • JsonSubTypesResolver

      public JsonSubTypesResolver()
      Default constructor equivalent to calling new JsonSubTypesResolver(Collections.emptyList()).
    • JsonSubTypesResolver

      public JsonSubTypesResolver(Collection<JacksonOption> options)
      Constructor expecting list of enabled module options.
      Currently, only the JacksonOption.ALWAYS_REF_SUBTYPES is considered here. Other relevant options are handled by the module class.
      Parameters:
      options - module options to derive differing behavior from
  • Method Details

    • findSubtypes

      public List<com.fasterxml.classmate.ResolvedType> findSubtypes(com.fasterxml.classmate.ResolvedType declaredType, com.github.victools.jsonschema.generator.SchemaGenerationContext context)
      Specified by:
      findSubtypes in interface com.github.victools.jsonschema.generator.SubtypeResolver
    • findTargetTypeOverrides

      public List<com.fasterxml.classmate.ResolvedType> findTargetTypeOverrides(com.github.victools.jsonschema.generator.MemberScope<?,?> property)
      Look-up applicable subtypes for the given field/method if there is a JsonSubTypes annotation.
      Parameters:
      property - targeted field/method
      Returns:
      list of annotated subtypes (or null if there is no JsonSubTypes annotation)
    • lookUpSubtypesFromAnnotation

      public List<com.fasterxml.classmate.ResolvedType> lookUpSubtypesFromAnnotation(com.fasterxml.classmate.ResolvedType declaredType, com.fasterxml.jackson.annotation.JsonSubTypes subtypesAnnotation, com.github.victools.jsonschema.generator.TypeContext context)
      Mapping the declared erased types from the annotation to resolved types. Returns null if annotation is null/not present.
      Parameters:
      declaredType - supertype encountered while generating a schema
      subtypesAnnotation - annotation to derive applicable subtypes from.
      context - type context for proper type resolution
      Returns:
      resolved annotated subtypes (or null if given annotation is null)
    • provideCustomSchemaDefinition

      public com.github.victools.jsonschema.generator.CustomDefinition provideCustomSchemaDefinition(com.fasterxml.classmate.ResolvedType javaType, com.github.victools.jsonschema.generator.SchemaGenerationContext context)
      Specified by:
      provideCustomSchemaDefinition in interface com.github.victools.jsonschema.generator.CustomDefinitionProviderV2
    • provideCustomPropertySchemaDefinition

      public com.github.victools.jsonschema.generator.CustomPropertyDefinition provideCustomPropertySchemaDefinition(com.github.victools.jsonschema.generator.MemberScope<?,?> scope, com.github.victools.jsonschema.generator.SchemaGenerationContext context)
      Providing custom schema definition for field/method in case of a per-property override of the applicable subtypes or how they are serialized.
      Parameters:
      scope - targeted field or method
      context - generation context
      Returns:
      applicable custom per-property override schema definition (may be null)