From 214b2620a2506ef3c5f9edd888419e6f6de21abd Mon Sep 17 00:00:00 2001 From: Carsten Wickner Date: Tue, 14 Jan 2025 23:34:26 +0100 Subject: [PATCH] chore: adjust variable names and version number --- .github/workflows/codeql-analysis.yml | 1 - .github/workflows/maven.yml | 4 +- CHANGELOG.md | 1 + jsonschema-examples/pom.xml | 2 +- jsonschema-generator-bom/pom.xml | 3 +- jsonschema-generator-parent/pom.xml | 15 +++-- jsonschema-generator/pom.xml | 2 +- .../jsonschema/generator/TypeContext.java | 16 ++--- .../generator/impl/AttributeCollector.java | 60 +++++++++---------- .../impl/SchemaGenerationContextImpl.java | 8 +-- jsonschema-maven-plugin/pom.xml | 2 +- jsonschema-module-jackson/pom.xml | 2 +- .../module/jackson/JsonPropertySorter.java | 4 +- .../JsonUnwrappedDefinitionProvider.java | 6 +- jsonschema-module-jakarta-validation/pom.xml | 2 +- jsonschema-module-javax-validation/pom.xml | 2 +- jsonschema-module-swagger-1.5/pom.xml | 2 +- jsonschema-module-swagger-2/pom.xml | 2 +- pom.xml | 5 +- 19 files changed, 70 insertions(+), 69 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 5adcd9dd..c8df797f 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -35,6 +35,5 @@ jobs: - name: Autobuild uses: github/codeql-action/autobuild@v2 - - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 7dd94f80..16f21c12 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: - java-version: ['17'] + java-version: ['17', '21'] steps: - uses: actions/checkout@v3 @@ -37,7 +37,7 @@ jobs: strategy: matrix: - java-version: ['17'] + java-version: ['17', '21'] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index d582b556..0d1d8b9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### `jsonschema-generator` #### Changed +- BREAKING: drop support for JDK 11 in favor of JDK 17 - avoid duplicate entries in `required` array when performing final clean-ups ## [4.37.0] - 2024-11-11 diff --git a/jsonschema-examples/pom.xml b/jsonschema-examples/pom.xml index 5c90db5f..f4193875 100644 --- a/jsonschema-examples/pom.xml +++ b/jsonschema-examples/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.38.0-SNAPSHOT + 5.0.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-examples diff --git a/jsonschema-generator-bom/pom.xml b/jsonschema-generator-bom/pom.xml index dc0ce231..c28efdcf 100644 --- a/jsonschema-generator-bom/pom.xml +++ b/jsonschema-generator-bom/pom.xml @@ -8,11 +8,10 @@ com.github.victools jsonschema-generator-bom - 4.38.0-SNAPSHOT + 5.0.0-SNAPSHOT pom - 17 true diff --git a/jsonschema-generator-parent/pom.xml b/jsonschema-generator-parent/pom.xml index 0817a61b..50cabb10 100644 --- a/jsonschema-generator-parent/pom.xml +++ b/jsonschema-generator-parent/pom.xml @@ -4,7 +4,7 @@ com.github.victools jsonschema-generator-bom - 4.38.0-SNAPSHOT + 5.0.0-SNAPSHOT ../jsonschema-generator-bom/pom.xml jsonschema-generator-parent @@ -61,7 +61,7 @@ Provided PRs #116 and #118 (part of initial Swagger2Module) Provided implementation for #204 (readOnly/writeOnly in JacksonModule) Provided PR #299 and feedback on final implementation (inheritance of validation constraint annotations) - Provided implementation for PR #503 (avoid duplicates in required array during final clean-ups) + Provided PR #503 (avoid duplicates in required array during final clean-ups) @@ -137,13 +137,18 @@ Provided PR #487 (support @JacksonAnnotationsInside annotations) + + https://github.com/hbzhou + + Provided PR #477 (drop JDK 11 support in favor of JDK 17) + + UTF-8 UTF-8 - 17 - 17 + 17 3.6.0 10.19.0 @@ -286,7 +291,7 @@ ${maven.plugin.version.compiler} true - 17 + ${maven.compiler.release} diff --git a/jsonschema-generator/pom.xml b/jsonschema-generator/pom.xml index b4b34f8d..7156cbcd 100644 --- a/jsonschema-generator/pom.xml +++ b/jsonschema-generator/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.38.0-SNAPSHOT + 5.0.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-generator diff --git a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/TypeContext.java b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/TypeContext.java index 36ca52a5..ef2a1877 100644 --- a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/TypeContext.java +++ b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/TypeContext.java @@ -73,9 +73,9 @@ public TypeContext(AnnotationConfiguration annotationConfig) { */ public TypeContext(AnnotationConfiguration annotationConfig, SchemaGeneratorConfig generatorConfig) { this(annotationConfig, generatorConfig.shouldDeriveFieldsFromArgumentFreeMethods()); - if (annotationConfig instanceof AnnotationConfiguration.StdConfiguration configuration) { + if (annotationConfig instanceof AnnotationConfiguration.StdConfiguration stdConfiguration) { generatorConfig.getAnnotationInclusionOverrides() - .forEach(configuration::setInclusion); + .forEach(stdConfiguration::setInclusion); } } @@ -327,8 +327,8 @@ public A getTypeParameterAnnotation(Class annotationCl * @since 4.30.0 */ public Stream getTypeParameterAnnotations(AnnotatedType annotatedContainerType, Integer containerItemIndex) { - if (annotatedContainerType instanceof AnnotatedParameterizedType type) { - AnnotatedType[] typeArguments = type.getAnnotatedActualTypeArguments(); + if (annotatedContainerType instanceof AnnotatedParameterizedType parameterizedType) { + AnnotatedType[] typeArguments = parameterizedType.getAnnotatedActualTypeArguments(); int itemIndex = containerItemIndex == null ? 0 : containerItemIndex; if (typeArguments.length > itemIndex) { return Stream.of(typeArguments[itemIndex].getAnnotations()); @@ -478,10 +478,10 @@ public String getMethodPropertyArgumentTypeDescription(ResolvedType type) { public R performActionOnMember(MemberScope member, Function fieldAction, Function methodAction) { R result; - if (member instanceof FieldScope scope) { - result = fieldAction.apply(scope); - } else if (member instanceof MethodScope scope) { - result = methodAction.apply(scope); + if (member instanceof FieldScope field) { + result = fieldAction.apply(field); + } else if (member instanceof MethodScope method) { + result = methodAction.apply(method); } else { throw new IllegalStateException("Unsupported member scope of type: " + member.getClass()); } diff --git a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/AttributeCollector.java b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/AttributeCollector.java index 6f406da1..4e7ff991 100644 --- a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/AttributeCollector.java +++ b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/AttributeCollector.java @@ -379,47 +379,47 @@ public AttributeCollector setEnum(ObjectNode node, Collection enumValues, Sch private void addRawPropertyValue(ObjectNode node, String propertyName, Object value) { // need to specifically add simple/primitive values by type - if (value instanceof String string) { + if (value instanceof String stringValue) { // explicit inclusion as string results in wrapping quote symbols - node.put(propertyName, string); - } else if (value instanceof BigDecimal decimal) { - node.put(propertyName, decimal); - } else if (value instanceof BigInteger integer) { - node.put(propertyName, integer); - } else if (value instanceof Boolean boolean1) { - node.put(propertyName, boolean1); - } else if (value instanceof Double double1) { - node.put(propertyName, double1); - } else if (value instanceof Float float1) { - node.put(propertyName, float1); - } else if (value instanceof Integer integer) { - node.put(propertyName, integer); + node.put(propertyName, stringValue); + } else if (value instanceof BigDecimal decimalValue) { + node.put(propertyName, decimalValue); + } else if (value instanceof BigInteger intValue) { + node.put(propertyName, intValue); + } else if (value instanceof Boolean boolValue) { + node.put(propertyName, boolValue); + } else if (value instanceof Double doubleValue) { + node.put(propertyName, doubleValue); + } else if (value instanceof Float floatValue) { + node.put(propertyName, floatValue); + } else if (value instanceof Integer intValue) { + node.put(propertyName, intValue); } else { // everything else is simply forwarded as-is to the JSON Schema, it's up to the configurator to ensure the value's correctness node.putPOJO(propertyName, value); } } - private void addRawArrayItem(ArrayNode node, Object value) { + private void addRawArrayItem(ArrayNode node, Object item) { // need to specifically add simple/primitive values by type - if (value instanceof String string) { + if (item instanceof String stringItem) { // explicit inclusion as string results in wrapping quote symbols - node.add(string); - } else if (value instanceof BigDecimal decimal) { - node.add(decimal); - } else if (value instanceof BigInteger integer) { - node.add(integer); - } else if (value instanceof Boolean boolean1) { - node.add(boolean1); - } else if (value instanceof Double double1) { - node.add(double1); - } else if (value instanceof Float float1) { - node.add(float1); - } else if (value instanceof Integer integer) { - node.add(integer); + node.add(stringItem); + } else if (item instanceof BigDecimal decimalItem) { + node.add(decimalItem); + } else if (item instanceof BigInteger intItem) { + node.add(intItem); + } else if (item instanceof Boolean boolItem) { + node.add(boolItem); + } else if (item instanceof Double doubleItem) { + node.add(doubleItem); + } else if (item instanceof Float floatItem) { + node.add(floatItem); + } else if (item instanceof Integer intItem) { + node.add(intItem); } else { // everything else is simply forwarded as-is to the JSON Schema, it's up to the configurator to ensure the value's correctness - node.addPOJO(value); + node.addPOJO(item); } } diff --git a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java index 42a6eba1..d7e5c500 100644 --- a/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java +++ b/jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/SchemaGenerationContextImpl.java @@ -435,11 +435,11 @@ private void generateArrayDefinition(GenericTypeDetails typeDetails, ObjectNode } private JsonNode populateItemMemberSchema(TypeScope targetScope) { - if (targetScope instanceof FieldScope scope && !scope.isFakeContainerItemScope()) { - return this.populateFieldSchema(scope.asFakeContainerItemScope()); + if (targetScope instanceof FieldScope field && !field.isFakeContainerItemScope()) { + return this.populateFieldSchema(field.asFakeContainerItemScope()); } - if (targetScope instanceof MethodScope scope && !scope.isFakeContainerItemScope()) { - return this.populateMethodSchema(scope.asFakeContainerItemScope()); + if (targetScope instanceof MethodScope method && !method.isFakeContainerItemScope()) { + return this.populateMethodSchema(method.asFakeContainerItemScope()); } ObjectNode arrayItemDefinition = this.generatorConfig.createObjectNode(); this.traverseGenericType(targetScope.getContainerItemType(), arrayItemDefinition); diff --git a/jsonschema-maven-plugin/pom.xml b/jsonschema-maven-plugin/pom.xml index 7f2517c9..c04951bb 100644 --- a/jsonschema-maven-plugin/pom.xml +++ b/jsonschema-maven-plugin/pom.xml @@ -6,7 +6,7 @@ com.github.victools jsonschema-generator-parent - 4.38.0-SNAPSHOT + 5.0.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 1e02c8df..e6cfafce 100644 --- a/jsonschema-module-jackson/pom.xml +++ b/jsonschema-module-jackson/pom.xml @@ -5,7 +5,7 @@ com.github.victools jsonschema-generator-parent - 4.38.0-SNAPSHOT + 5.0.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-jackson diff --git a/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorter.java b/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorter.java index fe2553d4..8a129b32 100644 --- a/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorter.java +++ b/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonPropertySorter.java @@ -75,8 +75,8 @@ protected int getPropertyIndex(MemberScope property) { List sortedProperties = this.propertyOrderPerDeclaringType .computeIfAbsent(topMostHierarchyType.getErasedType(), this::getAnnotatedPropertyOrder); String fieldName; - if (property instanceof MethodScope scope) { - fieldName = Optional.ofNullable(scope.findGetterField()) + if (property instanceof MethodScope method) { + fieldName = Optional.>ofNullable(method.findGetterField()) // since 4.33.1: fall-back on method's property name if no getter can be found .orElse(property) .getSchemaPropertyName(); diff --git a/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonUnwrappedDefinitionProvider.java b/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonUnwrappedDefinitionProvider.java index 1600e15c..b46c4bb0 100644 --- a/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonUnwrappedDefinitionProvider.java +++ b/jsonschema-module-jackson/src/main/java/com/github/victools/jsonschema/module/jackson/JsonUnwrappedDefinitionProvider.java @@ -109,12 +109,12 @@ private Optional createUnwrappedMemberSchema(ResolvedMember membe */ private void applyPrefixAndSuffixToPropertyNames(JsonNode definition, String prefix, String suffix, SchemaGenerationContext context) { JsonNode properties = definition.get(context.getKeyword(SchemaKeyword.TAG_PROPERTIES)); - if (properties instanceof ObjectNode node && !properties.isEmpty()) { + if (properties instanceof ObjectNode propertiesNode && !propertiesNode.isEmpty()) { List fieldNames = new ArrayList<>(); properties.fieldNames().forEachRemaining(fieldNames::add); for (String fieldName : fieldNames) { - JsonNode propertySchema = node.remove(fieldName); - node.set(prefix + fieldName + suffix, propertySchema); + JsonNode propertySchema = propertiesNode.remove(fieldName); + propertiesNode.set(prefix + fieldName + suffix, propertySchema); } } JsonNode allOf = definition.get(context.getKeyword(SchemaKeyword.TAG_ALLOF)); diff --git a/jsonschema-module-jakarta-validation/pom.xml b/jsonschema-module-jakarta-validation/pom.xml index c041930e..40bf4420 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.38.0-SNAPSHOT + 5.0.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 46959df5..263cf7b6 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.38.0-SNAPSHOT + 5.0.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 6dab80aa..028b2e1c 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.38.0-SNAPSHOT + 5.0.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 1ffca530..75915344 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.38.0-SNAPSHOT + 5.0.0-SNAPSHOT ../jsonschema-generator-parent/pom.xml jsonschema-module-swagger-2 diff --git a/pom.xml b/pom.xml index 46316da3..9e3fdeb7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,15 +3,12 @@ com.github.victools jsonschema-generator-reactor - 4.38.0-SNAPSHOT + 5.0.0-SNAPSHOT pom Java JSON Schema Generator (Reactor) Java JSON Schema Generator + Modules – creating a JSON Schema from your Java classes https://github.com/victools/jsonschema-generator - - 17 -