diff --git a/CHANGELOG.md b/CHANGELOG.md index 71240104..85318f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -*-* +## [Unreleased] +### `jsonschema-generator` +#### Added +- new `Option.STANDARD_FORMATS` includes standard `"format"` values to some types considered by `Option.ADDITIONAL_FIXED_TYPES` + +#### Changed +- include new `Option.STANDARD_FORMATS` in `OptionPreset.PLAIN_JSON` by default ## [4.32.0] - 2023-10-27 ### `jsonschema-generator` diff --git a/jsonschema-examples/pom.xml b/jsonschema-examples/pom.xml index 9feb61ad..6ce73068 100644 --- a/jsonschema-examples/pom.xml +++ b/jsonschema-examples/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-examples diff --git a/jsonschema-examples/src/test/resources/com/github/victools/jsonschema/examples/JacksonDescriptionAsTitleExample-result.json b/jsonschema-examples/src/test/resources/com/github/victools/jsonschema/examples/JacksonDescriptionAsTitleExample-result.json index 6f475bcc..f35b768d 100644 --- a/jsonschema-examples/src/test/resources/com/github/victools/jsonschema/examples/JacksonDescriptionAsTitleExample-result.json +++ b/jsonschema-examples/src/test/resources/com/github/victools/jsonschema/examples/JacksonDescriptionAsTitleExample-result.json @@ -8,6 +8,7 @@ }, "id" : { "type" : "string", + "format" : "uuid", "title" : "Method Title" } }, diff --git a/jsonschema-generator-bom/pom.xml b/jsonschema-generator-bom/pom.xml index 5c072b12..a482eca6 100644 --- a/jsonschema-generator-bom/pom.xml +++ b/jsonschema-generator-bom/pom.xml @@ -8,7 +8,7 @@ com.github.victools jsonschema-generator-bom - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT pom diff --git a/jsonschema-generator-parent/pom.xml b/jsonschema-generator-parent/pom.xml index 8b849a86..6bc14df8 100644 --- a/jsonschema-generator-parent/pom.xml +++ b/jsonschema-generator-parent/pom.xml @@ -4,7 +4,7 @@ com.github.victools jsonschema-generator-bom - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-bom/pom.xml jsonschema-generator-parent @@ -113,6 +113,13 @@ Provided PR #388 (allowing configuration of Maven plugin serialization behavior) + + Daniel Gómez-Sánchez + https://github.com/magicDGS + + Provided PR #300 (introducing support for standard "format" values via Option) + + diff --git a/jsonschema-generator/pom.xml b/jsonschema-generator/pom.xml index 1e486635..c2724165 100644 --- a/jsonschema-generator/pom.xml +++ b/jsonschema-generator/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-generator diff --git a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/Option.java b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/Option.java index b6daac2d..cb398027 100644 --- a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/Option.java +++ b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/Option.java @@ -286,18 +286,14 @@ public enum Option { * @since 4.11.0 */ PLAIN_DEFINITION_KEYS(null, null), - /** - * For the "format" attribute, JSON Schema defines various built-in supported values. + * For the "format" attribute, JSON Schema defines various supported values. *
- * Some of those data-types would be handed if either {@link #ADDITIONAL_FIXED_TYPES} - * or a custom {@link SimpleTypeModule} (i.e., {@link SimpleTypeModule#forPrimitiveTypes()}) - * are added. - * In that case, by enabling this option these standard built-in "format" values would be added. - * Note that if {@link #EXTRA_OPEN_API_FORMAT_VALUES} is enabled, it overrides this option as - * it include extra "format" attributes. + * Some of those data-types would be included if either {@link #ADDITIONAL_FIXED_TYPES} is enabled or a custom {@link 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 + * {@link #EXTRA_OPEN_API_FORMAT_VALUES} being enabled. * - * @since 4.32.1 + * @since 4.33.0 */ STANDARD_FORMATS(null, null), /** diff --git a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/OptionPreset.java b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/OptionPreset.java index 61b08ca6..7d8634ca 100644 --- a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/OptionPreset.java +++ b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/OptionPreset.java @@ -55,6 +55,7 @@ public class OptionPreset { public static final OptionPreset PLAIN_JSON = new OptionPreset( Option.SCHEMA_VERSION_INDICATOR, Option.ADDITIONAL_FIXED_TYPES, + Option.STANDARD_FORMATS, Option.FLATTENED_ENUMS, Option.FLATTENED_OPTIONALS, Option.FLATTENED_SUPPLIERS, diff --git a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/module/SimpleTypeModule.java b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/module/SimpleTypeModule.java index 7262b665..4364f132 100644 --- a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/module/SimpleTypeModule.java +++ b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/module/SimpleTypeModule.java @@ -23,15 +23,16 @@ import com.github.victools.jsonschema.generator.MemberScope; import com.github.victools.jsonschema.generator.Module; import com.github.victools.jsonschema.generator.SchemaGenerationContext; +import com.github.victools.jsonschema.generator.SchemaGeneratorConfig; import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder; import com.github.victools.jsonschema.generator.SchemaKeyword; import com.github.victools.jsonschema.generator.TypeScope; import java.lang.reflect.Type; -import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.List; +import java.util.HashSet; import java.util.Map; +import java.util.Set; import java.util.stream.Stream; /** @@ -104,8 +105,8 @@ public static SimpleTypeModule forPrimitiveAndAdditionalTypes() { } private final Map, SchemaKeyword> fixedJsonSchemaTypes = new HashMap<>(); - private final List> standardFormats = new ArrayList<>(); - private final Map, String> extraOpenApiFormatValues = new HashMap<>(); + private final Set> typesWithStandardFormats = new HashSet<>(); + private final Map, String> formatValues = new HashMap<>(); /** * Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute. @@ -118,7 +119,7 @@ public static SimpleTypeModule forPrimitiveAndAdditionalTypes() { private SimpleTypeModule with(Class javaType, SchemaKeyword jsonSchemaTypeValue, String openApiFormat) { this.fixedJsonSchemaTypes.put(javaType, jsonSchemaTypeValue); if (openApiFormat != null) { - this.extraOpenApiFormatValues.put(javaType, openApiFormat); + this.formatValues.put(javaType, openApiFormat); } return this; } @@ -166,10 +167,16 @@ public final SimpleTypeModule withStringType(Class javaType, String openApiFo return this.with(javaType, SchemaKeyword.TAG_TYPE_STRING, openApiFormat); } - private final SimpleTypeModule withStandardStringType(Class javaType, final String format) { - // track as a standard format - this.standardFormats.add(javaType); - return this.withStringType(javaType, format); + /** + * Add the given mapping for a (simple) java class to its JSON schema equivalent "type" attribute: "{@link SchemaKeyword#TAG_TYPE_STRING}". + * + * @param javaType java class to map to a fixed JSON schema definition + * @param standardFormat optional {@link SchemaKeyword#TAG_FORMAT} value, to set if one of the respective Options is enabled + * @return this module instance (for chaining) + */ + public final SimpleTypeModule withStandardStringType(Class javaType, final String standardFormat) { + this.typesWithStandardFormats.add(javaType); + return this.withStringType(javaType, standardFormat); } /** @@ -254,8 +261,7 @@ public void applyToConfigBuilder(SchemaGeneratorConfigBuilder builder) { * @return either {@code Object.class} to cause omission of the "additionalProperties" keyword or null to leave it up to following configurations */ private Type resolveAdditionalProperties(TypeScope scope) { - if (scope.getType().getTypeParameters().isEmpty() - && SchemaKeyword.TAG_TYPE_NULL == this.fixedJsonSchemaTypes.get(scope.getType().getErasedType())) { + if (this.shouldHaveEmptySchema(scope)) { // indicate no specific additionalProperties type - thereby causing it to be omitted from the generated schema return Object.class; } @@ -269,14 +275,17 @@ private Type resolveAdditionalProperties(TypeScope scope) { * @return either an empty map to cause omission of the "patternProperties" keyword or null to leave it up to following configurations */ private Map resolvePatternProperties(TypeScope scope) { - if (scope.getType().getTypeParameters().isEmpty() - && SchemaKeyword.TAG_TYPE_NULL == this.fixedJsonSchemaTypes.get(scope.getType().getErasedType())) { + if (this.shouldHaveEmptySchema(scope)) { // indicate no specific patternProperties - thereby causing it to be omitted from the generated schema return Collections.emptyMap(); } return null; } + private boolean shouldHaveEmptySchema(TypeScope scope) { + return SchemaKeyword.TAG_TYPE_NULL == this.fixedJsonSchemaTypes.get(scope.getType().getErasedType()); + } + /** * Implementation of the {@link CustomDefinitionProviderV2} interface for applying fixed schema definitions for simple java types. */ @@ -296,21 +305,20 @@ public CustomDefinition provideCustomSchemaDefinition(ResolvedType javaType, Sch if (jsonSchemaTypeValue != SchemaKeyword.TAG_TYPE_NULL) { customSchema.put(context.getKeyword(SchemaKeyword.TAG_TYPE), context.getKeyword(jsonSchemaTypeValue)); } - if (shouldAddFormatTag(javaType, context)) { - String formatValue = SimpleTypeModule.this.extraOpenApiFormatValues.get(javaType.getErasedType()); + if (this.shouldAddFormatTag(javaType, context.getGeneratorConfig())) { + String formatValue = SimpleTypeModule.this.formatValues.get(javaType.getErasedType()); if (formatValue != null) { customSchema.put(context.getKeyword(SchemaKeyword.TAG_FORMAT), formatValue); } } - // set true as second parameter to indicate simple types to be always in-lined (i.e. not put into definitions) return new CustomDefinition(customSchema, CustomDefinition.DefinitionType.INLINE, CustomDefinition.AttributeInclusion.YES); } - private boolean shouldAddFormatTag(final ResolvedType javaType, final SchemaGenerationContext context) { + private boolean shouldAddFormatTag(final ResolvedType javaType, final SchemaGeneratorConfig config) { // either OpenAPI extra formats or standard-formats that are registered - return context.getGeneratorConfig().shouldIncludeExtraOpenApiFormatValues() - || (context.getGeneratorConfig().shouldIncludeStandardFormatValues() - && standardFormats.contains(javaType.getErasedType())); + return config.shouldIncludeExtraOpenApiFormatValues() + || (config.shouldIncludeStandardFormatValues() + && SimpleTypeModule.this.typesWithStandardFormats.contains(javaType.getErasedType())); } } } diff --git a/jsonschema-generator/src/test/java/com/github/victools/jsonschema/generator/SchemaGeneratorSimpleTypesTest.java b/jsonschema-generator/src/test/java/com/github/victools/jsonschema/generator/SchemaGeneratorSimpleTypesTest.java index 54893ba7..9fb411f8 100644 --- a/jsonschema-generator/src/test/java/com/github/victools/jsonschema/generator/SchemaGeneratorSimpleTypesTest.java +++ b/jsonschema-generator/src/test/java/com/github/victools/jsonschema/generator/SchemaGeneratorSimpleTypesTest.java @@ -49,10 +49,10 @@ static Stream getSimpleTypeCombinations() { Arguments.of(long.class, SchemaKeyword.TAG_TYPE_INTEGER, "int64", null), Arguments.of(Short.class, SchemaKeyword.TAG_TYPE_INTEGER, null, null), Arguments.of(short.class, SchemaKeyword.TAG_TYPE_INTEGER, null, null), - Arguments.of(Double.class, SchemaKeyword.TAG_TYPE_NUMBER, "double", null, null), - Arguments.of(double.class, SchemaKeyword.TAG_TYPE_NUMBER, "double", null, null), - Arguments.of(Float.class, SchemaKeyword.TAG_TYPE_NUMBER, "float", null, null), - Arguments.of(float.class, SchemaKeyword.TAG_TYPE_NUMBER, "float", null, null), + Arguments.of(Double.class, SchemaKeyword.TAG_TYPE_NUMBER, "double", null), + Arguments.of(double.class, SchemaKeyword.TAG_TYPE_NUMBER, "double", null), + Arguments.of(Float.class, SchemaKeyword.TAG_TYPE_NUMBER, "float", null), + Arguments.of(float.class, SchemaKeyword.TAG_TYPE_NUMBER, "float", null), Arguments.of(java.time.LocalDate.class, SchemaKeyword.TAG_TYPE_STRING, "date", "date"), Arguments.of(java.time.LocalDateTime.class, SchemaKeyword.TAG_TYPE_STRING, "date-time", "date-time"), Arguments.of(java.time.LocalTime.class, SchemaKeyword.TAG_TYPE_STRING, "time", "time"), @@ -155,7 +155,7 @@ public void testGenerateSchema_SimpleType_withAdditionalPropertiesOption(Class targetType, SchemaKeyword expectedJsonSchemaType, String expectedFormat, - SchemaVersion schemaVersion) throws Exception { + SchemaVersion schemaVersion) throws Exception { SchemaGeneratorConfig config = new SchemaGeneratorConfigBuilder(schemaVersion) .with(Option.ADDITIONAL_FIXED_TYPES, Option.STANDARD_FORMATS) .build(); diff --git a/jsonschema-maven-plugin/pom.xml b/jsonschema-maven-plugin/pom.xml index 5e053557..c86f42bd 100644 --- a/jsonschema-maven-plugin/pom.xml +++ b/jsonschema-maven-plugin/pom.xml @@ -6,7 +6,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-maven-plugin diff --git a/jsonschema-module-jackson/pom.xml b/jsonschema-module-jackson/pom.xml index d89020b1..6b3c8506 100644 --- a/jsonschema-module-jackson/pom.xml +++ b/jsonschema-module-jackson/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-jackson diff --git a/jsonschema-module-jakarta-validation/pom.xml b/jsonschema-module-jakarta-validation/pom.xml index d74b4982..732d33af 100644 --- a/jsonschema-module-jakarta-validation/pom.xml +++ b/jsonschema-module-jakarta-validation/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-jakarta-validation diff --git a/jsonschema-module-javax-validation/pom.xml b/jsonschema-module-javax-validation/pom.xml index 877eb9af..3a08688d 100644 --- a/jsonschema-module-javax-validation/pom.xml +++ b/jsonschema-module-javax-validation/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-javax-validation diff --git a/jsonschema-module-swagger-1.5/pom.xml b/jsonschema-module-swagger-1.5/pom.xml index 3886533f..46ef1416 100644 --- a/jsonschema-module-swagger-1.5/pom.xml +++ b/jsonschema-module-swagger-1.5/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-swagger-1.5 diff --git a/jsonschema-module-swagger-2/pom.xml b/jsonschema-module-swagger-2/pom.xml index b0591f09..ca6cfc9f 100644 --- a/jsonschema-module-swagger-2/pom.xml +++ b/jsonschema-module-swagger-2/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-swagger-2 diff --git a/pom.xml b/pom.xml index 2f1342c3..1353271c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.github.victools jsonschema-generator-reactor - 4.32.1-SNAPSHOT + 4.33.0-SNAPSHOT pom Java JSON Schema Generator (Reactor) diff --git a/slate-docs/source/includes/_main-generator-options.md b/slate-docs/source/includes/_main-generator-options.md index fe02215e..37c34890 100644 --- a/slate-docs/source/includes/_main-generator-options.md +++ b/slate-docs/source/includes/_main-generator-options.md @@ -58,23 +58,32 @@ configBuilder.without( 3 - Option.EXTRA_OPEN_API_FORMAT_VALUES + Option.STANDARD_FORMATS - Include extra "format" values (e.g. "int32", "int64", "date", "time", "date-time", "duration", "uuid", "uri") for fixed types (primitive/basic types, plus some of the Option.ADDITIONAL_FIXED_TYPES if they are enabled as well). Only works if Option.ADDITIONAL_FIXED_TYPES is set and it overrides Option.STANDARD_FORMATS. - no automatic "format" values are being included. + Subset of the "format" values being added by Option.EXTRA_OPEN_API_FORMAT_VALUES but limited to built-in supported "format" values ("date", "time", "date-time", "duration", "uuid", "uri"). + Only works if Option.ADDITIONAL_FIXED_TYPES is set. and it is overriden by Option.EXTRA_OPEN_API_FORMAT_VALUES + no automatic "format" values are being included, unless Option.EXTRA_OPEN_API_FORMAT_VALUES indicates otherwise. 4 + Option.EXTRA_OPEN_API_FORMAT_VALUES + + + Include extra "format" values (e.g. "int32", "int64", "date", "time", "date-time", "duration", "uuid", "uri") for fixed types (primitive/basic types, plus some of the Option.ADDITIONAL_FIXED_TYPES if they are enabled as well). It overrides Option.STANDARD_FORMATS, which would cover only a subset of the OpenAPI format values. + no automatic "format" values are being included, unless Option.STANDARD_FORMATS indicates otherwise. + + #Behavior if includedBehavior if excluded + + 5 Option.SIMPLIFIED_ENUMS Treating encountered enum types as objects, but including only the name() method and listing the names of the enum constants as its enum values. - - #Behavior if includedBehavior if excluded - 5 + 6 Option.FLATTENED_ENUMS @@ -82,7 +91,7 @@ configBuilder.without( - - 6 + 7 Option.FLATTENED_ENUMS_FROM_TOSTRING @@ -90,24 +99,24 @@ configBuilder.without( - - 7 + 8 Option.SIMPLIFIED_OPTIONALS Treating encountered Optional instances as objects, but including only the get(), orElse() and isPresent() methods. - + #Behavior if includedBehavior if excluded - 8 + 9 Option.FLATTENED_OPTIONALS Replacing encountered Optional instances as null-able forms of their generic parameter type. - - #Behavior if includedBehavior if excluded - 9 + 10 Option.FLATTENED_SUPPLIERS @@ -115,7 +124,7 @@ configBuilder.without( - - 10 + 11 Option.VALUES_FROM_CONSTANT_FIELDS @@ -126,24 +135,24 @@ configBuilder.without( No const values are populated for static final fields. - 11 + 12 Option.PUBLIC_STATIC_FIELDS Include public static fields in an object's properties. No public static fields are included in an object's properties. + #Behavior if includedBehavior if excluded - 12 + 13 Option.PUBLIC_NONSTATIC_FIELDS Include public non-static fields in an object's properties. No public non-static fields are included in an object's properties. - #Behavior if includedBehavior if excluded - 13 + 14 Option.NONPUBLIC_STATIC_FIELDS @@ -151,7 +160,7 @@ configBuilder.without( No protected/package-visible/private static fields are included in an object's properties. - 14 + 15 Option.NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS @@ -159,24 +168,24 @@ configBuilder.without( No protected/package-visible/private non-static fields with getter methods are included in an object's properties. - 15 + 16 Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS Include protected/package-visible/private non-static fields in an object's properties if they don't have corresponding getter methods. No protected/package-visible/private non-static fields without getter methods are included in an object's properties. + #Behavior if includedBehavior if excluded - 16 + 17 Option.TRANSIENT_FIELDS Include transient fields in an object's properties if they would otherwise be included according to the Options above. No transient fields are included in an object's properties even if they would otherwise be included according to the Options above. - #Behavior if includedBehavior if excluded - 17 + 18 Option.STATIC_METHODS @@ -184,7 +193,7 @@ configBuilder.without( No static methods are included in an object's properties even if they would be included according to the Option.VOID_METHODS below. - 18 + 19 Option.VOID_METHODS @@ -192,24 +201,24 @@ configBuilder.without( No void methods are included in an object's properties even if they would be included according to the Option.STATIC_METHODS above. - 19 + 20 Option.GETTER_METHODS Include public methods in an object's properties if a corresponding field exists that fulfills the usual naming conventions (getX()/x or isValid()/valid). No methods are included in an object's properties> for which a field exists that fulfills the usual naming conventions. + #Behavior if includedBehavior if excluded - 20 + 21 Option.NONSTATIC_NONVOID_NONGETTER_METHODS Include public non-static non-void methods in an object's properties for which no field exists that fulfills the usual getter naming conventions. No non-static/non-void/non-getter methods are included in an object's properties. - #Behavior if includedBehavior if excluded - 21 + 22 Option.NULLABLE_FIELDS_BY_DEFAULT @@ -217,7 +226,7 @@ configBuilder.without( The schema type for a field does not allow for null by default unless some configuration specifically says it is null-able. - 22 + 23 Option.NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT @@ -225,24 +234,24 @@ configBuilder.without( The schema type for a method's return type does not allow for null by default unless some configuration specifically says it is null-able. - 23 + 24 Option.NULLABLE_ARRAY_ITEMS_ALLOWED The schema type for the items in an array (in case of a field's value or method's return value being a container/array) allows null, if the corresponding configuration explicitly says so. Otherwise, they're still deemed not null-able by default. The schema type for the items in an array (in case of a field's value or method's return value being a container/array) never allows null. + #Behavior if includedBehavior if excluded - 24 + 25 Option.FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS Include argument-free methods as fields, e.g. the return type of getName() will be included as name field. Argument-free methods will be included with the appended parentheses. - #Behavior if includedBehavior if excluded - 25 + 26 Option.MAP_VALUES_AS_ADDITIONAL_PROPERTIES @@ -250,7 +259,7 @@ configBuilder.without( Omitting the additionalProperties attribute in Map<K, V> schemas by default (thereby allowing additional properties of any type) unless some configuration specifically says something else. - 26 + 27 Option.ENUM_KEYWORD_FOR_SINGLE_VALUES @@ -258,24 +267,24 @@ configBuilder.without( In case of a single allowed value, use the const keyword instead of enum. - 27 + 28 Option.FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT Setting the additionalProperties attribute in all object schemas to false by default unless some configuration specifically says something else. Omitting the additionalProperties attribute in all object schemas by default (thereby allowing any additional properties) unless some configuration specifically says something else. + #Behavior if includedBehavior if excluded - 28 + 29 Option.DEFINITIONS_FOR_ALL_OBJECTS Include an entry in the $defs/definitions for each encountered object type that is not explicitly declared as "inline" via a custom definition. Only include those entries in the $defs/definitions for object types that are referenced more than once and which are not explicitly declared as "inline" via a custom definition. - #Behavior if includedBehavior if excluded - 29 + 30 Option.DEFINITION_FOR_MAIN_SCHEMA @@ -283,7 +292,7 @@ configBuilder.without( Define the main/target type "inline". - 30 + 31 Option.DEFINITIONS_FOR_MEMBER_SUPERTYPES @@ -291,24 +300,24 @@ configBuilder.without( For a member (field/method), having a declared type for which subtypes are being detected, include a list of definittions: one for each subtype in the given member's context. This allows independently interpreting contextual information (e.g., member annotations) for each subtype. - 31 + 32 Option.INLINE_ALL_SCHEMAS Do not include any $defs/definitions but rather define all sub-schemas "inline" – however, this results in an exception being thrown if the given type contains any kind of circular reference. Depending on whether DEFINITIONS_FOR_ALL_OBJECTS is included or excluded. + #Behavior if includedBehavior if excluded - 32 + 33 Option.PLAIN_DEFINITION_KEYS Ensure that the keys for any $defs/definitions match the regular expression ^[a-zA-Z0-9\.\-_]+$ (as expected by the OpenAPI specification 3.0). Ensure that the keys for any $defs/definitions are URI compatible (as expected by the JSON Schema specification). - #Behavior if includedBehavior if excluded - 33 + 34 Option.ALLOF_CLEANUP_AT_THE_END @@ -316,22 +325,13 @@ configBuilder.without( Do not attempt to reduce allOf wrappers but preserve them as they were generated regardless of them being necessary or not. - 34 + 35 Option.STRICT_TYPE_INFO As final step in the schema generation process, ensure all sub schemas containing keywords implying a particular "type" (e.g., "properties" implying an "object") have this "type" declared explicitly – this also affects the results from custom definitions. No additional "type" indication will be added for each sub schema, e.g. on the collected attributes where the "allOf" clean-up could not be applied or was disabled. - - 35 - Option.STANDARD_FORMATS - - - Same as Option.EXTRA_OPEN_API_FORMAT_VALUES but only for built-in supported "format" values ("date", "time", "date-time", "duration", "uuid", "uri"). - Only works if Option.ADDITIONAL_FIXED_TYPES is set and it is overriden by Option.EXTRA_OPEN_API_FORMAT_VALUES - no automatic "format" values are being included. - @@ -341,40 +341,40 @@ Below, you can find the lists of Options included/excluded in the r * "J_O" = JAVA_OBJECT * "P_J" = PLAIN_JSON -| # | Standard `Option` | F_D | J_O | P_J | -| -- | -------------------------------------------- | --- | --- | --- | -| 1 | `SCHEMA_VERSION_INDICATOR` | ⬜️ | ⬜️ | ✅ | -| 2 | `ADDITIONAL_FIXED_TYPES` | ⬜️ | ⬜️ | ✅ | -| 3 | `EXTRA_OPEN_API_FORMAT_VALUES` | ⬜️ | ⬜️ | ⬜️ | -| 4 | `SIMPLIFIED_ENUMS` | ✅ | ✅ | ⬜️ | -| 5 | `FLATTENED_ENUMS` | ⬜️ | ⬜️ | ✅ | -| 6 | `FLATTENED_ENUMS_FROM_TOSTRING` | ⬜️ | ⬜️ | ⬜️ | -| 7 | `SIMPLIFIED_OPTIONALS` | ✅ | ✅ | ⬜️ | -| 8 | `FLATTENED_OPTIONALS` | ⬜️ | ⬜️ | ✅ | -| 8 | `FLATTENED_SUPPLIERS` | ⬜️ | ⬜️ | ✅ | -| 10 | `VALUES_FROM_CONSTANT_FIELDS` | ✅ | ✅ | ✅ | -| 11 | `PUBLIC_STATIC_FIELDS` | ✅ | ✅ | ⬜️ | -| 12 | `PUBLIC_NONSTATIC_FIELDS` | ✅ | ✅ | ✅ | -| 13 | `NONPUBLIC_STATIC_FIELDS` | ✅ | ⬜️ | ⬜️ | -| 14 | `NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS` | ✅ | ⬜️ | ✅ | -| 15 | `NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS` | ✅ | ⬜️ | ✅ | -| 16 | `TRANSIENT_FIELDS` | ✅ | ⬜️ | ⬜️ | -| 17 | `STATIC_METHODS` | ✅ | ✅ | ⬜️ | -| 18 | `VOID_METHODS` | ✅ | ✅ | ⬜️ | -| 19 | `GETTER_METHODS` | ✅ | ✅ | ⬜️ | -| 20 | `NONSTATIC_NONVOID_NONGETTER_METHODS` | ✅ | ✅ | ⬜️ | -| 21 | `NULLABLE_FIELDS_BY_DEFAULT` | ✅ | ⬜️ | ⬜️ | -| 22 | `NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT` | ✅ | ⬜️ | ⬜️ | -| 23 | `NULLABLE_ARRAY_ITEMS_ALLOWED` | ⬜️ | ⬜️ | ⬜️ | -| 24 | `FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS` | ⬜️ | ⬜️ | ⬜️ | -| 25 | `MAP_VALUES_AS_ADDITIONAL_PROPERTIES` | ⬜️ | ⬜️ | ⬜️ | -| 26 | `ENUM_KEYWORD_FOR_SINGLE_VALUES` | ⬜️ | ⬜️ | ⬜️ | -| 27 | `FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT` | ⬜️ | ⬜️ | ⬜️ | -| 28 | `DEFINITIONS_FOR_ALL_OBJECTS` | ⬜️ | ⬜️ | ⬜️ | -| 29 | `DEFINITION_FOR_MAIN_SCHEMA` | ⬜️ | ⬜️ | ⬜️ | -| 30 | `DEFINITIONS_FOR_MEMBER_SUPERTYPES` | ⬜️ | ⬜️ | ⬜️ | -| 31 | `INLINE_ALL_SCHEMAS` | ⬜️ | ⬜️ | ⬜️ | -| 32 | `PLAIN_DEFINITION_KEYS` | ⬜️ | ⬜️ | ⬜️ | -| 33 | `ALLOF_CLEANUP_AT_THE_END` | ✅ | ✅ | ✅ | -| 34 | `STRICT_TYPE_INFO` | ⬜️ | ⬜️ | ⬜️ | -| 35 | `STANDARD_FORMATS` | ⬜️ | ⬜️ | ⬜️ | +| # | Standard `Option` | F_D | J_O | P_J | +|----| -------------------------------------------- | -- | --- | --- | +| 1 | `SCHEMA_VERSION_INDICATOR` | ⬜️ | ⬜️ | ✅ | +| 2 | `ADDITIONAL_FIXED_TYPES` | ⬜️ | ⬜️ | ✅ | +| 3 | `STANDARD_FORMATS` | ⬜ | ⬜️ | ✅ | +| 4 | `EXTRA_OPEN_API_FORMAT_VALUES` | ⬜️ | ⬜️ | ⬜️ | +| 5 | `SIMPLIFIED_ENUMS` | ✅ | ✅ | ⬜️ | +| 6 | `FLATTENED_ENUMS` | ⬜️ | ⬜️ | ✅ | +| 7 | `FLATTENED_ENUMS_FROM_TOSTRING` | ⬜️ | ⬜️ | ⬜️ | +| 8 | `SIMPLIFIED_OPTIONALS` | ✅ | ✅ | ⬜️ | +| 9 | `FLATTENED_OPTIONALS` | ⬜️ | ⬜️ | ✅ | +| 10 | `FLATTENED_SUPPLIERS` | ⬜️ | ⬜️ | ✅ | +| 11 | `VALUES_FROM_CONSTANT_FIELDS` | ✅ | ✅ | ✅ | +| 12 | `PUBLIC_STATIC_FIELDS` | ✅ | ✅ | ⬜️ | +| 13 | `PUBLIC_NONSTATIC_FIELDS` | ✅ | ✅ | ✅ | +| 14 | `NONPUBLIC_STATIC_FIELDS` | ✅ | ⬜️ | ⬜️ | +| 15 | `NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS` | ✅ | ⬜️ | ✅ | +| 16 | `NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS` | ✅ | ⬜️ | ✅ | +| 17 | `TRANSIENT_FIELDS` | ✅ | ⬜️ | ⬜️ | +| 18 | `STATIC_METHODS` | ✅ | ✅ | ⬜️ | +| 19 | `VOID_METHODS` | ✅ | ✅ | ⬜️ | +| 20 | `GETTER_METHODS` | ✅ | ✅ | ⬜️ | +| 21 | `NONSTATIC_NONVOID_NONGETTER_METHODS` | ✅ | ✅ | ⬜️ | +| 22 | `NULLABLE_FIELDS_BY_DEFAULT` | ✅ | ⬜️ | ⬜️ | +| 23 | `NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT` | ✅ | ⬜️ | ⬜️ | +| 24 | `NULLABLE_ARRAY_ITEMS_ALLOWED` | ⬜️ | ⬜️ | ⬜️ | +| 25 | `FIELDS_DERIVED_FROM_ARGUMENTFREE_METHODS` | ⬜️ | ⬜️ | ⬜️ | +| 26 | `MAP_VALUES_AS_ADDITIONAL_PROPERTIES` | ⬜️ | ⬜️ | ⬜️ | +| 27 | `ENUM_KEYWORD_FOR_SINGLE_VALUES` | ⬜️ | ⬜️ | ⬜️ | +| 28 | `FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT` | ⬜️ | ⬜️ | ⬜️ | +| 29 | `DEFINITIONS_FOR_ALL_OBJECTS` | ⬜️ | ⬜️ | ⬜️ | +| 30 | `DEFINITION_FOR_MAIN_SCHEMA` | ⬜️ | ⬜️ | ⬜️ | +| 31 | `DEFINITIONS_FOR_MEMBER_SUPERTYPES` | ⬜️ | ⬜️ | ⬜️ | +| 32 | `INLINE_ALL_SCHEMAS` | ⬜️ | ⬜️ | ⬜️ | +| 33 | `PLAIN_DEFINITION_KEYS` | ⬜️ | ⬜️ | ⬜️ | +| 34 | `ALLOF_CLEANUP_AT_THE_END` | ✅ | ✅ | ✅ | +| 35 | `STRICT_TYPE_INFO` | ⬜️ | ⬜️ | ⬜️ | \ No newline at end of file