Class SchemaGeneratorGeneralConfigPart
java.lang.Object
com.github.victools.jsonschema.generator.SchemaGeneratorTypeConfigPart<TypeScope>
com.github.victools.jsonschema.generator.SchemaGeneratorGeneralConfigPart
- All Implemented Interfaces:
StatefulConfig
Generic collection of reflection based analysis for populating a JSON Schema targeting a specific type in general.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGetter for the applicable custom definition provider.Getter for the current naming strategy for keys in the "definitions"/"$defs".Comparator<MemberScope<?,?>> Getter for the sorting algorithm for an object's properties (fields and methods).Getter for the applicable subtype resolvers.Getter for the applicable overrides for type attributes.voidMethod being invoked after the generation of a single "main" type's schema has been completed.resolveAnchor(TypeScope scope) Determine the "$anchor" of a context-independent type representation.Determine the "$id" of a context-independent type representation.Setter for "additionalProperties" resolver.withAdditionalPropertiesResolver(BiFunction<TypeScope, SchemaGenerationContext, tools.jackson.databind.JsonNode> resolver) Setter for "additionalProperties" resolver.withAnchorResolver(ConfigFunction<TypeScope, String> resolver) Setter for "$anchor" resolver.withArrayMaxItemsResolver(ConfigFunction<TypeScope, Integer> resolver) Setter for "maxItems" resolver.withArrayMinItemsResolver(ConfigFunction<TypeScope, Integer> resolver) Setter for "minItems" resolver.Setter for "uniqueItems" resolver.withCustomDefinitionProvider(CustomDefinitionProviderV2 definitionProvider) Adding a custom schema provider - if it returns null for a given type, the next definition provider will be applied.withDefaultResolver(ConfigFunction<TypeScope, Object> resolver) Setter for "default" resolver.withDefinitionNamingStrategy(SchemaDefinitionNamingStrategy namingStrategy) Replacing the current naming strategy for keys in the "definitions"/"$defs".withDescriptionResolver(ConfigFunction<TypeScope, String> resolver) Setter for "description" resolver.withEnumResolver(ConfigFunction<TypeScope, Collection<?>> resolver) Setter for "enum"/"const" resolver.withIdResolver(ConfigFunction<TypeScope, String> resolver) Setter for "$id" resolver.Setter for "exclusiveMaximum" resolver.Setter for "exclusiveMinimum" resolver.Setter for "maximum" resolver.Setter for "minimum" resolver.Setter for "multipleOf" resolver.withPatternPropertiesResolver(ConfigFunction<TypeScope, Map<String, Type>> resolver) Setter for "patternProperties" resolver.withPatternPropertiesResolver(BiFunction<TypeScope, SchemaGenerationContext, Map<String, tools.jackson.databind.JsonNode>> resolver) Setter for "patternProperties" resolver.withPropertySorter(Comparator<MemberScope<?, ?>> propertySorter) Replacing the current sorting algorithm of properties (fields and methods).withStringFormatResolver(ConfigFunction<TypeScope, String> resolver) Setter for "format" resolver.Setter for "maxLength" resolver.Setter for "minLength" resolver.withStringPatternResolver(ConfigFunction<TypeScope, String> resolver) Setter for "format" resolver.withSubtypeResolver(SubtypeResolver subtypeResolver) Adding a subtype resolver - if it returns null for a given type, the next subtype resolver will be applied.withTitleResolver(ConfigFunction<TypeScope, String> resolver) Setter for "title" resolver.Adding an override for type attributes - all the registered overrides will be applied in the order of having been added.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
-
SchemaGeneratorGeneralConfigPart
public SchemaGeneratorGeneralConfigPart()
-
-
Method Details
-
withPropertySorter
public SchemaGeneratorGeneralConfigPart withPropertySorter(Comparator<MemberScope<?, ?>> propertySorter) Replacing the current sorting algorithm of properties (fields and methods).- Parameters:
propertySorter- sorting algorithm for an object's properties- Returns:
- this builder instance (for chaining)
-
getPropertySorter
Getter for the sorting algorithm for an object's properties (fields and methods).- Returns:
- applicable
Comparatorfor an object's properties
-
withDefinitionNamingStrategy
public SchemaGeneratorGeneralConfigPart withDefinitionNamingStrategy(SchemaDefinitionNamingStrategy namingStrategy) Replacing the current naming strategy for keys in the "definitions"/"$defs".- Parameters:
namingStrategy- naming strategy for "definitions"/"$defs" keys- Returns:
- this builder instance (for chaining)
-
getDefinitionNamingStrategy
Getter for the current naming strategy for keys in the "definitions"/"$defs".- Returns:
- applicable naming strategy for "definitions"/"$defs" keys (or
nullif the a default strategy should be used)
-
withCustomDefinitionProvider
public SchemaGeneratorGeneralConfigPart withCustomDefinitionProvider(CustomDefinitionProviderV2 definitionProvider) Adding a custom schema provider - if it returns null for a given type, the next definition provider will be applied.
If all custom schema providers return null (or there is none), then the standard behaviour applies.- Parameters:
definitionProvider- provider of a custom definition to register, which may return null- Returns:
- this builder instance (for chaining)
-
getCustomDefinitionProviders
Getter for the applicable custom definition provider.- Returns:
- providers for certain custom definitions by-passing the default schema generation to some extent
-
withSubtypeResolver
Adding a subtype resolver - if it returns null for a given type, the next subtype resolver will be applied.
If all subtype resolvers return null, there is none or a resolver returns an empty list, then the standard behaviour applies.- Parameters:
subtypeResolver- resolver for looking up a declared type's subtypes in order to list those specifically- Returns:
- this builder instance (for chaining)
-
getSubtypeResolvers
Getter for the applicable subtype resolvers.- Returns:
- registered subtype resolvers
-
withTypeAttributeOverride
Adding an override for type attributes - all the registered overrides will be applied in the order of having been added.- Parameters:
override- adding/removing attributes on a JSON Schema node - specifically intended for attributes relating to the type in general.- Returns:
- this builder instance (for chaining)
-
getTypeAttributeOverrides
Getter for the applicable overrides for type attributes.- Returns:
- registered overrides to be applied in the given order
-
withIdResolver
Setter for "$id" resolver.- Parameters:
resolver- how to determine the "$id" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveId
Determine the "$id" of a context-independent type representation.- Parameters:
scope- context-independent type representation to determine "$id" value for- Returns:
- "$id" in a JSON Schema (may be null)
-
withAnchorResolver
public SchemaGeneratorGeneralConfigPart withAnchorResolver(ConfigFunction<TypeScope, String> resolver) Setter for "$anchor" resolver.- Parameters:
resolver- how to determine the "$anchor" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveAnchor
Determine the "$anchor" of a context-independent type representation.- Parameters:
scope- context-independent type representation to determine "$anchor" value for- Returns:
- "$anchor" in a JSON Schema (may be null)
-
withTitleResolver
public SchemaGeneratorGeneralConfigPart withTitleResolver(ConfigFunction<TypeScope, String> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "title" resolver.- Overrides:
withTitleResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "title" of a JSON Schema- Returns:
- this config part (for chaining)
-
withDescriptionResolver
public SchemaGeneratorGeneralConfigPart withDescriptionResolver(ConfigFunction<TypeScope, String> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "description" resolver.- Overrides:
withDescriptionResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "description" of a JSON Schema- Returns:
- this config part (for chaining)
-
withDefaultResolver
public SchemaGeneratorGeneralConfigPart withDefaultResolver(ConfigFunction<TypeScope, Object> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "default" resolver.- Overrides:
withDefaultResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "default" of a JSON Schema- Returns:
- this config part (for chaining)
-
withEnumResolver
public SchemaGeneratorGeneralConfigPart withEnumResolver(ConfigFunction<TypeScope, Collection<?>> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "enum"/"const" resolver.- Overrides:
withEnumResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "enum"/"const" of a JSON Schema- Returns:
- this config part (for chaining)
-
withAdditionalPropertiesResolver
public SchemaGeneratorGeneralConfigPart withAdditionalPropertiesResolver(ConfigFunction<TypeScope, 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<TypeScope>- Parameters:
resolver- how to determine the "additionalProperties" of a JSON Schema, returningVoidwill result in "false"- Returns:
- this config part (for chaining)
-
withAdditionalPropertiesResolver
public SchemaGeneratorGeneralConfigPart withAdditionalPropertiesResolver(BiFunction<TypeScope, 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<TypeScope>- Parameters:
resolver- how to determine the "additionalProperties" of a JSON Schema, returningVoidwill result in "false"- Returns:
- this config part (for chaining)
-
withPatternPropertiesResolver
public SchemaGeneratorGeneralConfigPart withPatternPropertiesResolver(ConfigFunction<TypeScope, 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<TypeScope>- Parameters:
resolver- how to determine the "patternProperties" of a JSON Schema- Returns:
- this config part (for chaining)
-
withPatternPropertiesResolver
public SchemaGeneratorGeneralConfigPart withPatternPropertiesResolver(BiFunction<TypeScope, 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<TypeScope>- Parameters:
resolver- how to determine the "patternProperties" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringMinLengthResolver
public SchemaGeneratorGeneralConfigPart withStringMinLengthResolver(ConfigFunction<TypeScope, Integer> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "minLength" resolver.- Overrides:
withStringMinLengthResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "minLength" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringMaxLengthResolver
public SchemaGeneratorGeneralConfigPart withStringMaxLengthResolver(ConfigFunction<TypeScope, Integer> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "maxLength" resolver.- Overrides:
withStringMaxLengthResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "maxLength" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringFormatResolver
public SchemaGeneratorGeneralConfigPart withStringFormatResolver(ConfigFunction<TypeScope, String> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "format" resolver.- Overrides:
withStringFormatResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "format" of a JSON Schema- Returns:
- this config part (for chaining)
-
withStringPatternResolver
public SchemaGeneratorGeneralConfigPart withStringPatternResolver(ConfigFunction<TypeScope, String> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "format" resolver.- Overrides:
withStringPatternResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "format" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberInclusiveMinimumResolver
public SchemaGeneratorGeneralConfigPart withNumberInclusiveMinimumResolver(ConfigFunction<TypeScope, BigDecimal> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "minimum" resolver.- Overrides:
withNumberInclusiveMinimumResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "minimum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberExclusiveMinimumResolver
public SchemaGeneratorGeneralConfigPart withNumberExclusiveMinimumResolver(ConfigFunction<TypeScope, BigDecimal> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "exclusiveMinimum" resolver.- Overrides:
withNumberExclusiveMinimumResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "exclusiveMinimum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberInclusiveMaximumResolver
public SchemaGeneratorGeneralConfigPart withNumberInclusiveMaximumResolver(ConfigFunction<TypeScope, BigDecimal> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "maximum" resolver.- Overrides:
withNumberInclusiveMaximumResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "maximum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberExclusiveMaximumResolver
public SchemaGeneratorGeneralConfigPart withNumberExclusiveMaximumResolver(ConfigFunction<TypeScope, BigDecimal> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "exclusiveMaximum" resolver.- Overrides:
withNumberExclusiveMaximumResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "exclusiveMaximum" of a JSON Schema- Returns:
- this config part (for chaining)
-
withNumberMultipleOfResolver
public SchemaGeneratorGeneralConfigPart withNumberMultipleOfResolver(ConfigFunction<TypeScope, BigDecimal> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "multipleOf" resolver.- Overrides:
withNumberMultipleOfResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "multipleOf" of a JSON Schema- Returns:
- this config part (for chaining)
-
withArrayMinItemsResolver
public SchemaGeneratorGeneralConfigPart withArrayMinItemsResolver(ConfigFunction<TypeScope, Integer> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "minItems" resolver.- Overrides:
withArrayMinItemsResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "minItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
withArrayMaxItemsResolver
public SchemaGeneratorGeneralConfigPart withArrayMaxItemsResolver(ConfigFunction<TypeScope, Integer> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "maxItems" resolver.- Overrides:
withArrayMaxItemsResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- Parameters:
resolver- how to determine the "maxItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
withArrayUniqueItemsResolver
public SchemaGeneratorGeneralConfigPart withArrayUniqueItemsResolver(ConfigFunction<TypeScope, Boolean> resolver) Description copied from class:SchemaGeneratorTypeConfigPartSetter for "uniqueItems" resolver.- Overrides:
withArrayUniqueItemsResolverin classSchemaGeneratorTypeConfigPart<TypeScope>- 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<TypeScope>
-