Class SchemaGeneratorTypeConfigPart<S extends TypeScope>
java.lang.Object
com.github.victools.jsonschema.generator.SchemaGeneratorTypeConfigPart<S>
- Type Parameters:
S- type of the scope/type representation to analyse
- All Implemented Interfaces:
StatefulConfig
- Direct Known Subclasses:
SchemaGeneratorConfigPart,SchemaGeneratorGeneralConfigPart
public class SchemaGeneratorTypeConfigPart<S extends TypeScope>
extends Object
implements StatefulConfig
Generic collection of reflection based analysis for populating a JSON Schema.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static <S extends TypeScope,R>
RgetFirstDefinedValue(List<ConfigFunction<S, R>> resolvers, S scope) Helper function for invoking a given function with the provided inputs or returning null, if all functions return null themselves.protected static <S extends TypeScope,R>
RgetFirstDefinedValue(List<BiFunction<S, SchemaGenerationContext, R>> resolvers, S scope, SchemaGenerationContext context) Helper function for invoking a given function with the provided inputs or returning null, if all functions return null themselves.voidMethod being invoked after the generation of a single "main" type's schema has been completed.tools.jackson.databind.JsonNoderesolveAdditionalProperties(S scope, SchemaGenerationContext context) Determine the "additionalProperties" of a given scope/type representation.resolveArrayMaxItems(S scope) Determine the "maxItems" of a given scope/type representation.resolveArrayMinItems(S scope) Determine the "minItems" of a given scope/type representation.resolveArrayUniqueItems(S scope) Determine the "uniqueItems" of a given scope/type representation.resolveDefault(S scope) Determine the "default" of a given scope/type representation.resolveDescription(S scope) Determine the "description" of a given scope/type representation.Collection<?>resolveEnum(S scope) Determine the "enum"/"const" of a given scope/type representation.resolveNumberExclusiveMaximum(S scope) Determine the "exclusiveMaximum" of a given scope/type representation.resolveNumberExclusiveMinimum(S scope) Determine the "exclusiveMinimum" of a given scope/type representation.resolveNumberInclusiveMaximum(S scope) Determine the "maximum" of a given scope/type representation.resolveNumberInclusiveMinimum(S scope) Determine the "minimum" of a given scope/type representation.resolveNumberMultipleOf(S scope) Determine the "multipleOf" of a given scope/type representation.resolvePatternProperties(S scope, SchemaGenerationContext context) Determine the "patternProperties" of a given scope/type representation.resolveStringFormat(S scope) Determine the "format" of a given scope/type representation.resolveStringMaxLength(S scope) Determine the "maxLength" of a given scope/type representation.resolveStringMinLength(S scope) Determine the "minLength" of a given scope/type representation.resolveStringPattern(S scope) Determine the "format" of a given scope/type representation.resolveTitle(S scope) Determine the "title" of a given scope/type representation.withAdditionalPropertiesResolver(ConfigFunction<S, Type> resolver) Setter for "additionalProperties" resolver.withAdditionalPropertiesResolver(BiFunction<S, SchemaGenerationContext, tools.jackson.databind.JsonNode> resolver) Setter for "additionalProperties" resolver.withArrayMaxItemsResolver(ConfigFunction<S, Integer> resolver) Setter for "maxItems" resolver.withArrayMinItemsResolver(ConfigFunction<S, Integer> resolver) Setter for "minItems" resolver.withArrayUniqueItemsResolver(ConfigFunction<S, Boolean> resolver) Setter for "uniqueItems" resolver.withDefaultResolver(ConfigFunction<S, Object> resolver) Setter for "default" resolver.withDescriptionResolver(ConfigFunction<S, String> resolver) Setter for "description" resolver.withEnumResolver(ConfigFunction<S, Collection<?>> resolver) Setter for "enum"/"const" resolver.Setter for "exclusiveMaximum" resolver.Setter for "exclusiveMinimum" resolver.Setter for "maximum" resolver.Setter for "minimum" resolver.withNumberMultipleOfResolver(ConfigFunction<S, BigDecimal> resolver) Setter for "multipleOf" resolver.withPatternPropertiesResolver(ConfigFunction<S, Map<String, Type>> resolver) Setter for "patternProperties" resolver.withPatternPropertiesResolver(BiFunction<S, SchemaGenerationContext, Map<String, tools.jackson.databind.JsonNode>> resolver) Setter for "patternProperties" resolver.withStringFormatResolver(ConfigFunction<S, String> resolver) Setter for "format" resolver.withStringMaxLengthResolver(ConfigFunction<S, Integer> resolver) Setter for "maxLength" resolver.withStringMinLengthResolver(ConfigFunction<S, Integer> resolver) Setter for "minLength" resolver.withStringPatternResolver(ConfigFunction<S, String> resolver) Setter for "format" resolver.withTitleResolver(ConfigFunction<S, String> resolver) Setter for "title" resolver.
-
Constructor Details
-
SchemaGeneratorTypeConfigPart
public SchemaGeneratorTypeConfigPart()
-
-
Method Details
-
getFirstDefinedValue
protected static <S extends TypeScope,R> R getFirstDefinedValue(List<ConfigFunction<S, R>> resolvers, S scope) Helper function for invoking a given function with the provided inputs or returning null, if all functions return null themselves.- Type Parameters:
S- type of the targeted scope/type representation (to be forwarded as parameter to the given function)R- type of the expected return value (of the given function)- Parameters:
resolvers- functions to invoke and return the first non-null result fromscope- targeted scope (to be forwarded as first argument to a given function)- Returns:
- return value of successfully invoked function or null
-
getFirstDefinedValue
protected static <S extends TypeScope,R> R getFirstDefinedValue(List<BiFunction<S, SchemaGenerationContext, R>> resolvers, S scope, SchemaGenerationContext context) Helper function for invoking a given function with the provided inputs or returning null, if all functions return null themselves.- Type Parameters:
S- type of the targeted scope/type representation (to be forwarded as first parameter to the given function)R- type of the expected return value (of the given function)- Parameters:
resolvers- functions to invoke and return the first non-null result fromscope- targeted scope (to be forwarded as first argument to a given function)context- generation context enabling advanced features within the given configuration- Returns:
- return value of successfully invoked function or null
-
withTitleResolver
Setter for "title" resolver.- Parameters:
resolver- how to determine the "title" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveTitle
Determine the "title" of a given scope/type representation.- Parameters:
scope- scope to determine "title" value for- Returns:
- "title" in a JSON Schema (may be null)
-
withDescriptionResolver
Setter for "description" resolver.- Parameters:
resolver- how to determine the "description" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveDescription
Determine the "description" of a given scope/type representation.- Parameters:
scope- scope to determine "description" value for- Returns:
- "description" in a JSON Schema (may be null)
-
withDefaultResolver
Setter for "default" resolver.- Parameters:
resolver- how to determine the "default" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveDefault
Determine the "default" of a given scope/type representation.- Parameters:
scope- scope to determine "default" value for- Returns:
- "default" in a JSON Schema (may be null)
-
withEnumResolver
Setter for "enum"/"const" resolver.- Parameters:
resolver- how to determine the "enum"/"const" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveEnum
Determine the "enum"/"const" of a given scope/type representation.- Parameters:
scope- scope to determine "enum"/"const" value for- Returns:
- "enum"/"const" in a JSON Schema (may be null)
-
withAdditionalPropertiesResolver
public SchemaGeneratorTypeConfigPart<S> withAdditionalPropertiesResolver(ConfigFunction<S, Type> resolver) Setter for "additionalProperties" resolver. If the returned type isVoid"false" will be set, otherwise an appropriate sub-schema.- Parameters:
resolver- how to determine the "additionalProperties" of a JSON Schema, returningVoidwill result in "false"- Returns:
- this config part (for chaining)
-
withAdditionalPropertiesResolver
public SchemaGeneratorTypeConfigPart<S> withAdditionalPropertiesResolver(BiFunction<S, SchemaGenerationContext, tools.jackson.databind.JsonNode> resolver) Setter for "additionalProperties" resolver. If the returned type isVoid"false" will be set, otherwise an appropriate sub-schema.- Parameters:
resolver- how to determine the "additionalProperties" of a JSON Schema, returningVoidwill result in "false"- Returns:
- this config part (for chaining)
-
resolveAdditionalProperties
public tools.jackson.databind.JsonNode resolveAdditionalProperties(S scope, SchemaGenerationContext context) Determine the "additionalProperties" of a given scope/type representation.- Parameters:
scope- scope to determine "additionalProperties" value forcontext- generation context allowing to let the standard generation take over nested parts of the custom definition- Returns:
- "additionalProperties" in a JSON Schema (may be null)
-
withPatternPropertiesResolver
public SchemaGeneratorTypeConfigPart<S> withPatternPropertiesResolver(ConfigFunction<S, Map<String, Type>> resolver) Setter for "patternProperties" resolver. The map's keys are representing the patterns and the mapped values their corresponding types.- Parameters:
resolver- how to determine the "patternProperties" of a JSON Schema- Returns:
- this config part (for chaining)
-
withPatternPropertiesResolver
public SchemaGeneratorTypeConfigPart<S> withPatternPropertiesResolver(BiFunction<S, SchemaGenerationContext, Map<String, tools.jackson.databind.JsonNode>> resolver) Setter for "patternProperties" resolver. The map's keys are representing the patterns and the mapped values their corresponding types.- Parameters:
resolver- how to determine the "patternProperties" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolvePatternProperties
public Map<String,tools.jackson.databind.JsonNode> resolvePatternProperties(S scope, SchemaGenerationContext context) Determine the "patternProperties" of a given scope/type representation.- Parameters:
scope- scope to determine "patternProperties" value forcontext- generation context allowing to let the standard generation take over nested parts of the custom definition- Returns:
- "patternProperties" in a JSON Schema (may be null), the keys representing the patterns and the mapped values their corresponding types
-
withStringMinLengthResolver
public SchemaGeneratorTypeConfigPart<S> withStringMinLengthResolver(ConfigFunction<S, Integer> resolver) Setter for "minLength" resolver.- Parameters:
resolver- how to determine the "minLength" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveStringMinLength
Determine the "minLength" of a given scope/type representation.- Parameters:
scope- scope to determine "minLength" value for- Returns:
- "minLength" in a JSON Schema (may be null)
-
withStringMaxLengthResolver
public SchemaGeneratorTypeConfigPart<S> withStringMaxLengthResolver(ConfigFunction<S, Integer> resolver) Setter for "maxLength" resolver.- Parameters:
resolver- how to determine the "maxLength" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveStringMaxLength
Determine the "maxLength" of a given scope/type representation.- Parameters:
scope- scope to determine "maxLength" value for- Returns:
- "maxLength" in a JSON Schema (may be null)
-
withStringFormatResolver
Setter for "format" resolver.- Parameters:
resolver- how to determine the "format" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveStringFormat
Determine the "format" of a given scope/type representation.- Parameters:
scope- scope to determine "format" value for- Returns:
- "format" in a JSON Schema (may be null)
-
withStringPatternResolver
public SchemaGeneratorTypeConfigPart<S> withStringPatternResolver(ConfigFunction<S, String> resolver) Setter for "format" resolver.- Parameters:
resolver- how to determine the "format" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveStringPattern
Determine the "format" of a given scope/type representation.- Parameters:
scope- scope to determine "format" value for- Returns:
- "format" in a JSON Schema (may be null)
-
withNumberInclusiveMinimumResolver
public SchemaGeneratorTypeConfigPart<S> withNumberInclusiveMinimumResolver(ConfigFunction<S, BigDecimal> resolver) Setter for "minimum" resolver.- Parameters:
resolver- how to determine the "minimum" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveNumberInclusiveMinimum
Determine the "minimum" of a given scope/type representation.- Parameters:
scope- scope to determine "minimum" value for- Returns:
- "minimum" in a JSON Schema (may be null)
-
withNumberExclusiveMinimumResolver
public SchemaGeneratorTypeConfigPart<S> withNumberExclusiveMinimumResolver(ConfigFunction<S, BigDecimal> resolver) Setter for "exclusiveMinimum" resolver.- Parameters:
resolver- how to determine the "exclusiveMinimum" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveNumberExclusiveMinimum
Determine the "exclusiveMinimum" of a given scope/type representation.- Parameters:
scope- scope to determine "exclusiveMinimum" value for- Returns:
- "exclusiveMinimum" in a JSON Schema (may be null)
-
withNumberInclusiveMaximumResolver
public SchemaGeneratorTypeConfigPart<S> withNumberInclusiveMaximumResolver(ConfigFunction<S, BigDecimal> resolver) Setter for "maximum" resolver.- Parameters:
resolver- how to determine the "maximum" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveNumberInclusiveMaximum
Determine the "maximum" of a given scope/type representation.- Parameters:
scope- scope to determine "maximum" value for- Returns:
- "maximum" in a JSON Schema (may be null)
-
withNumberExclusiveMaximumResolver
public SchemaGeneratorTypeConfigPart<S> withNumberExclusiveMaximumResolver(ConfigFunction<S, BigDecimal> resolver) Setter for "exclusiveMaximum" resolver.- Parameters:
resolver- how to determine the "exclusiveMaximum" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveNumberExclusiveMaximum
Determine the "exclusiveMaximum" of a given scope/type representation.- Parameters:
scope- scope to determine "exclusiveMaximum" value for- Returns:
- "exclusiveMaximum" in a JSON Schema (may be null)
-
withNumberMultipleOfResolver
public SchemaGeneratorTypeConfigPart<S> withNumberMultipleOfResolver(ConfigFunction<S, BigDecimal> resolver) Setter for "multipleOf" resolver.- Parameters:
resolver- how to determine the "multipleOf" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveNumberMultipleOf
Determine the "multipleOf" of a given scope/type representation.- Parameters:
scope- scope to determine "multipleOf" value for- Returns:
- "multipleOf" in a JSON Schema (may be null)
-
withArrayMinItemsResolver
public SchemaGeneratorTypeConfigPart<S> withArrayMinItemsResolver(ConfigFunction<S, Integer> resolver) Setter for "minItems" resolver.- Parameters:
resolver- how to determine the "minItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveArrayMinItems
Determine the "minItems" of a given scope/type representation.- Parameters:
scope- scope to determine "minItems" value for- Returns:
- "minItems" in a JSON Schema (may be null)
-
withArrayMaxItemsResolver
public SchemaGeneratorTypeConfigPart<S> withArrayMaxItemsResolver(ConfigFunction<S, Integer> resolver) Setter for "maxItems" resolver.- Parameters:
resolver- how to determine the "maxItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveArrayMaxItems
Determine the "maxItems" of a given scope/type representation.- Parameters:
scope- scope to determine "maxItems" value for- Returns:
- "maxItems" in a JSON Schema (may be null)
-
withArrayUniqueItemsResolver
public SchemaGeneratorTypeConfigPart<S> withArrayUniqueItemsResolver(ConfigFunction<S, Boolean> resolver) Setter for "uniqueItems" resolver.- Parameters:
resolver- how to determine the "uniqueItems" of a JSON Schema- Returns:
- this config part (for chaining)
-
resolveArrayUniqueItems
Determine the "uniqueItems" of a given scope/type representation.- Parameters:
scope- scope to determine "uniqueItems" value for- Returns:
- "uniqueItems" in a JSON Schema (may be null)
-
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
-