Enum Option
- java.lang.Object
-
- java.lang.Enum<Option>
-
- com.github.victools.jsonschema.generator.Option
-
- All Implemented Interfaces:
Serializable
,Comparable<Option>
public enum Option extends Enum<Option>
Configuration options to be set on aSchemaGeneratorConfigBuilder
instance.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ADDITIONAL_FIXED_TYPES
Whether additional types (and not just primitives and their associated classes should be included as fixed schema with aSchemaKeyword.TAG_TYPE
attribute of "string"/"boolean"/"integer"/"number".ALLOF_CLEANUP_AT_THE_END
Whether as the last step of the schema generation, unnecessary "allOf" elements (i.e.DEFINITION_FOR_MAIN_SCHEMA
Whether the schema for the target/main type should be included in the "definitions"/"$defs" – thereby avoiding an potential"$ref": "#"
and assigning a name to it like for all other defined subschemas.DEFINITIONS_FOR_ALL_OBJECTS
Whether all referenced objects should be listed in the schema's "definitions"/"$defs".DEFINITIONS_FOR_MEMBER_SUPERTYPES
Whether a member (field/method), having a declared type for which subtypes are being detected, should be included as standalone definition with any collected member attributes assigned directly – and the subtypes only being handled as generic types – or each of its subtypes should be treated as alternative sub-schema for this member (field/method) including any attributes derived from that member.ENUM_KEYWORD_FOR_SINGLE_VALUES
Whether allowed values should always be included in an"enum"
keyword.EXTRA_OPEN_API_FORMAT_VALUES
For the "format" attribute, JSON Schema defines various supported values.FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS
Whether methods that do not expect any arguments, should be treated as fields: i.e.FLATTENED_ENUMS
Whether enums should be treated as plainSchemaKeyword.TAG_TYPE_STRING
values – derived from their respective constant name.FLATTENED_ENUMS_FROM_TOSTRING
Whether enums should be treated as plainSchemaKeyword.TAG_TYPE_STRING
values – derived from their respectivetoString()
.FLATTENED_OPTIONALS
Whether anyOptional
instance should be treated as nullable value of the wrapped type.FLATTENED_SUPPLIERS
Whether aSupplier<T>
instance should be treated as the wrapped typeT
.FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT
Whether a schema's "additionalProperties" should be set to "false" if no specific configuration says otherwise.GETTER_METHODS
Whether getter methods should be included (assuming their fields are not included).INLINE_ALL_SCHEMAS
Whether all sub-schemas should be defined in-line, i.e.MAP_VALUES_AS_ADDITIONAL_PROPERTIES
Whether aMap<K, V>
schema's "additionalProperties" should be set to its declared value typeV
.NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS
Whether fields with private/package/protected visibility, for which a respective getter method can be found, should be included.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS
Whether fields with private/package/protected visibility and no accompanying getter method should be included.NONPUBLIC_STATIC_FIELDS
Whetherstatic
fields with private/package/protected visibility should be included.NONSTATIC_NONVOID_NONGETTER_METHODS
Whether methods that are (1) notstatic
, (2) have a specific return value and (3) are not getters, should be included.NULLABLE_ARRAY_ITEMS_ALLOWED
Whether a container/collection/array item should be subject to the standard nullable checks.NULLABLE_FIELDS_BY_DEFAULT
Whether an object's field/property should be deemed to be nullable if no specific check says otherwise.NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT
Whether a method's return value should be deemed to be nullable if no specific check says otherwise.PLAIN_DEFINITION_KEYS
Generally, keys in the collected "definitions"/"$defs" are ensured to be URI compatible but may include parentheses and commas for listing type parameters.PUBLIC_NONSTATIC_FIELDS
Whetherstatic
fields with public visibility should be included.PUBLIC_STATIC_FIELDS
Whetherstatic
fields with public visibility should be included.SCHEMA_VERSION_INDICATOR
Whether theSchemaKeyword.TAG_SCHEMA
attribute withSchemaKeyword.TAG_SCHEMA_VALUE
should be included.SIMPLIFIED_ENUMS
Whether enums should be treated asSchemaKeyword.TAG_TYPE_OBJECT
, with all methods butname()
being excluded.SIMPLIFIED_OPTIONALS
Whether anyOptional
instance should be reduced to an object with only three methods.STATIC_METHODS
Whether methods that arestatic
should be included.STRICT_TYPE_INFO
Whether at the end of the schema generation, all sub-schemas without an explicit "type" indication should be augmented by the implied "type" based on the other tags in the respective schema.TRANSIENT_FIELDS
Whethertransient
fields should be included.VALUES_FROM_CONSTANT_FIELDS
Whether the constant values of static final fields should be included.VOID_METHODS
Whether methods without return value (e.g.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isOverriding(Option otherOption)
Check whether the given option is being ignored if this one enabled.static Option
valueOf(String name)
Returns the enum constant of this type with the specified name.static Option[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
SCHEMA_VERSION_INDICATOR
public static final Option SCHEMA_VERSION_INDICATOR
Whether theSchemaKeyword.TAG_SCHEMA
attribute withSchemaKeyword.TAG_SCHEMA_VALUE
should be included.
-
ADDITIONAL_FIXED_TYPES
public static final Option ADDITIONAL_FIXED_TYPES
Whether additional types (and not just primitives and their associated classes should be included as fixed schema with aSchemaKeyword.TAG_TYPE
attribute of "string"/"boolean"/"integer"/"number".
-
SIMPLIFIED_ENUMS
public static final Option SIMPLIFIED_ENUMS
Whether enums should be treated asSchemaKeyword.TAG_TYPE_OBJECT
, with all methods butname()
being excluded.
This only takes effect ifFLATTENED_ENUMS
andFLATTENED_ENUMS_FROM_TOSTRING
are disabled.- See Also:
FLATTENED_ENUMS
,FLATTENED_ENUMS_FROM_TOSTRING
-
FLATTENED_ENUMS
public static final Option FLATTENED_ENUMS
Whether enums should be treated as plainSchemaKeyword.TAG_TYPE_STRING
values – derived from their respective constant name.
This only takes effect ifFLATTENED_ENUMS_FROM_TOSTRING
is disabled but takes priority overSIMPLIFIED_ENUMS
.- See Also:
FLATTENED_ENUMS_FROM_TOSTRING
,SIMPLIFIED_ENUMS
-
FLATTENED_ENUMS_FROM_TOSTRING
public static final Option FLATTENED_ENUMS_FROM_TOSTRING
Whether enums should be treated as plainSchemaKeyword.TAG_TYPE_STRING
values – derived from their respectivetoString()
.
This takes priority over bothFLATTENED_ENUMS
andSIMPLIFIED_ENUMS
.- See Also:
FLATTENED_ENUMS
,SIMPLIFIED_ENUMS
-
SIMPLIFIED_OPTIONALS
public static final Option SIMPLIFIED_OPTIONALS
Whether anyOptional
instance should be reduced to an object with only three methods.
This only takes effect ifFLATTENED_OPTIONALS
is disabled.
-
FLATTENED_OPTIONALS
public static final Option FLATTENED_OPTIONALS
Whether anyOptional
instance should be treated as nullable value of the wrapped type.
This takes priority overSIMPLIFIED_OPTIONALS
.- See Also:
SIMPLIFIED_OPTIONALS
-
FLATTENED_SUPPLIERS
public static final Option FLATTENED_SUPPLIERS
Whether aSupplier<T>
instance should be treated as the wrapped typeT
.- Since:
- 4.25.0
-
VALUES_FROM_CONSTANT_FIELDS
public static final Option VALUES_FROM_CONSTANT_FIELDS
Whether the constant values of static final fields should be included.
-
PUBLIC_STATIC_FIELDS
public static final Option PUBLIC_STATIC_FIELDS
Whetherstatic
fields with public visibility should be included.
-
PUBLIC_NONSTATIC_FIELDS
public static final Option PUBLIC_NONSTATIC_FIELDS
Whetherstatic
fields with public visibility should be included.
-
NONPUBLIC_STATIC_FIELDS
public static final Option NONPUBLIC_STATIC_FIELDS
Whetherstatic
fields with private/package/protected visibility should be included.
-
NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS
public static final Option NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS
Whether fields with private/package/protected visibility, for which a respective getter method can be found, should be included.
-
NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS
public static final Option NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS
Whether fields with private/package/protected visibility and no accompanying getter method should be included.
-
TRANSIENT_FIELDS
public static final Option TRANSIENT_FIELDS
Whethertransient
fields should be included.
-
STATIC_METHODS
public static final Option STATIC_METHODS
Whether methods that arestatic
should be included.
-
VOID_METHODS
public static final Option VOID_METHODS
Whether methods without return value (e.g. setters) should be included.
-
GETTER_METHODS
public static final Option GETTER_METHODS
Whether getter methods should be included (assuming their fields are not included).
-
NONSTATIC_NONVOID_NONGETTER_METHODS
public static final Option NONSTATIC_NONVOID_NONGETTER_METHODS
Whether methods that are (1) notstatic
, (2) have a specific return value and (3) are not getters, should be included.- See Also:
STATIC_METHODS
,VOID_METHODS
,GETTER_METHODS
-
NULLABLE_FIELDS_BY_DEFAULT
public static final Option NULLABLE_FIELDS_BY_DEFAULT
Whether an object's field/property should be deemed to be nullable if no specific check says otherwise.
Without this option, all fields are deemed not-nullable unless a specific check says otherwise.
-
NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT
public static final Option NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT
Whether a method's return value should be deemed to be nullable if no specific check says otherwise.
Without this option, all methods' return values are deemed not-nullable unless a specific check says otherwise.
-
NULLABLE_ARRAY_ITEMS_ALLOWED
public static final Option NULLABLE_ARRAY_ITEMS_ALLOWED
Whether a container/collection/array item should be subject to the standard nullable checks.
Without this option, no null values are allowed in any array.
Beware: with this option enabled, all nullable checks may need to consider the field/method'sisFakeContainerItemScope()
indication.- Since:
- 4.20.0
-
FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS
public static final Option FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS
Whether methods that do not expect any arguments, should be treated as fields: i.e. renaming the property.
-
MAP_VALUES_AS_ADDITIONAL_PROPERTIES
public static final Option MAP_VALUES_AS_ADDITIONAL_PROPERTIES
Whether aMap<K, V>
schema's "additionalProperties" should be set to its declared value typeV
.- Since:
- 4.11.0
-
ENUM_KEYWORD_FOR_SINGLE_VALUES
public static final Option ENUM_KEYWORD_FOR_SINGLE_VALUES
Whether allowed values should always be included in an"enum"
keyword. If there is exactly one allowed value, it will otherwise be represented by a"const"
keyword instead.- Since:
- 4.16.0
-
FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT
public static final Option FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT
Whether a schema's "additionalProperties" should be set to "false" if no specific configuration says otherwise.
Without this option, i.e. by default, the "additionalProperties" keyword will be omitted and thereby allowing any additional properties in an object schema.- Since:
- 4.2.0
-
DEFINITIONS_FOR_ALL_OBJECTS
public static final Option DEFINITIONS_FOR_ALL_OBJECTS
Whether all referenced objects should be listed in the schema's "definitions"/"$defs".
Without this option, only those subschemas will be "$ref"-erenced if they occur more than once – in-lining everything else.
-
DEFINITION_FOR_MAIN_SCHEMA
public static final Option DEFINITION_FOR_MAIN_SCHEMA
Whether the schema for the target/main type should be included in the "definitions"/"$defs" – thereby avoiding an potential"$ref": "#"
and assigning a name to it like for all other defined subschemas.
Otherwise, "$ref"-erences to the main/target schema will use the empty fragment ("#") and it will not be listed in the "definitions"/"$defs".Beware: this only results in a valid schema from
SchemaVersion.DRAFT_2019_09
onward. Before that, everything besides "$ref" would be ignored.- Since:
- 4.11.0
-
DEFINITIONS_FOR_MEMBER_SUPERTYPES
public static final Option DEFINITIONS_FOR_MEMBER_SUPERTYPES
Whether a member (field/method), having a declared type for which subtypes are being detected, should be included as standalone definition with any collected member attributes assigned directly – and the subtypes only being handled as generic types – or each of its subtypes should be treated as alternative sub-schema for this member (field/method) including any attributes derived from that member.
Warning: this should only be enabled if there are no relevant annotations (e.g. like jackson@JsonTypeInfo
) on individual properties, that override the general behavior exclusively for single subtypes.- Since:
- 4.27.0
-
INLINE_ALL_SCHEMAS
public static final Option INLINE_ALL_SCHEMAS
Whether all sub-schemas should be defined in-line, i.e. including no "definitions"/"$defs". This takes precedence overDEFINITIONS_FOR_ALL_OBJECTS
andDEFINITION_FOR_MAIN_SCHEMA
.Beware: This will result in an exception being thrown if a single circular reference is being encountered!
- Since:
- 4.10.0
-
PLAIN_DEFINITION_KEYS
public static final Option PLAIN_DEFINITION_KEYS
Generally, keys in the collected "definitions"/"$defs" are ensured to be URI compatible but may include parentheses and commas for listing type parameters. By enabling this option, these parentheses and commas will be removed to conform with a reduced set of characters, e.g. as expected by OpenAPI: following the regular expression^[a-zA-Z0-9\.\-_]+$
.- Since:
- 4.11.0
-
EXTRA_OPEN_API_FORMAT_VALUES
public static final Option EXTRA_OPEN_API_FORMAT_VALUES
For the "format" attribute, JSON Schema defines various supported values. The OpenAPI specification assigns a few more of those in order to differentiate between standard data types (e.g. float vs. double) and even some more fixed data types (e.g. LocalDate, LocalDateTime) ifADDITIONAL_FIXED_TYPES
is enabled. By enabling this option, these extra "format" values will be set for the respective primitive/standard data types automatically.- Since:
- 4.15.0
-
ALLOF_CLEANUP_AT_THE_END
public static final Option ALLOF_CLEANUP_AT_THE_END
Whether as the last step of the schema generation, unnecessary "allOf" elements (i.e. where there are no conflicts/overlaps between the contained sub-schemas) should be merged into one, in order to make the generated schema more readable. This also applies to manually added "allOf" elements, e.g. through custom definitions or attribute overrides.- Since:
- 4.6.0
-
STRICT_TYPE_INFO
public static final Option STRICT_TYPE_INFO
Whether at the end of the schema generation, all sub-schemas without an explicit "type" indication should be augmented by the implied "type" based on the other tags in the respective schema.- Since:
- 4.30.0
-
-
Method Detail
-
values
public static Option[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Option c : Option.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Option valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isOverriding
public boolean isOverriding(Option otherOption)
Check whether the given option is being ignored if this one enabled.- Parameters:
otherOption
- option that may be ignored- Returns:
- whether the given option is being ignored in case of this one being enabled
-
-