Class SchemaGeneratorConfigBuilder
- java.lang.Object
-
- com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder
-
public class SchemaGeneratorConfigBuilder extends Object
Builder class for creating a configuration object to be passed into the SchemaGenerator's constructor.
-
-
Constructor Summary
Constructors Constructor Description SchemaGeneratorConfigBuilder(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Constructor of an empty configuration builder.SchemaGeneratorConfigBuilder(com.fasterxml.jackson.databind.ObjectMapper objectMapper, OptionPreset preset)
Constructor of an empty configuration builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SchemaGeneratorConfig
build()
Create a schema generator instance from the builder.SchemaGeneratorConfigPart<FieldScope>
forFields()
Get the part of this configuration builder dedicated to custom attribute look-ups for fields.SchemaGeneratorConfigPart<MethodScope>
forMethods()
Get the part of this configuration builder dedicated to custom attribute look-ups for methods.SchemaGeneratorTypeConfigPart<TypeScope>
forTypesInGeneral()
Get the part of this configuration builder dedicated to custom attribute look-ups for types in general, independent of the declaration context.com.fasterxml.jackson.databind.ObjectMapper
getObjectMapper()
Retrieve the associated object mapper instance.Boolean
getSetting(Option setting)
Check whether the given setting/option has been set and if yes, whether it is enabled or disabled.SchemaGeneratorConfigBuilder
with(CustomDefinitionProviderV2 definitionProvider)
Adding a custom schema provider – if it returns null for a given type, the next definition provider will be applied.SchemaGeneratorConfigBuilder
with(Module module)
Applying a module to this configuration builder instance.SchemaGeneratorConfigBuilder
with(Option setting, Option... moreSettings)
Enable an option for the schema generation.SchemaGeneratorConfigBuilder
with(TypeAttributeOverride override)
Adding an override for type attributes – all of the registered overrides will be applied in the order of having been added.SchemaGeneratorConfigBuilder
without(Option setting, Option... moreSettings)
Disable an option for the schema generation.
-
-
-
Constructor Detail
-
SchemaGeneratorConfigBuilder
public SchemaGeneratorConfigBuilder(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Constructor of an empty configuration builder. This is equivalent to calling:
new SchemaGeneratorConfigBuilder(objectMapper, OptionPreset.FULL_DOCUMENTATION)
- Parameters:
objectMapper
- supplier for object and array nodes for the JSON structure being generated- See Also:
SchemaGeneratorConfigBuilder(ObjectMapper, OptionPreset)
-
SchemaGeneratorConfigBuilder
public SchemaGeneratorConfigBuilder(com.fasterxml.jackson.databind.ObjectMapper objectMapper, OptionPreset preset)
Constructor of an empty configuration builder.- Parameters:
objectMapper
- supplier for object and array nodes for the JSON structure being generatedpreset
- default settings for standardOption
values
-
-
Method Detail
-
build
public SchemaGeneratorConfig build()
Create a schema generator instance from the builder.- Returns:
- successfully created/initialised generator instance
-
forTypesInGeneral
public SchemaGeneratorTypeConfigPart<TypeScope> forTypesInGeneral()
Get the part of this configuration builder dedicated to custom attribute look-ups for types in general, independent of the declaration context.- Returns:
- configuration part responsible for handling types regardless of their declaration context
-
forFields
public SchemaGeneratorConfigPart<FieldScope> forFields()
Get the part of this configuration builder dedicated to custom attribute look-ups for fields.- Returns:
- configuration part responsible for handling of fields
- See Also:
: holding configurations also applying to methods or types that are not declared as member directly
,: holding configuration applying to methods
-
forMethods
public SchemaGeneratorConfigPart<MethodScope> forMethods()
Get the part of this configuration builder dedicated to custom attribute look-ups for methods.- Returns:
- configuration part responsible for handling of methods
- See Also:
: holding configurations also applying to fields or types that are not declared as member directly
,: holding configuration applying to fields
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
Retrieve the associated object mapper instance.- Returns:
- supplier for object and array nodes for the JSON structure being generated
-
getSetting
public Boolean getSetting(Option setting)
Check whether the given setting/option has been set and if yes, whether it is enabled or disabled.- Parameters:
setting
- generator option to check for- Returns:
- currently configured flag (i.e. true/false if already set), or null if not configured
-
with
public SchemaGeneratorConfigBuilder with(Module module)
Applying a module to this configuration builder instance.- Parameters:
module
- configuration module to add/apply- Returns:
- this builder instance (for chaining)
-
with
public SchemaGeneratorConfigBuilder with(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)
-
with
public SchemaGeneratorConfigBuilder with(TypeAttributeOverride override)
Adding an override for type attributes – all of 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)
-
with
public SchemaGeneratorConfigBuilder with(Option setting, Option... moreSettings)
Enable an option for the schema generation.- Parameters:
setting
- generator option to enablemoreSettings
- additional generator options to enable- Returns:
- this builder instance (for chaining)
-
without
public SchemaGeneratorConfigBuilder without(Option setting, Option... moreSettings)
Disable an option for the schema generation.- Parameters:
setting
- generator option to disablemoreSettings
- additional generator options to disable- Returns:
- this builder instance (for chaining)
-
-