Class SchemaGeneratorConfigPart<M extends MemberScope<?,?>>
- java.lang.Object
-
- com.github.victools.jsonschema.generator.SchemaGeneratorTypeConfigPart<M>
-
- com.github.victools.jsonschema.generator.SchemaGeneratorConfigPart<M>
-
- Type Parameters:
M- type of the (resolved) member to analyse
- All Implemented Interfaces:
StatefulConfig
public class SchemaGeneratorConfigPart<M extends MemberScope<?,?>> extends SchemaGeneratorTypeConfigPart<M>
Generic collection of reflection based analysis for populating a JSON Schema from a certain kind of member.
-
-
Constructor Summary
Constructors Constructor Description SchemaGeneratorConfigPart()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description List<CustomPropertyDefinitionProvider<M>>getCustomDefinitionProviders()Getter for the applicable custom property definition provider.List<InstanceAttributeOverrideV2<M>>getInstanceAttributeOverrides()Getter for the applicable instance attribute overrides.BooleanisNullable(M member)Determine whether a given member is nullable.booleanisReadOnly(M member)Determine whether a given member should be deemed read-only in its declaring type.booleanisRequired(M member)Determine whether a given member should be indicated as being required in its declaring type.booleanisWriteOnly(M member)Determine whether a given member should be deemed write-only in its declaring type.voidresetAfterSchemaGenerationFinished()Method being invoked after the generation of a single "main" type's schema has been completed.StringresolvePropertyNameOverride(M member)Determine the alternative name in a parent JSON Schema's "properties" from a given member.List<com.fasterxml.classmate.ResolvedType>resolveTargetTypeOverrides(M member)Determine the alternative target type from a given member.booleanshouldIgnore(M member)Determine whether a given member should be included – ignoring member if any inclusion check returns false.SchemaGeneratorConfigPart<M>withAdditionalPropertiesResolver(ConfigFunction<M,Type> resolver)Setter for "additionalProperties" resolver.SchemaGeneratorConfigPart<M>withAdditionalPropertiesResolver(BiFunction<M,SchemaGenerationContext,com.fasterxml.jackson.databind.JsonNode> resolver)Setter for "additionalProperties" resolver.SchemaGeneratorConfigPart<M>withArrayMaxItemsResolver(ConfigFunction<M,Integer> resolver)Setter for "maxItems" resolver.SchemaGeneratorConfigPart<M>withArrayMinItemsResolver(ConfigFunction<M,Integer> resolver)Setter for "minItems" resolver.SchemaGeneratorConfigPart<M>withArrayUniqueItemsResolver(ConfigFunction<M,Boolean> resolver)Setter for "uniqueItems" resolver.SchemaGeneratorConfigPart<M>withCustomDefinitionProvider(CustomPropertyDefinitionProvider<M> definitionProvider)Adding a custom schema provider – if it returns null for a given type, the next definition provider will be applied.SchemaGeneratorConfigPart<M>withDefaultResolver(ConfigFunction<M,Object> resolver)Setter for "default" resolver.SchemaGeneratorConfigPart<M>withDescriptionResolver(ConfigFunction<M,String> resolver)Setter for "description" resolver.SchemaGeneratorConfigPart<M>withEnumResolver(ConfigFunction<M,Collection<?>> resolver)Setter for "enum"/"const" resolver.SchemaGeneratorConfigPart<M>withIgnoreCheck(Predicate<M> check)Setter for ignore check.SchemaGeneratorConfigPart<M>withInstanceAttributeOverride(InstanceAttributeOverride<M> override)Deprecated.SchemaGeneratorConfigPart<M>withInstanceAttributeOverride(InstanceAttributeOverrideV2<M> override)Setter for override of attributes on a given JSON Schema node in the respective member.SchemaGeneratorConfigPart<M>withNullableCheck(ConfigFunction<M,Boolean> check)Setter for nullable check.SchemaGeneratorConfigPart<M>withNumberExclusiveMaximumResolver(ConfigFunction<M,BigDecimal> resolver)Setter for "exclusiveMaximum" resolver.SchemaGeneratorConfigPart<M>withNumberExclusiveMinimumResolver(ConfigFunction<M,BigDecimal> resolver)Setter for "exclusiveMinimum" resolver.SchemaGeneratorConfigPart<M>withNumberInclusiveMaximumResolver(ConfigFunction<M,BigDecimal> resolver)Setter for "maximum" resolver.SchemaGeneratorConfigPart<M>withNumberInclusiveMinimumResolver(ConfigFunction<M,BigDecimal> resolver)Setter for "minimum" resolver.SchemaGeneratorConfigPart<M>withNumberMultipleOfResolver(ConfigFunction<M,BigDecimal> resolver)Setter for "multipleOf" resolver.SchemaGeneratorConfigPart<M>withPatternPropertiesResolver(ConfigFunction<M,Map<String,Type>> resolver)Setter for "patternProperties" resolver.SchemaGeneratorConfigPart<M>withPatternPropertiesResolver(BiFunction<M,SchemaGenerationContext,Map<String,com.fasterxml.jackson.databind.JsonNode>> resolver)Setter for "patternProperties" resolver.SchemaGeneratorConfigPart<M>withPropertyNameOverrideResolver(ConfigFunction<M,String> resolver)Setter for property name resolver, expecting the respective member and the default name as inputs.SchemaGeneratorConfigPart<M>withReadOnlyCheck(Predicate<M> check)Setter for read-only check.SchemaGeneratorConfigPart<M>withRequiredCheck(Predicate<M> check)Setter for required check.SchemaGeneratorConfigPart<M>withStringFormatResolver(ConfigFunction<M,String> resolver)Setter for "format" resolver.SchemaGeneratorConfigPart<M>withStringMaxLengthResolver(ConfigFunction<M,Integer> resolver)Setter for "maxLength" resolver.SchemaGeneratorConfigPart<M>withStringMinLengthResolver(ConfigFunction<M,Integer> resolver)Setter for "minLength" resolver.SchemaGeneratorConfigPart<M>withStringPatternResolver(ConfigFunction<M,String> resolver)Setter for "format" resolver.SchemaGeneratorConfigPart<M>withTargetTypeOverrideResolver(ConfigFunction<M,com.fasterxml.classmate.ResolvedType> resolver)Deprecated.usewithTargetTypeOverridesResolver(ConfigFunction)insteadSchemaGeneratorConfigPart<M>withTargetTypeOverridesResolver(ConfigFunction<M,List<com.fasterxml.classmate.ResolvedType>> resolver)Setter for target type resolver, expecting the respective member as input.SchemaGeneratorConfigPart<M>withTitleResolver(ConfigFunction<M,String> resolver)Setter for "title" resolver.SchemaGeneratorConfigPart<M>withWriteOnlyCheck(Predicate<M> check)Setter for write-only check.-
Methods inherited from class com.github.victools.jsonschema.generator.SchemaGeneratorTypeConfigPart
getFirstDefinedValue, getFirstDefinedValue, resolveAdditionalProperties, resolveArrayMaxItems, resolveArrayMinItems, resolveArrayUniqueItems, resolveDefault, resolveDescription, resolveEnum, resolveNumberExclusiveMaximum, resolveNumberExclusiveMinimum, resolveNumberInclusiveMaximum, resolveNumberInclusiveMinimum, resolveNumberMultipleOf, resolvePatternProperties, resolveStringFormat, resolveStringMaxLength, resolveStringMinLength, resolveStringPattern, resolveTitle
-
-
-
-
Method Detail
-
withCustomDefinitionProvider
public SchemaGeneratorConfigPart<M> withCustomDefinitionProvider(CustomPropertyDefinitionProvider<M> definitionProvider)
Adding a custom schema provider – if it returns null for a given type, the next definition provider will be applied.
If all custom property schema providers return null (or there is none), then the general type custom schema providers apply.- Parameters:
definitionProvider- provider of a custom property definition to register, which may return null- Returns:
- this builder instance (for chaining)
-
getCustomDefinitionProviders
public List<CustomPropertyDefinitionProvider<M>> getCustomDefinitionProviders()
Getter for the applicable custom property definition provider.- Returns:
- providers for certain custom definitions by-passing the default schema generation to some extent
-
withInstanceAttributeOverride
@Deprecated public SchemaGeneratorConfigPart<M> withInstanceAttributeOverride(InstanceAttributeOverride<M> override)
Deprecated.Setter for override of attributes on a given JSON Schema node in the respective member.- Parameters:
override- override of a given JSON Schema node's instance attributes- Returns:
- this config part (for chaining)
-
withInstanceAttributeOverride
public SchemaGeneratorConfigPart<M> withInstanceAttributeOverride(InstanceAttributeOverrideV2<M> override)
Setter for override of attributes on a given JSON Schema node in the respective member.- Parameters:
override- override of a given JSON Schema node's instance attributes- Returns:
- this config part (for chaining)
-
getInstanceAttributeOverrides
public List<InstanceAttributeOverrideV2<M>> getInstanceAttributeOverrides()
Getter for the applicable instance attribute overrides.- Returns:
- overrides of a given JSON Schema node's instance attributes
-
withIgnoreCheck
public SchemaGeneratorConfigPart<M> withIgnoreCheck(Predicate<M> check)
Setter for ignore check.- Parameters:
check- how to determine whether a given reference should be ignored- Returns:
- this config part (for chaining)
-
shouldIgnore
public boolean shouldIgnore(M member)
Determine whether a given member should be included – ignoring member if any inclusion check returns false.- Parameters:
member- member to check- Returns:
- whether the member should be ignored (defaults to false)
-
withRequiredCheck
public SchemaGeneratorConfigPart<M> withRequiredCheck(Predicate<M> check)
Setter for required check.- Parameters:
check- how to determine whether a given reference should have required value- Returns:
- this config part (for chaining)
-
isRequired
public boolean isRequired(M member)
Determine whether a given member should be indicated as being required in its declaring type.- Parameters:
member- member to check- Returns:
- whether the member is required (defaults to false)
-
withReadOnlyCheck
public SchemaGeneratorConfigPart<M> withReadOnlyCheck(Predicate<M> check)
Setter for read-only check.- Parameters:
check- how to determine whether a given reference should be deemed read-only- Returns:
- this config part (for chaining)
-
isReadOnly
public boolean isReadOnly(M member)
Determine whether a given member should be deemed read-only in its declaring type.- Parameters:
member- member to check- Returns:
- whether the member is read-only (defaults to false)
-
withWriteOnlyCheck
public SchemaGeneratorConfigPart<M> withWriteOnlyCheck(Predicate<M> check)
Setter for write-only check.- Parameters:
check- how to determine whether a given reference should be deemed write-only- Returns:
- this config part (for chaining)
-
isWriteOnly
public boolean isWriteOnly(M member)
Determine whether a given member should be deemed write-only in its declaring type.- Parameters:
member- member to check- Returns:
- whether the member is write-only (defaults to false)
-
withNullableCheck
public SchemaGeneratorConfigPart<M> withNullableCheck(ConfigFunction<M,Boolean> check)
Setter for nullable check.- Parameters:
check- how to determine whether a given reference should be nullable- Returns:
- this config part (for chaining)
-
isNullable
public Boolean isNullable(M member)
Determine whether a given member is nullable.- Parameters:
member- member to check- Returns:
- whether the member is nullable (may be null if not specified)
-
withTargetTypeOverrideResolver
@Deprecated public SchemaGeneratorConfigPart<M> withTargetTypeOverrideResolver(ConfigFunction<M,com.fasterxml.classmate.ResolvedType> resolver)
Deprecated.usewithTargetTypeOverridesResolver(ConfigFunction)insteadSetter for target type resolver, expecting the respective member as input. NOTE: there is an alternative method allowing for multiple type overrides at once:withTargetTypeOverridesResolver(ConfigFunction)
For generally replacing one type with one or multiple of its subtypes, you may want to consider adding aSubtypeResolverviaforTypesInGeneral()instead.- Parameters:
resolver- how to determine the alternative target type- Returns:
- this config part (for chaining)
- See Also:
SchemaGeneratorGeneralConfigPart.withSubtypeResolver(SubtypeResolver)
-
withTargetTypeOverridesResolver
public SchemaGeneratorConfigPart<M> withTargetTypeOverridesResolver(ConfigFunction<M,List<com.fasterxml.classmate.ResolvedType>> resolver)
Setter for target type resolver, expecting the respective member as input. Allowing for multiple alternative types to be returned.
For generally replacing one type with one or multiple of its subtypes, you may want to consider adding aSubtypeResolverviaforTypesInGeneral()instead.- Parameters:
resolver- how to determine the alternative target types- Returns:
- this config part (for chaining)
- See Also:
SchemaGeneratorGeneralConfigPart.withSubtypeResolver(SubtypeResolver)
-
resolveTargetTypeOverrides
public List<com.fasterxml.classmate.ResolvedType> resolveTargetTypeOverrides(M member)
Determine the alternative target type from a given member.- Parameters:
member- member to determine the target type override for- Returns:
- target type of member (may be null)
- See Also:
MemberScope.getDeclaredType(),MemberScope.getOverriddenType()
-
withPropertyNameOverrideResolver
public SchemaGeneratorConfigPart<M> withPropertyNameOverrideResolver(ConfigFunction<M,String> resolver)
Setter for property name resolver, expecting the respective member and the default name as inputs.- Parameters:
resolver- how to determine the alternative name in a parent JSON Schema's "properties"- Returns:
- this config part (for chaining)
-
resolvePropertyNameOverride
public String resolvePropertyNameOverride(M member)
Determine the alternative name in a parent JSON Schema's "properties" from a given member.- Parameters:
member- member to determine the property name for- Returns:
- name in a parent JSON Schema's "properties" (may be null, thereby falling back on the default value)
-
withTitleResolver
public SchemaGeneratorConfigPart<M> withTitleResolver(ConfigFunction<M,String> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "title" resolver.- Overrides:
withTitleResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "title" of a JSON Schema- Returns:
- this config part (for chaining)
-
withDescriptionResolver
public SchemaGeneratorConfigPart<M> withDescriptionResolver(ConfigFunction<M,String> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "description" resolver.- Overrides:
withDescriptionResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "description" of a JSON Schema- Returns:
- this config part (for chaining)
-
withDefaultResolver
public SchemaGeneratorConfigPart<M> withDefaultResolver(ConfigFunction<M,Object> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "default" resolver.- Overrides:
withDefaultResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "default" of a JSON Schema- Returns:
- this config part (for chaining)
-
withEnumResolver
public SchemaGeneratorConfigPart<M> withEnumResolver(ConfigFunction<M,Collection<?>> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "enum"/"const" resolver.- Overrides:
withEnumResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "enum"/"const" of a JSON Schema- Returns:
- this config part (for chaining)
-
withAdditionalPropertiesResolver
public SchemaGeneratorConfigPart<M> withAdditionalPropertiesResolver(ConfigFunction<M,Type> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "additionalProperties" resolver. If the returned type isVoid"false" will be set, otherwise an appropriate sub-schema.- Overrides:
withAdditionalPropertiesResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "additionalProperties" of a JSON Schema, returningVoidwill result in "false"- Returns:
- this config part (for chaining)
-
withAdditionalPropertiesResolver
public SchemaGeneratorConfigPart<M> withAdditionalPropertiesResolver(BiFunction<M,SchemaGenerationContext,com.fasterxml.jackson.databind.JsonNode> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "additionalProperties" resolver. If the returned type isVoid"false" will be set, otherwise an appropriate sub-schema.- Overrides:
withAdditionalPropertiesResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "additionalProperties" of a JSON Schema, returningVoidwill result in "false"- Returns:
- this config part (for chaining)
-
withPatternPropertiesResolver
public SchemaGeneratorConfigPart<M> withPatternPropertiesResolver(ConfigFunction<M,Map<String,Type>> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "patternProperties" resolver. The map's keys are representing the patterns and the mapped values their corresponding types.- Overrides:
withPatternPropertiesResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "patternProperties" of a JSON Schema- Returns:
- this config part (for chaining)
-
withPatternPropertiesResolver
public SchemaGeneratorConfigPart<M> withPatternPropertiesResolver(BiFunction<M,SchemaGenerationContext,Map<String,com.fasterxml.jackson.databind.JsonNode>> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "patternProperties" resolver. The map's keys are representing the patterns and the mapped values their corresponding types.- Overrides:
withPatternPropertiesResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "patternProperties" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringMinLengthResolver
public SchemaGeneratorConfigPart<M> withStringMinLengthResolver(ConfigFunction<M,Integer> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "minLength" resolver.- Overrides:
withStringMinLengthResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "minLength" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringMaxLengthResolver
public SchemaGeneratorConfigPart<M> withStringMaxLengthResolver(ConfigFunction<M,Integer> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "maxLength" resolver.- Overrides:
withStringMaxLengthResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "maxLength" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringFormatResolver
public SchemaGeneratorConfigPart<M> withStringFormatResolver(ConfigFunction<M,String> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "format" resolver.- Overrides:
withStringFormatResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "format" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringPatternResolver
public SchemaGeneratorConfigPart<M> withStringPatternResolver(ConfigFunction<M,String> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "format" resolver.- Overrides:
withStringPatternResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "format" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberInclusiveMinimumResolver
public SchemaGeneratorConfigPart<M> withNumberInclusiveMinimumResolver(ConfigFunction<M,BigDecimal> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "minimum" resolver.- Overrides:
withNumberInclusiveMinimumResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "minimum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberExclusiveMinimumResolver
public SchemaGeneratorConfigPart<M> withNumberExclusiveMinimumResolver(ConfigFunction<M,BigDecimal> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "exclusiveMinimum" resolver.- Overrides:
withNumberExclusiveMinimumResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "exclusiveMinimum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberInclusiveMaximumResolver
public SchemaGeneratorConfigPart<M> withNumberInclusiveMaximumResolver(ConfigFunction<M,BigDecimal> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "maximum" resolver.- Overrides:
withNumberInclusiveMaximumResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "maximum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberExclusiveMaximumResolver
public SchemaGeneratorConfigPart<M> withNumberExclusiveMaximumResolver(ConfigFunction<M,BigDecimal> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "exclusiveMaximum" resolver.- Overrides:
withNumberExclusiveMaximumResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "exclusiveMaximum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberMultipleOfResolver
public SchemaGeneratorConfigPart<M> withNumberMultipleOfResolver(ConfigFunction<M,BigDecimal> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "multipleOf" resolver.- Overrides:
withNumberMultipleOfResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "multipleOf" of a JSON Schema- Returns:
- this config part (for chaining)
-
withArrayMinItemsResolver
public SchemaGeneratorConfigPart<M> withArrayMinItemsResolver(ConfigFunction<M,Integer> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "minItems" resolver.- Overrides:
withArrayMinItemsResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "minItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
withArrayMaxItemsResolver
public SchemaGeneratorConfigPart<M> withArrayMaxItemsResolver(ConfigFunction<M,Integer> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "maxItems" resolver.- Overrides:
withArrayMaxItemsResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "maxItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
withArrayUniqueItemsResolver
public SchemaGeneratorConfigPart<M> withArrayUniqueItemsResolver(ConfigFunction<M,Boolean> resolver)
Description copied from class:SchemaGeneratorTypeConfigPartSetter for "uniqueItems" resolver.- Overrides:
withArrayUniqueItemsResolverin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>- Parameters:
resolver- how to determine the "uniqueItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
resetAfterSchemaGenerationFinished
public void resetAfterSchemaGenerationFinished()
Description copied from interface:StatefulConfigMethod being invoked after the generation of a single "main" type's schema has been completed. This enables the sameSchemaGeneratorinstance to be re-used for multiple subsequent executions, even if some aspect of the configuration remembers the original "main" type.- Specified by:
resetAfterSchemaGenerationFinishedin interfaceStatefulConfig- Overrides:
resetAfterSchemaGenerationFinishedin classSchemaGeneratorTypeConfigPart<M extends MemberScope<?,?>>
-
-