Enum Class Option

java.lang.Object
java.lang.Enum<Option>
com.github.victools.jsonschema.generator.Option
All Implemented Interfaces:
Serializable, Comparable<Option>, Constable

public enum Option extends Enum<Option>
Configuration options to be set on a SchemaGeneratorConfigBuilder instance.
  • Enum Constant Details

    • SCHEMA_VERSION_INDICATOR

      public static final Option SCHEMA_VERSION_INDICATOR
      Whether the SchemaKeyword.TAG_SCHEMA attribute with SchemaKeyword.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 a SchemaKeyword.TAG_TYPE attribute of "string"/"boolean"/"integer"/"number".
    • SIMPLIFIED_ENUMS

      public static final Option SIMPLIFIED_ENUMS
      Whether enums should be treated as SchemaKeyword.TAG_TYPE_OBJECT, with all methods but name() being excluded.
      This only takes effect if FLATTENED_ENUMS and FLATTENED_ENUMS_FROM_TOSTRING are disabled.
      See Also:
    • FLATTENED_ENUMS

      public static final Option FLATTENED_ENUMS
      Whether enums should be treated as plain SchemaKeyword.TAG_TYPE_STRING values - derived from their respective constant name.
      This only takes effect if FLATTENED_ENUMS_FROM_TOSTRING is disabled but takes priority over SIMPLIFIED_ENUMS.
      See Also:
    • FLATTENED_ENUMS_FROM_TOSTRING

      public static final Option FLATTENED_ENUMS_FROM_TOSTRING
      Whether enums should be treated as plain SchemaKeyword.TAG_TYPE_STRING values - derived from their respective toString().
      This takes priority over both FLATTENED_ENUMS and SIMPLIFIED_ENUMS.
      See Also:
    • SIMPLIFIED_OPTIONALS

      public static final Option SIMPLIFIED_OPTIONALS
      Whether any Optional instance should be reduced to an object with only three methods.
      This only takes effect if FLATTENED_OPTIONALS is disabled.
      See Also:
    • FLATTENED_OPTIONALS

      public static final Option FLATTENED_OPTIONALS
      Whether any Optional instance should be treated as nullable value of the wrapped type.
      This takes priority over SIMPLIFIED_OPTIONALS.
      See Also:
    • FLATTENED_SUPPLIERS

      public static final Option FLATTENED_SUPPLIERS
      Whether a Supplier<T> instance should be treated as the wrapped type T.
      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
      Whether static fields with public visibility should be included.
      See Also:
    • PUBLIC_NONSTATIC_FIELDS

      public static final Option PUBLIC_NONSTATIC_FIELDS
      Whether static fields with public visibility should be included.
      See Also:
    • NONPUBLIC_STATIC_FIELDS

      public static final Option NONPUBLIC_STATIC_FIELDS
      Whether static fields with private/package/protected visibility should be included.
      See Also:
    • 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.
      See Also:
    • 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.
      See Also:
    • TRANSIENT_FIELDS

      public static final Option TRANSIENT_FIELDS
      Whether transient fields should be included.
      See Also:
    • STATIC_METHODS

      public static final Option STATIC_METHODS
      Whether methods that are static should be included.
      See Also:
    • VOID_METHODS

      public static final Option VOID_METHODS
      Whether methods without return value (e.g. setters) should be included.
      See Also:
    • GETTER_METHODS

      public static final Option GETTER_METHODS
      Whether getter methods should be included (assuming their fields are not included).
      See Also:
    • NONSTATIC_NONVOID_NONGETTER_METHODS

      public static final Option NONSTATIC_NONVOID_NONGETTER_METHODS
      Whether methods that are (1) not static, (2) have a specific return value and (3) are not getters, should be included.
      See Also:
    • 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's isFakeContainerItemScope() 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 a Map<K, V> schema's "additionalProperties" should be set to its declared value type V.
      Since:
      4.11.0
    • ACCEPT_SINGLE_VALUE_AS_ARRAY

      public static final Option ACCEPT_SINGLE_VALUE_AS_ARRAY
      Whether each property with a container/Collection type should also allow for a single collection item to be provided instead of an array. This corresponds to the Jackson ACCEPT_SINGLE_VALUE_AS_ARRAY feature.
      Since:
      4.36.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
    • NULLABLE_ALWAYS_AS_ANYOF

      public static final Option NULLABLE_ALWAYS_AS_ANYOF
      Whether a {"type":"null"} schema should always be grouped as "anyOf" with the not-null schema. Otherwise, it is deemed acceptable to include the "null" option in the main schema's "type" value, e.g. as {"type":["null","string]} resulting in a simpler/smaller schema overall.
      Since:
      4.37.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_NULLABLE_SCHEMAS

      public static final Option INLINE_NULLABLE_SCHEMAS
      Whether the "nullable" variants of a sub-schema should be defined in-line, i.e., avoiding a second "MyType-nullable" entry in the "definitions"/"$defs". This takes precedence over DEFINITIONS_FOR_ALL_OBJECTS in this specific case. The non-nullable sub-schema is unaffected by this setting.
      Since:
      4.33.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 over DEFINITIONS_FOR_ALL_OBJECTS and DEFINITION_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
    • STANDARD_FORMATS

      public static final Option STANDARD_FORMATS
      For the "format" attribute, JSON Schema defines various supported values.
      Some of those data-types would be included if either ADDITIONAL_FIXED_TYPES is enabled or a custom SimpleTypeModule are added. By enabling this option, only the standard built-in "format" values would be added, which is a subset of the values considered with the EXTRA_OPEN_API_FORMAT_VALUES being enabled.
      Since:
      4.33.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) if ADDITIONAL_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
    • DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END

      public static final Option DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END
      Whether at the end of the schema generation, all member sub-schemas referencing a common definition should be checked for any duplicated attributes, which should be removed from the inline member sub-schemas in favor of the equivalent in the single common definition.
      Since:
      4.34.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 Details

    • values

      public static Option[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Option valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - 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