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
ConstructorsConstructorDescriptionDefault constructor equivalent to callingnew JsonSubTypesResolver(Collections.emptyList()).JsonSubTypesResolver(Collection<JacksonOption> options) Constructor expecting list of enabled module options. -
Method Summary
Modifier and TypeMethodDescriptionList<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 aJsonSubTypesannotation.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.CustomPropertyDefinitionprovideCustomPropertySchemaDefinition(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.CustomDefinitionprovideCustomSchemaDefinition(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, waitMethods inherited from interface com.github.victools.jsonschema.generator.StatefulConfig
resetAfterSchemaGenerationFinished
-
Constructor Details
-
JsonSubTypesResolver
public JsonSubTypesResolver()Default constructor equivalent to callingnew JsonSubTypesResolver(Collections.emptyList()). -
JsonSubTypesResolver
Constructor expecting list of enabled module options.
Currently, only theJacksonOption.ALWAYS_REF_SUBTYPESis 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:
findSubtypesin interfacecom.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 aJsonSubTypesannotation.- Parameters:
property- targeted field/method- Returns:
- list of annotated subtypes (or
nullif there is noJsonSubTypesannotation)
-
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. Returnsnullif annotation isnull/not present.- Parameters:
declaredType- supertype encountered while generating a schemasubtypesAnnotation- annotation to derive applicable subtypes from.context- type context for proper type resolution- Returns:
- resolved annotated subtypes (or
nullif given annotation isnull)
-
provideCustomSchemaDefinition
public com.github.victools.jsonschema.generator.CustomDefinition provideCustomSchemaDefinition(com.fasterxml.classmate.ResolvedType javaType, com.github.victools.jsonschema.generator.SchemaGenerationContext context) - Specified by:
provideCustomSchemaDefinitionin interfacecom.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 methodcontext- generation context- Returns:
- applicable custom per-property override schema definition (may be
null)
-