diff --git a/CHANGELOG.md b/CHANGELOG.md index d7fd1732..90376078 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,12 @@ 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.DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END` discard duplicate elements from member sub-schemas + +#### Changed +- new `Option.DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END` by default included in standard `OptionPreset`s ## [4.33.1] - 2023-12-19 ### `jsonschema-module-jackson` 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 d154891e..6ccbf912 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 @@ -322,6 +322,13 @@ public enum Option { * @since 4.6.0 */ ALLOF_CLEANUP_AT_THE_END(null, null), + /** + * 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 + */ + DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END(null, null), /** * 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. 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 7d8634ca..ad60275c 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 @@ -46,7 +46,8 @@ public class OptionPreset { Option.DEFINITIONS_FOR_ALL_OBJECTS, Option.NULLABLE_FIELDS_BY_DEFAULT, Option.NULLABLE_METHOD_RETURN_VALUES_BY_DEFAULT, - Option.ALLOF_CLEANUP_AT_THE_END + Option.ALLOF_CLEANUP_AT_THE_END, + Option.DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END ); /** @@ -63,7 +64,8 @@ public class OptionPreset { Option.PUBLIC_NONSTATIC_FIELDS, Option.NONPUBLIC_NONSTATIC_FIELDS_WITH_GETTERS, Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS, - Option.ALLOF_CLEANUP_AT_THE_END + Option.ALLOF_CLEANUP_AT_THE_END, + Option.DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END ); /** @@ -79,7 +81,8 @@ public class OptionPreset { Option.NONSTATIC_NONVOID_NONGETTER_METHODS, Option.SIMPLIFIED_ENUMS, Option.SIMPLIFIED_OPTIONALS, - Option.ALLOF_CLEANUP_AT_THE_END + Option.ALLOF_CLEANUP_AT_THE_END, + Option.DUPLICATE_MEMBER_ATTRIBUTE_CLEANUP_AT_THE_END ); private final Set