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 -
Method Summary
Modifier and TypeMethodDescriptionGetter for the applicable custom property definition provider.Getter for the applicable instance attribute overrides.isNullable(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.voidMethod being invoked after the generation of a single "main" type's schema has been completed.resolveDependentRequires(M member) Determine the names of other properties that are required to have a value, if the given member is present.resolvePropertyNameOverride(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.withAdditionalPropertiesResolver(ConfigFunction<M, Type> resolver) Setter for "additionalProperties" resolver.withAdditionalPropertiesResolver(BiFunction<M, SchemaGenerationContext, tools.jackson.databind.JsonNode> resolver) Setter for "additionalProperties" resolver.withArrayMaxItemsResolver(ConfigFunction<M, Integer> resolver) Setter for "maxItems" resolver.withArrayMinItemsResolver(ConfigFunction<M, Integer> resolver) Setter for "minItems" resolver.withArrayUniqueItemsResolver(ConfigFunction<M, Boolean> resolver) Setter for "uniqueItems" resolver.withCustomDefinitionProvider(CustomPropertyDefinitionProvider<M> definitionProvider) Adding a custom schema provider - if it returns null for a given type, the next definition provider will be applied.withDefaultResolver(ConfigFunction<M, Object> resolver) Setter for "default" resolver.withDependentRequiresResolver(ConfigFunction<M, List<String>> resolver) Setter for resolver, that collects the names of other properties that are required depending on the targeted one.withDescriptionResolver(ConfigFunction<M, String> resolver) Setter for "description" resolver.withEnumResolver(ConfigFunction<M, Collection<?>> resolver) Setter for "enum"/"const" resolver.withIgnoreCheck(Predicate<M> check) Setter for ignore check.Deprecated.Setter for override of attributes on a given JSON Schema node in the respective member.withNullableCheck(ConfigFunction<M, Boolean> check) Setter for nullable check.Setter for "exclusiveMaximum" resolver.Setter for "exclusiveMinimum" resolver.Setter for "maximum" resolver.Setter for "minimum" resolver.withNumberMultipleOfResolver(ConfigFunction<M, BigDecimal> resolver) Setter for "multipleOf" resolver.withPatternPropertiesResolver(ConfigFunction<M, Map<String, Type>> resolver) Setter for "patternProperties" resolver.withPatternPropertiesResolver(BiFunction<M, SchemaGenerationContext, Map<String, tools.jackson.databind.JsonNode>> resolver) Setter for "patternProperties" resolver.withPropertyNameOverrideResolver(ConfigFunction<M, String> resolver) Setter for property name resolver, expecting the respective member and the default name as inputs.withReadOnlyCheck(Predicate<M> check) Setter for read-only check.withRequiredCheck(Predicate<M> check) Setter for required check.withStringFormatResolver(ConfigFunction<M, String> resolver) Setter for "format" resolver.withStringMaxLengthResolver(ConfigFunction<M, Integer> resolver) Setter for "maxLength" resolver.withStringMinLengthResolver(ConfigFunction<M, Integer> resolver) Setter for "minLength" resolver.withStringPatternResolver(ConfigFunction<M, String> resolver) Setter for "format" resolver.withTargetTypeOverrideResolver(ConfigFunction<M, com.fasterxml.classmate.ResolvedType> resolver) Deprecated.usewithTargetTypeOverridesResolver(ConfigFunction)insteadwithTargetTypeOverridesResolver(ConfigFunction<M, List<com.fasterxml.classmate.ResolvedType>> resolver) Setter for target type resolver, expecting the respective member as input.withTitleResolver(ConfigFunction<M, String> resolver) Setter for "title" resolver.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
-
Constructor Details
-
SchemaGeneratorConfigPart
public SchemaGeneratorConfigPart()
-
-
Method Details
-
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
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
Getter for the applicable instance attribute overrides.- Returns:
- overrides of a given JSON Schema node's instance attributes
-
withIgnoreCheck
Setter for ignore check.- Parameters:
check- how to determine whether a given reference should be ignored- Returns:
- this config part (for chaining)
-
shouldIgnore
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
Setter for required check.- Parameters:
check- how to determine whether a given reference should have required value- Returns:
- this config part (for chaining)
-
isRequired
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
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
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
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
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
Setter for nullable check.- Parameters:
check- how to determine whether a given reference should be nullable- Returns:
- this config part (for chaining)
-
isNullable
Determine whether a given member is nullable.- Parameters:
member- member to check- Returns:
- whether the member is nullable (may be null if not specified)
-
withDependentRequiresResolver
public SchemaGeneratorConfigPart<M> withDependentRequiresResolver(ConfigFunction<M, List<String>> resolver) Setter for resolver, that collects the names of other properties that are required depending on the targeted one.
Beware that the output of all configured resolvers are combined, i.e., not just considering the first that returns a value.- Parameters:
resolver- how to determine which other properties should have a required value if the given one is present.- Returns:
- this config part (for chaining)
-
resolveDependentRequires
Determine the names of other properties that are required to have a value, if the given member is present.- Parameters:
member- member to check- Returns:
- list of other properties' names (may be empty)
-
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:
-
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:
-
resolveTargetTypeOverrides
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:
-
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
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
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
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
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
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, tools.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, tools.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
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
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
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
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
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
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<?,?>>
-
withInstanceAttributeOverride(InstanceAttributeOverrideV2)instead