Class SchemaGeneratorTypeConfigPart<S extends TypeScope>

    • Constructor Detail

      • SchemaGeneratorTypeConfigPart

        public SchemaGeneratorTypeConfigPart()
    • Method Detail

      • 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 from
        scope - 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 from
        scope - 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

        public SchemaGeneratorTypeConfigPart<S> withTitleResolver​(ConfigFunction<S,​String> resolver)
        Setter for "title" resolver.
        Parameters:
        resolver - how to determine the "title" of a JSON Schema
        Returns:
        this config part (for chaining)
      • resolveTitle

        public String resolveTitle​(S scope)
        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

        public SchemaGeneratorTypeConfigPart<S> withDescriptionResolver​(ConfigFunction<S,​String> resolver)
        Setter for "description" resolver.
        Parameters:
        resolver - how to determine the "description" of a JSON Schema
        Returns:
        this config part (for chaining)
      • resolveDescription

        public String resolveDescription​(S scope)
        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

        public SchemaGeneratorTypeConfigPart<S> withDefaultResolver​(ConfigFunction<S,​Object> resolver)
        Setter for "default" resolver.
        Parameters:
        resolver - how to determine the "default" of a JSON Schema
        Returns:
        this config part (for chaining)
      • resolveDefault

        public Object resolveDefault​(S scope)
        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

        public SchemaGeneratorTypeConfigPart<S> withEnumResolver​(ConfigFunction<S,​Collection<?>> resolver)
        Setter for "enum"/"const" resolver.
        Parameters:
        resolver - how to determine the "enum"/"const" of a JSON Schema
        Returns:
        this config part (for chaining)
      • resolveEnum

        public Collection<?> resolveEnum​(S scope)
        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 is Void "false" will be set, otherwise an appropriate sub-schema.
        Parameters:
        resolver - how to determine the "additionalProperties" of a JSON Schema, returning Void will result in "false"
        Returns:
        this config part (for chaining)
      • withAdditionalPropertiesResolver

        public SchemaGeneratorTypeConfigPart<S> withAdditionalPropertiesResolver​(BiFunction<S,​SchemaGenerationContext,​com.fasterxml.jackson.databind.JsonNode> resolver)
        Setter for "additionalProperties" resolver. If the returned type is Void "false" will be set, otherwise an appropriate sub-schema.
        Parameters:
        resolver - how to determine the "additionalProperties" of a JSON Schema, returning Void will result in "false"
        Returns:
        this config part (for chaining)
      • resolveAdditionalProperties

        public com.fasterxml.jackson.databind.JsonNode resolveAdditionalProperties​(S scope,
                                                                                   SchemaGenerationContext context)
        Determine the "additionalProperties" of a given scope/type representation.
        Parameters:
        scope - scope to determine "additionalProperties" value for
        context - 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,​com.fasterxml.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,​com.fasterxml.jackson.databind.JsonNode> resolvePatternProperties​(S scope,
                                                                                                  SchemaGenerationContext context)
        Determine the "patternProperties" of a given scope/type representation.
        Parameters:
        scope - scope to determine "patternProperties" value for
        context - 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

        public Integer resolveStringMinLength​(S scope)
        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

        public Integer resolveStringMaxLength​(S scope)
        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

        public SchemaGeneratorTypeConfigPart<S> withStringFormatResolver​(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)
      • resolveStringFormat

        public String resolveStringFormat​(S scope)
        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

        public String resolveStringPattern​(S scope)
        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

        public BigDecimal resolveNumberInclusiveMinimum​(S scope)
        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

        public BigDecimal resolveNumberExclusiveMinimum​(S scope)
        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

        public BigDecimal resolveNumberInclusiveMaximum​(S scope)
        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

        public BigDecimal resolveNumberExclusiveMaximum​(S scope)
        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

        public BigDecimal resolveNumberMultipleOf​(S scope)
        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

        public Integer resolveArrayMinItems​(S scope)
        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

        public Integer resolveArrayMaxItems​(S scope)
        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

        public Boolean resolveArrayUniqueItems​(S scope)
        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: StatefulConfig
        Method being invoked after the generation of a single "main" type's schema has been completed. This enables the same SchemaGenerator instance to be re-used for multiple subsequent executions, even if some aspect of the configuration remembers the original "main" type.
        Specified by:
        resetAfterSchemaGenerationFinished in interface StatefulConfig