diff --git a/docs/generators/java.md b/docs/generators/java.md index 34b9d793e6a..00930d5722d 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -287,7 +287,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |ExclusiveMinimum|✓|OAS2,OAS3 |ExclusiveMaximum|✓|OAS2,OAS3 |Format|✓|OAS2,OAS3 -|If|✗|OAS3 +|If|✓|OAS3 |Items|✓|OAS2,OAS3 |MaxContains|✓|OAS3 |MaxItems|✓|OAS2,OAS3 diff --git a/samples/client/3_0_3_unit_test/java/.openapi-generator/FILES b/samples/client/3_0_3_unit_test/java/.openapi-generator/FILES index 83ee5fdf66f..71a63653d18 100644 --- a/samples/client/3_0_3_unit_test/java/.openapi-generator/FILES +++ b/samples/client/3_0_3_unit_test/java/.openapi-generator/FILES @@ -225,6 +225,7 @@ src/main/java/org/openapijsonschematools/client/schemas/validation/FloatValueMet src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenList.java src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenMap.java +src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/IntegerEnumValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/IntegerValueMethod.java src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java index 81adeddb054..fd6fa6a4d29 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java @@ -20,7 +20,8 @@ public AdditionalPropertiesValidator(Class additionalPrope @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java index 0c662704072..313e2d97446 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java @@ -16,7 +16,8 @@ public AllOfValidator(List> allOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); for(Class allOfClass: allOf) { diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java index f170798d97c..a4754dda464 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java @@ -19,7 +19,8 @@ public AnyOfValidator(List> anyOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedAnyOfClasses = new ArrayList<>(); diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java index f77d5360885..f797c68ab2e 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java @@ -20,7 +20,8 @@ public ConstValidator(@Nullable Object constValue) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { BigDecimal castArg = getBigDecimal((Number) arg); diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java index a4459d8a9db..deaa878d5af 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java @@ -19,7 +19,8 @@ public ContainsValidator(Class contains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java index 554a49120d0..a5e92887928 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java @@ -21,7 +21,8 @@ public DependentRequiredValidator(Map> dependentRequired) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java index 6ad17c0d139..0ffa3b351ca 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java @@ -21,7 +21,8 @@ public DependentSchemasValidator(Map> depend @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java index ad242f735b2..6cc9459e1a8 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java @@ -25,7 +25,8 @@ private boolean enumContainsArg(@Nullable Object arg){ @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (enumValues.isEmpty()) { throw new ValidationException("No value can match enum because enum is empty"); diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java index 64d86b2722a..432d5b0f4de 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java @@ -18,7 +18,8 @@ public ExclusiveMaximumValidator(Number exclusiveMaximum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java index a596a7e80ce..d60c96f8325 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java @@ -18,7 +18,8 @@ public ExclusiveMinimumValidator(Number exclusiveMinimum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java index be5e2d928b5..d782f2ce4a2 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java @@ -149,7 +149,8 @@ private Void validateStringFormat(String arg, ValidationMetadata validationMetad @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { validateNumericFormat( diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java new file mode 100644 index 00000000000..e1634bd1b00 --- /dev/null +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java @@ -0,0 +1,56 @@ +package org.openapijsonschematools.client.schemas.validation; + +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class IfValidator implements KeywordValidator { + public final Class ifSchema; + + public IfValidator(Class ifSchema) { + this.ifSchema = ifSchema; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List containsPathToSchemas, + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas + ) { + if (ifPathToSchemas == null) { + throw new ValidationException("Invalid type for ifPathToSchemas"); + } + /* + if is false use case + ifPathToSchemas == {} + no need to add any data to pathToSchemas + + if true, then true -> true for whole schema + so validate_then will add ifPathToSchemas data to pathToSchemas + */ + return null; + } + + public PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + JsonSchema ifSchemaInstance = JsonSchemaFactory.getInstance(ifSchema); + PathToSchemasMap pathToSchemas = new PathToSchemasMap(); + try { + var otherPathToSchemas = JsonSchema.validate(ifSchemaInstance, arg, validationMetadata); + pathToSchemas.update(otherPathToSchemas); + } catch (ValidationException | InvalidTypeException ignored) {} + return pathToSchemas; + } +} diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java index cf66ce04470..5d146ab250c 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java @@ -18,7 +18,8 @@ public ItemsValidator(Class items) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java index 33fc4a78e91..551c586665c 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java @@ -54,6 +54,7 @@ public abstract class JsonSchema { public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; public @Nullable List> prefixItems; + public final @Nullable Class ifSchema; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -292,6 +293,13 @@ protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { new PrefixItemsValidator(this.prefixItems) ); } + this.ifSchema = jsonSchemaInfo.ifSchema; + if (this.ifSchema != null) { + keywordToValidator.put( + "if", + new IfValidator(this.ifSchema) + ); + } this.keywordToValidator = keywordToValidator; } @@ -316,6 +324,11 @@ public static PathToSchemasMap validate( if (patternPropertiesValidator != null) { patternPropertiesPathToSchemas = patternPropertiesValidator.getPatternPropertiesPathToSchemas(arg, validationMetadata); } + @Nullable PathToSchemasMap ifPathToSchemas = null; + KeywordValidator ifValidator = thisKeywordToValidator.get("if"); + if (ifValidator != null) { + ifPathToSchemas = ifValidator.getIfPathToSchemas(arg, validationMetadata); + } for (Map.Entry entry: thisKeywordToValidator.entrySet()) { String jsonKeyword = entry.getKey(); if (disabledKeywords.contains(jsonKeyword)) { @@ -330,7 +343,8 @@ public static PathToSchemasMap validate( arg, validationMetadata, containsPathToSchemas, - patternPropertiesPathToSchemas + patternPropertiesPathToSchemas, + ifPathToSchemas ); if (otherPathToSchemas == null) { continue; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java index 16554a769d5..6d59bf27219 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java @@ -182,4 +182,9 @@ public JsonSchemaInfo prefixItems(List> prefixItems) this.prefixItems = prefixItems; return this; } + public @Nullable Class ifSchema = null; + public JsonSchemaInfo ifSchema(Class ifSchema) { + this.ifSchema = ifSchema; + return this; + } } \ No newline at end of file diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java index 3ff931654e5..41b4b85eb2e 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java @@ -12,7 +12,8 @@ public interface KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) throws ValidationException; default List getContainsPathToSchemas( @@ -28,4 +29,11 @@ default PathToSchemasMap getPatternPropertiesPathToSchemas( ) { return new PathToSchemasMap(); } + + default PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + return new PathToSchemasMap(); + } } \ No newline at end of file diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java index a234c2907bd..25482139fab 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java @@ -18,7 +18,8 @@ public MaxContainsValidator(int maxContains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java index 21d175aeb60..bda6fb43ece 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java @@ -18,7 +18,8 @@ public MaxItemsValidator(int maxItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java index 4309ad392ab..1a78623e0f4 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java @@ -18,7 +18,8 @@ public MaxLengthValidator(int maxLength) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java index 0933d14568b..5928ec588ac 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java @@ -19,7 +19,8 @@ public MaxPropertiesValidator(int maxProperties) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java index b7c08a08cb5..25faceb4022 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java @@ -18,7 +18,8 @@ public MaximumValidator(Number maximum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java index 70239e3fa3b..2f34127155e 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java @@ -18,7 +18,8 @@ public MinContainsValidator(int minContains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java index 5b452150aef..7c46cbe8f94 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java @@ -18,7 +18,8 @@ public MinItemsValidator(int minItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java index 9dbac1aeb11..7c92205a9cf 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java @@ -18,7 +18,8 @@ public MinLengthValidator(int minLength) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java index 24bb979c613..c52b16000d8 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java @@ -19,7 +19,8 @@ public MinPropertiesValidator(int minProperties) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java index 34d6d27c5bf..dec192d47df 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java @@ -18,7 +18,8 @@ public MinimumValidator(Number minimum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java index b5601e16fc9..15230b54275 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java @@ -19,7 +19,8 @@ public MultipleOfValidator(BigDecimal multipleOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java index 5a9e59f530b..507c7f40fbc 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java @@ -23,7 +23,8 @@ public NotValidator(Class not) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas; try { diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java index e0c51fe2a11..5bc4bbd297b 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java @@ -19,7 +19,8 @@ public OneOfValidator(List> oneOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedOneOfClasses = new ArrayList<>(); diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java index fa486ddcdab..6104329139f 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java @@ -21,7 +21,8 @@ public PatternPropertiesValidator(Map> patt @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java index 92678f1cca4..37e7a545711 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java @@ -19,7 +19,8 @@ public PatternValidator(Pattern pattern) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java index 4163833addb..a8b2bda2a21 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java @@ -18,7 +18,8 @@ public PrefixItemsValidator(List> prefixItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java index 94599597a13..9b7d50b28d8 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java @@ -21,7 +21,8 @@ public PropertiesValidator(Map> properties) @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java index f4ec5ab6239..5154911d484 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java @@ -19,7 +19,8 @@ public PropertyNamesValidator(Class propertyNames) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java index 148be09c410..f68aef2b87a 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java @@ -21,7 +21,8 @@ public RequiredValidator(Set required) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java index fd827d49e13..f1fcd9d5cdd 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java @@ -20,7 +20,8 @@ public TypeValidator(Set> type) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { Class argClass; if (arg == null) { diff --git a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java index 419823634e3..4cdbbe01060 100644 --- a/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java @@ -20,7 +20,8 @@ public UniqueItemsValidator(boolean uniqueItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java index e23076a75b1..7e6d7d09535 100644 --- a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java +++ b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java @@ -79,6 +79,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -110,6 +111,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -134,6 +136,7 @@ public void testIncorrectPropertyValueFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java index 69ffff00ce1..87a6bafc05f 100644 --- a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java +++ b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java @@ -35,6 +35,7 @@ public void testIntFormatSucceedsWithFloat() { 1.0f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -48,6 +49,7 @@ public void testIntFormatFailsWithFloat() { 3.14f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -60,6 +62,7 @@ public void testIntFormatSucceedsWithInt() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -73,6 +76,7 @@ public void testInt32UnderMinFails() { -2147483649L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -85,6 +89,7 @@ public void testInt32InclusiveMinSucceeds() { -2147483648, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -98,6 +103,7 @@ public void testInt32InclusiveMaxSucceeds() { 2147483647, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -111,6 +117,7 @@ public void testInt32OverMaxFails() { 2147483648L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -124,6 +131,7 @@ public void testInt64UnderMinFails() { new BigInteger("-9223372036854775809"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -136,6 +144,7 @@ public void testInt64InclusiveMinSucceeds() { -9223372036854775808L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -149,6 +158,7 @@ public void testInt64InclusiveMaxSucceeds() { 9223372036854775807L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -163,6 +173,7 @@ public void testInt64OverMaxFails() { new BigInteger("9223372036854775808"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -175,6 +186,7 @@ public void testFloatUnderMinFails() { -3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -187,6 +199,7 @@ public void testFloatInclusiveMinSucceeds() { -3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -200,6 +213,7 @@ public void testFloatInclusiveMaxSucceeds() { 3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -213,6 +227,7 @@ public void testFloatOverMaxFails() { 3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -225,6 +240,7 @@ public void testDoubleUnderMinFails() { new BigDecimal("-1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -237,6 +253,7 @@ public void testDoubleInclusiveMinSucceeds() { -1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -250,6 +267,7 @@ public void testDoubleInclusiveMaxSucceeds() { 1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -263,6 +281,7 @@ public void testDoubleOverMaxFails() { new BigDecimal("1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -275,6 +294,7 @@ public void testInvalidNumberStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -287,6 +307,7 @@ public void testValidFloatNumberStringSucceeds() { "3.14", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -300,6 +321,7 @@ public void testValidIntNumberStringSucceeds() { "1", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -313,6 +335,7 @@ public void testInvalidDateStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -325,6 +348,7 @@ public void testValidDateStringSucceeds() { "2017-01-20", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -338,6 +362,7 @@ public void testInvalidDateTimeStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -350,6 +375,7 @@ public void testValidDateTimeStringSucceeds() { "2017-07-21T17:32:28Z", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); diff --git a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java index 2e3fcdb5129..f9c539091f3 100644 --- a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java +++ b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java @@ -38,6 +38,7 @@ public void testCorrectItemsSucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -69,6 +70,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -92,6 +94,7 @@ public void testIncorrectItemFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java index 9367dc3268d..ea58d090f1f 100644 --- a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java +++ b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java @@ -42,6 +42,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -75,6 +76,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -101,6 +103,7 @@ public void testIncorrectPropertyValueFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java index 53d0fced6ca..2c26d7c7954 100644 --- a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java +++ b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java @@ -41,6 +41,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -64,6 +65,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -90,6 +92,7 @@ public void testIncorrectPropertyFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java index 1dffdb7eb98..48433e51455 100644 --- a/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java +++ b/samples/client/3_0_3_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java @@ -33,6 +33,7 @@ public void testValidateSucceeds() { "hi", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -54,6 +55,7 @@ public void testValidateFailsIntIsNotString() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_1_0_unit_test/java/.openapi-generator/FILES b/samples/client/3_1_0_unit_test/java/.openapi-generator/FILES index 502dec2548c..bf90fe85e5e 100644 --- a/samples/client/3_1_0_unit_test/java/.openapi-generator/FILES +++ b/samples/client/3_1_0_unit_test/java/.openapi-generator/FILES @@ -47,6 +47,7 @@ docs/components/schemas/ForbiddenProperty.md docs/components/schemas/HostnameFormat.md docs/components/schemas/IdnEmailFormat.md docs/components/schemas/IdnHostnameFormat.md +docs/components/schemas/IgnoreIfWithoutThenOrElse.md docs/components/schemas/IntegerTypeMatchesIntegers.md docs/components/schemas/Ipv4Format.md docs/components/schemas/Ipv6Format.md @@ -76,6 +77,7 @@ docs/components/schemas/NestedAllofToCheckValidationSemantics.md docs/components/schemas/NestedAnyofToCheckValidationSemantics.md docs/components/schemas/NestedItems.md docs/components/schemas/NestedOneofToCheckValidationSemantics.md +docs/components/schemas/NonAsciiPatternWithAdditionalproperties.md docs/components/schemas/Not.md docs/components/schemas/NotMoreComplexSchema.md docs/components/schemas/NotMultipleTypes.md @@ -178,6 +180,7 @@ src/main/java/org/openapijsonschematools/client/components/schemas/ForbiddenProp src/main/java/org/openapijsonschematools/client/components/schemas/HostnameFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/IdnEmailFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/IdnHostnameFormat.java +src/main/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElse.java src/main/java/org/openapijsonschematools/client/components/schemas/IntegerTypeMatchesIntegers.java src/main/java/org/openapijsonschematools/client/components/schemas/Ipv4Format.java src/main/java/org/openapijsonschematools/client/components/schemas/Ipv6Format.java @@ -207,6 +210,7 @@ src/main/java/org/openapijsonschematools/client/components/schemas/NestedAllofTo src/main/java/org/openapijsonschematools/client/components/schemas/NestedAnyofToCheckValidationSemantics.java src/main/java/org/openapijsonschematools/client/components/schemas/NestedItems.java src/main/java/org/openapijsonschematools/client/components/schemas/NestedOneofToCheckValidationSemantics.java +src/main/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalproperties.java src/main/java/org/openapijsonschematools/client/components/schemas/Not.java src/main/java/org/openapijsonschematools/client/components/schemas/NotMoreComplexSchema.java src/main/java/org/openapijsonschematools/client/components/schemas/NotMultipleTypes.java @@ -309,6 +313,7 @@ src/main/java/org/openapijsonschematools/client/schemas/validation/FloatValueMet src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenList.java src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenMap.java +src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/IntegerEnumValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/IntegerValueMethod.java src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java diff --git a/samples/client/3_1_0_unit_test/java/README.md b/samples/client/3_1_0_unit_test/java/README.md index 2b260c96abe..40d9c54aeb2 100644 --- a/samples/client/3_1_0_unit_test/java/README.md +++ b/samples/client/3_1_0_unit_test/java/README.md @@ -205,6 +205,7 @@ allowed input and output types. | [HostnameFormat.HostnameFormat1](docs/components/schemas/HostnameFormat.md#hostnameformat1) | | | [IdnEmailFormat.IdnEmailFormat1](docs/components/schemas/IdnEmailFormat.md#idnemailformat1) | | | [IdnHostnameFormat.IdnHostnameFormat1](docs/components/schemas/IdnHostnameFormat.md#idnhostnameformat1) | | +| [IgnoreIfWithoutThenOrElse.IgnoreIfWithoutThenOrElse1](docs/components/schemas/IgnoreIfWithoutThenOrElse.md#ignoreifwithoutthenorelse1) | | | [IntegerTypeMatchesIntegers.IntegerTypeMatchesIntegers1](docs/components/schemas/IntegerTypeMatchesIntegers.md#integertypematchesintegers1) | | | [Ipv4Format.Ipv4Format1](docs/components/schemas/Ipv4Format.md#ipv4format1) | | | [Ipv6Format.Ipv6Format1](docs/components/schemas/Ipv6Format.md#ipv6format1) | | @@ -234,6 +235,7 @@ allowed input and output types. | [NestedAnyofToCheckValidationSemantics.NestedAnyofToCheckValidationSemantics1](docs/components/schemas/NestedAnyofToCheckValidationSemantics.md#nestedanyoftocheckvalidationsemantics1) | | | [NestedItems.NestedItems1](docs/components/schemas/NestedItems.md#nesteditems1) | | | [NestedOneofToCheckValidationSemantics.NestedOneofToCheckValidationSemantics1](docs/components/schemas/NestedOneofToCheckValidationSemantics.md#nestedoneoftocheckvalidationsemantics1) | | +| [NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalproperties1](docs/components/schemas/NonAsciiPatternWithAdditionalproperties.md#nonasciipatternwithadditionalproperties1) | | | [Not.Not1](docs/components/schemas/Not.md#not1) | | | [NotMoreComplexSchema.NotMoreComplexSchema1](docs/components/schemas/NotMoreComplexSchema.md#notmorecomplexschema1) | | | [NotMultipleTypes.NotMultipleTypes1](docs/components/schemas/NotMultipleTypes.md#notmultipletypes1) | | diff --git a/samples/client/3_1_0_unit_test/java/docs/components/schemas/IgnoreIfWithoutThenOrElse.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/IgnoreIfWithoutThenOrElse.md new file mode 100644 index 00000000000..ad6fa18d65a --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/IgnoreIfWithoutThenOrElse.md @@ -0,0 +1,74 @@ +# IgnoreIfWithoutThenOrElse +org.openapijsonschematools.client.components.schemas.IgnoreIfWithoutThenOrElse.java +public class IgnoreIfWithoutThenOrElse + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- enum classes + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [IgnoreIfWithoutThenOrElse.IgnoreIfWithoutThenOrElse1](#ignoreifwithoutthenorelse1)
schema class | +| static class | [IgnoreIfWithoutThenOrElse.IfSchema](#ifschema)
schema class | +| enum | [IgnoreIfWithoutThenOrElse.StringIfConst](#stringifconst)
String enum | + +## IgnoreIfWithoutThenOrElse1 +public static class IgnoreIfWithoutThenOrElse1
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Class | if = [IfSchema.class](#ifschema) | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| String | validate(String arg, SchemaConfiguration configuration) | +| Void | validate(Void arg, SchemaConfiguration configuration) | +| int | validate(int arg, SchemaConfiguration configuration) | +| long | validate(long arg, SchemaConfiguration configuration) | +| float | validate(float arg, SchemaConfiguration configuration) | +| double | validate(double arg, SchemaConfiguration configuration) | +| boolean | validate(boolean arg, SchemaConfiguration configuration) | +| FrozenMap | validate(Map<?, ?> arg, SchemaConfiguration configuration) | +| FrozenList<@Nullable Object> | validate(List arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## IfSchema +public static class IfSchema
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| String | validate(String arg, SchemaConfiguration configuration) | +| Void | validate(Void arg, SchemaConfiguration configuration) | +| int | validate(int arg, SchemaConfiguration configuration) | +| long | validate(long arg, SchemaConfiguration configuration) | +| float | validate(float arg, SchemaConfiguration configuration) | +| double | validate(double arg, SchemaConfiguration configuration) | +| boolean | validate(boolean arg, SchemaConfiguration configuration) | +| FrozenMap | validate(Map<?, ?> arg, SchemaConfiguration configuration) | +| FrozenList<@Nullable Object> | validate(List arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## StringIfConst +public enum StringIfConst
+extends `Enum` + +A class that stores String enum values + +### Enum Constant Summary +| Enum Constant | Description | +| ------------- | ----------- | +| POSITIVE_0 | value = "0" | + +[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md) diff --git a/samples/client/3_1_0_unit_test/java/docs/components/schemas/NonAsciiPatternWithAdditionalproperties.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/NonAsciiPatternWithAdditionalproperties.md new file mode 100644 index 00000000000..ee28a1cdeea --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/NonAsciiPatternWithAdditionalproperties.md @@ -0,0 +1,108 @@ +# NonAsciiPatternWithAdditionalproperties +org.openapijsonschematools.client.components.schemas.NonAsciiPatternWithAdditionalproperties.java +public class NonAsciiPatternWithAdditionalproperties + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated map payloads, extends FrozenMap +- classes to build inputs for map payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalproperties1](#nonasciipatternwithadditionalproperties1)
schema class | +| static class | [NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalpropertiesMapBuilder](#nonasciipatternwithadditionalpropertiesmapbuilder)
builder for Map payloads | +| static class | [NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalpropertiesMap](#nonasciipatternwithadditionalpropertiesmap)
output class for Map payloads | +| static class | [NonAsciiPatternWithAdditionalproperties.CircumflexAccentLatinSmallLetterAWithAcute](#circumflexaccentlatinsmallletterawithacute)
schema class | +| static class | [NonAsciiPatternWithAdditionalproperties.AdditionalProperties](#additionalproperties)
schema class | + +## NonAsciiPatternWithAdditionalproperties1 +public static class NonAsciiPatternWithAdditionalproperties1
+extends JsonSchema + +A schema class that validates payloads + +### Code Sample +``` +import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags; +import org.openapijsonschematools.client.configurations.SchemaConfiguration; +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.schemas.validation.MapUtils; +import org.openapijsonschematools.client.schemas.validation.FrozenList; +import org.openapijsonschematools.client.schemas.validation.FrozenMap; + +import java.util.Arrays; +import java.util.List; +import java.util.AbstractMap; + +static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); + +// Map validation +NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalpropertiesMap validatedPayload = + NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalproperties1.validate( + new NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalpropertiesMapBuilder() + .build(), + configuration +); +``` + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Set> | type = Set.of(Map.class) | +| Class | additionalProperties = [AdditionalProperties.class](#additionalproperties) | +| Map> | patternProperties = Map.ofEntries(
    new AbstractMap.SimpleEntry<>(Pattern.compile("^á"), [CircumflexAccentLatinSmallLetterAWithAcute.class](#circumflexaccentlatinsmallletterawithacute)))
)
| + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| [NonAsciiPatternWithAdditionalpropertiesMap](#nonasciipatternwithadditionalpropertiesmap) | validate([Map<?, ?>](#nonasciipatternwithadditionalpropertiesmapbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## NonAsciiPatternWithAdditionalpropertiesMapBuilder +public class NonAsciiPatternWithAdditionalpropertiesMapBuilder
+builder for `Map` + +A class that builds the Map input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| NonAsciiPatternWithAdditionalpropertiesMapBuilder()
Creates a builder that contains an empty map | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| Map | build()
Returns map input that should be used with Schema.validate | + +## NonAsciiPatternWithAdditionalpropertiesMap +public static class NonAsciiPatternWithAdditionalpropertiesMap
+extends FrozenMap + +A class to store validated Map payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [NonAsciiPatternWithAdditionalpropertiesMap](#nonasciipatternwithadditionalpropertiesmap) | of([Map](#nonasciipatternwithadditionalpropertiesmapbuilder) arg, SchemaConfiguration configuration) | + +## CircumflexAccentLatinSmallLetterAWithAcute +public static class CircumflexAccentLatinSmallLetterAWithAcute
+extends AnyTypeJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.AnyTypeJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## AdditionalProperties +public static class AdditionalProperties
+extends NotAnyTypeJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.NotAnyTypeJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md) diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElse.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElse.java new file mode 100644 index 00000000000..694081d4c22 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElse.java @@ -0,0 +1,447 @@ +package org.openapijsonschematools.client.components.schemas; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags; +import org.openapijsonschematools.client.configurations.SchemaConfiguration; +import org.openapijsonschematools.client.exceptions.InvalidAdditionalPropertyException; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.openapijsonschematools.client.exceptions.UnsetPropertyException; +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.schemas.UnsetAddPropsSetter; +import org.openapijsonschematools.client.schemas.validation.BooleanSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.FrozenList; +import org.openapijsonschematools.client.schemas.validation.FrozenMap; +import org.openapijsonschematools.client.schemas.validation.JsonSchema; +import org.openapijsonschematools.client.schemas.validation.JsonSchemaInfo; +import org.openapijsonschematools.client.schemas.validation.ListSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.MapSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.NullSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.NumberSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.PathToSchemasMap; +import org.openapijsonschematools.client.schemas.validation.StringEnumValidator; +import org.openapijsonschematools.client.schemas.validation.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.StringValueMethod; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class IgnoreIfWithoutThenOrElse { + // nest classes so all schemas and input/output classes can be public + + public enum StringIfConst implements StringValueMethod { + POSITIVE_0("0"); + private final String value; + + StringIfConst(String value) { + this.value = value; + } + public String value() { + return this.value; + } + } + + + public static class IfSchema extends JsonSchema implements NullSchemaValidator, BooleanSchemaValidator, NumberSchemaValidator, StringSchemaValidator, ListSchemaValidator>, MapSchemaValidator> { + private static @Nullable IfSchema instance = null; + + protected IfSchema() { + super(new JsonSchemaInfo() + .constValue("0") + ); + } + + public static IfSchema getInstance() { + if (instance == null) { + instance = new IfSchema(); + } + return instance; + } + + @Override + public Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + Void castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + @Override + public boolean validate(boolean arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + boolean castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + @Override + public Number validate(Number arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + Number castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + public int validate(int arg, SchemaConfiguration configuration) { + return (int) validate((Number) arg, configuration); + } + + public long validate(long arg, SchemaConfiguration configuration) { + return (long) validate((Number) arg, configuration); + } + + public float validate(float arg, SchemaConfiguration configuration) { + return (float) validate((Number) arg, configuration); + } + + public double validate(double arg, SchemaConfiguration configuration) { + return (double) validate((Number) arg, configuration); + } + + @Override + public String validate(String arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + String castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + public String validate(LocalDate arg, SchemaConfiguration configuration) throws ValidationException { + return validate(arg.toString(), configuration); + } + + public String validate(ZonedDateTime arg, SchemaConfiguration configuration) throws ValidationException { + return validate(arg.toString(), configuration); + } + + public String validate(UUID arg, SchemaConfiguration configuration) throws ValidationException { + return validate(arg.toString(), configuration); + } + + @Override + public FrozenList<@Nullable Object> getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + List<@Nullable Object> items = new ArrayList<>(); + int i = 0; + for (Object item: arg) { + List itemPathToItem = new ArrayList<>(pathToItem); + itemPathToItem.add(i); + LinkedHashMap schemas = pathToSchemas.get(itemPathToItem); + if (schemas == null) { + throw new InvalidTypeException("Validation result is invalid, schemas must exist for a pathToItem"); + } + JsonSchema itemSchema = schemas.entrySet().iterator().next().getKey(); + @Nullable Object itemInstance = itemSchema.getNewInstance(item, itemPathToItem, pathToSchemas); + items.add(itemInstance); + i += 1; + } + FrozenList<@Nullable Object> newInstanceItems = new FrozenList<>(items); + return newInstanceItems; + } + + public FrozenList<@Nullable Object> validate(List arg, SchemaConfiguration configuration) throws ValidationException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0"); + List castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, new PathToSchemasMap(), new LinkedHashSet<>()); + PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet); + return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + + @Override + public FrozenMap<@Nullable Object> getNewInstance(Map arg, List pathToItem, PathToSchemasMap pathToSchemas) { + LinkedHashMap properties = new LinkedHashMap<>(); + for(Map.Entry entry: arg.entrySet()) { + @Nullable Object entryKey = entry.getKey(); + if (!(entryKey instanceof String)) { + throw new InvalidTypeException("Invalid non-string key value"); + } + String propertyName = (String) entryKey; + List propertyPathToItem = new ArrayList<>(pathToItem); + propertyPathToItem.add(propertyName); + Object value = entry.getValue(); + LinkedHashMap schemas = pathToSchemas.get(propertyPathToItem); + if (schemas == null) { + throw new InvalidTypeException("Validation result is invalid, schemas must exist for a pathToItem"); + } + JsonSchema propertySchema = schemas.entrySet().iterator().next().getKey(); + @Nullable Object propertyInstance = propertySchema.getNewInstance(value, propertyPathToItem, pathToSchemas); + properties.put(propertyName, propertyInstance); + } + FrozenMap<@Nullable Object> castProperties = new FrozenMap<>(properties); + return castProperties; + } + + public FrozenMap<@Nullable Object> validate(Map arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + Map castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet); + return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + + @Override + public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + if (arg == null) { + return validate((Void) null, configuration); + } else if (arg instanceof Boolean) { + boolean boolArg = (Boolean) arg; + return validate(boolArg, configuration); + } else if (arg instanceof Number) { + return validate((Number) arg, configuration); + } else if (arg instanceof String) { + return validate((String) arg, configuration); + } else if (arg instanceof List) { + return validate((List) arg, configuration); + } else if (arg instanceof Map) { + return validate((Map) arg, configuration); + } + throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be validated by this schema"); + } + @Override + public @Nullable Object getNewInstance(@Nullable Object arg, List pathToItem, PathToSchemasMap pathToSchemas) throws InvalidTypeException { + if (arg == null) { + return getNewInstance((Void) null, pathToItem, pathToSchemas); + } else if (arg instanceof Boolean) { + boolean boolArg = (Boolean) arg; + return getNewInstance(boolArg, pathToItem, pathToSchemas); + } else if (arg instanceof Number) { + return getNewInstance((Number) arg, pathToItem, pathToSchemas); + } else if (arg instanceof String) { + return getNewInstance((String) arg, pathToItem, pathToSchemas); + } else if (arg instanceof List) { + return getNewInstance((List) arg, pathToItem, pathToSchemas); + } else if (arg instanceof Map) { + return getNewInstance((Map) arg, pathToItem, pathToSchemas); + } + throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema"); + } + } + + public static class IgnoreIfWithoutThenOrElse1 extends JsonSchema implements NullSchemaValidator, BooleanSchemaValidator, NumberSchemaValidator, StringSchemaValidator, ListSchemaValidator>, MapSchemaValidator> { + /* + NOTE: This class is auto generated by OpenAPI JSON Schema Generator. + Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator + + Do not edit the class manually. + */ + private static @Nullable IgnoreIfWithoutThenOrElse1 instance = null; + + protected IgnoreIfWithoutThenOrElse1() { + super(new JsonSchemaInfo() + .ifSchema(IfSchema.class) + ); + } + + public static IgnoreIfWithoutThenOrElse1 getInstance() { + if (instance == null) { + instance = new IgnoreIfWithoutThenOrElse1(); + } + return instance; + } + + @Override + public Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + Void castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + @Override + public boolean validate(boolean arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + boolean castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + @Override + public Number validate(Number arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + Number castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + public int validate(int arg, SchemaConfiguration configuration) { + return (int) validate((Number) arg, configuration); + } + + public long validate(long arg, SchemaConfiguration configuration) { + return (long) validate((Number) arg, configuration); + } + + public float validate(float arg, SchemaConfiguration configuration) { + return (float) validate((Number) arg, configuration); + } + + public double validate(double arg, SchemaConfiguration configuration) { + return (double) validate((Number) arg, configuration); + } + + @Override + public String validate(String arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + String castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + getPathToSchemas(this, castArg, validationMetadata, pathSet); + return castArg; + } + + public String validate(LocalDate arg, SchemaConfiguration configuration) throws ValidationException { + return validate(arg.toString(), configuration); + } + + public String validate(ZonedDateTime arg, SchemaConfiguration configuration) throws ValidationException { + return validate(arg.toString(), configuration); + } + + public String validate(UUID arg, SchemaConfiguration configuration) throws ValidationException { + return validate(arg.toString(), configuration); + } + + @Override + public FrozenList<@Nullable Object> getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + List<@Nullable Object> items = new ArrayList<>(); + int i = 0; + for (Object item: arg) { + List itemPathToItem = new ArrayList<>(pathToItem); + itemPathToItem.add(i); + LinkedHashMap schemas = pathToSchemas.get(itemPathToItem); + if (schemas == null) { + throw new InvalidTypeException("Validation result is invalid, schemas must exist for a pathToItem"); + } + JsonSchema itemSchema = schemas.entrySet().iterator().next().getKey(); + @Nullable Object itemInstance = itemSchema.getNewInstance(item, itemPathToItem, pathToSchemas); + items.add(itemInstance); + i += 1; + } + FrozenList<@Nullable Object> newInstanceItems = new FrozenList<>(items); + return newInstanceItems; + } + + public FrozenList<@Nullable Object> validate(List arg, SchemaConfiguration configuration) throws ValidationException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0"); + List castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, new PathToSchemasMap(), new LinkedHashSet<>()); + PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet); + return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + + @Override + public FrozenMap<@Nullable Object> getNewInstance(Map arg, List pathToItem, PathToSchemasMap pathToSchemas) { + LinkedHashMap properties = new LinkedHashMap<>(); + for(Map.Entry entry: arg.entrySet()) { + @Nullable Object entryKey = entry.getKey(); + if (!(entryKey instanceof String)) { + throw new InvalidTypeException("Invalid non-string key value"); + } + String propertyName = (String) entryKey; + List propertyPathToItem = new ArrayList<>(pathToItem); + propertyPathToItem.add(propertyName); + Object value = entry.getValue(); + LinkedHashMap schemas = pathToSchemas.get(propertyPathToItem); + if (schemas == null) { + throw new InvalidTypeException("Validation result is invalid, schemas must exist for a pathToItem"); + } + JsonSchema propertySchema = schemas.entrySet().iterator().next().getKey(); + @Nullable Object propertyInstance = propertySchema.getNewInstance(value, propertyPathToItem, pathToSchemas); + properties.put(propertyName, propertyInstance); + } + FrozenMap<@Nullable Object> castProperties = new FrozenMap<>(properties); + return castProperties; + } + + public FrozenMap<@Nullable Object> validate(Map arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0]"); + Map castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + PathToSchemasMap validatedPathToSchemas = new PathToSchemasMap(); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, validatedPathToSchemas, new LinkedHashSet<>()); + PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet); + return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + + @Override + public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + if (arg == null) { + return validate((Void) null, configuration); + } else if (arg instanceof Boolean) { + boolean boolArg = (Boolean) arg; + return validate(boolArg, configuration); + } else if (arg instanceof Number) { + return validate((Number) arg, configuration); + } else if (arg instanceof String) { + return validate((String) arg, configuration); + } else if (arg instanceof List) { + return validate((List) arg, configuration); + } else if (arg instanceof Map) { + return validate((Map) arg, configuration); + } + throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be validated by this schema"); + } + @Override + public @Nullable Object getNewInstance(@Nullable Object arg, List pathToItem, PathToSchemasMap pathToSchemas) throws InvalidTypeException { + if (arg == null) { + return getNewInstance((Void) null, pathToItem, pathToSchemas); + } else if (arg instanceof Boolean) { + boolean boolArg = (Boolean) arg; + return getNewInstance(boolArg, pathToItem, pathToSchemas); + } else if (arg instanceof Number) { + return getNewInstance((Number) arg, pathToItem, pathToSchemas); + } else if (arg instanceof String) { + return getNewInstance((String) arg, pathToItem, pathToSchemas); + } else if (arg instanceof List) { + return getNewInstance((List) arg, pathToItem, pathToSchemas); + } else if (arg instanceof Map) { + return getNewInstance((Map) arg, pathToItem, pathToSchemas); + } + throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema"); + } + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalproperties.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalproperties.java new file mode 100644 index 00000000000..3eb3d9f2ecc --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalproperties.java @@ -0,0 +1,158 @@ +package org.openapijsonschematools.client.components.schemas; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.regex.Pattern; +import org.checkerframework.checker.nullness.qual.Nullable; +import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags; +import org.openapijsonschematools.client.configurations.SchemaConfiguration; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.schemas.AnyTypeJsonSchema; +import org.openapijsonschematools.client.schemas.BaseBuilder; +import org.openapijsonschematools.client.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.client.schemas.validation.FrozenMap; +import org.openapijsonschematools.client.schemas.validation.JsonSchema; +import org.openapijsonschematools.client.schemas.validation.JsonSchemaInfo; +import org.openapijsonschematools.client.schemas.validation.MapSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.MapUtils; +import org.openapijsonschematools.client.schemas.validation.PathToSchemasMap; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class NonAsciiPatternWithAdditionalproperties { + // nest classes so all schemas and input/output classes can be public + + + public static class AdditionalProperties extends NotAnyTypeJsonSchema { + // NotAnyTypeSchema + private static @Nullable AdditionalProperties instance = null; + public static AdditionalProperties getInstance() { + if (instance == null) { + instance = new AdditionalProperties(); + } + return instance; + } + } + + + public static class CircumflexAccentLatinSmallLetterAWithAcute extends AnyTypeJsonSchema { + private static @Nullable CircumflexAccentLatinSmallLetterAWithAcute instance = null; + public static CircumflexAccentLatinSmallLetterAWithAcute getInstance() { + if (instance == null) { + instance = new CircumflexAccentLatinSmallLetterAWithAcute(); + } + return instance; + } + } + + + public static class NonAsciiPatternWithAdditionalpropertiesMap extends FrozenMap<@Nullable Object> { + protected NonAsciiPatternWithAdditionalpropertiesMap(FrozenMap<@Nullable Object> m) { + super(m); + } + public static final Set requiredKeys = Set.of(); + public static final Set optionalKeys = Set.of(); + // map with no key value pairs + public static NonAsciiPatternWithAdditionalpropertiesMap of(Map arg, SchemaConfiguration configuration) throws ValidationException { + return NonAsciiPatternWithAdditionalproperties1.getInstance().validate(arg, configuration); + } + } + + public static class NonAsciiPatternWithAdditionalpropertiesMapBuilder implements BaseBuilder<@Nullable Object> { + private final Map instance; + private static final Set knownKeys = Set.of(); + public Set getKnownKeys() { + return knownKeys; + } + public NonAsciiPatternWithAdditionalpropertiesMapBuilder() { + this.instance = new LinkedHashMap<>(); + } + public Map build() { + return instance; + } + } + + + public static class NonAsciiPatternWithAdditionalproperties1 extends JsonSchema implements MapSchemaValidator { + /* + NOTE: This class is auto generated by OpenAPI JSON Schema Generator. + Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator + + Do not edit the class manually. + */ + private static @Nullable NonAsciiPatternWithAdditionalproperties1 instance = null; + + protected NonAsciiPatternWithAdditionalproperties1() { + super(new JsonSchemaInfo() + .type(Set.of(Map.class)) + .additionalProperties(AdditionalProperties.class) + .patternProperties(Map.ofEntries( + new AbstractMap.SimpleEntry<>(Pattern.compile("^á"), CircumflexAccentLatinSmallLetterAWithAcute.class) + )) + ); + } + + public static NonAsciiPatternWithAdditionalproperties1 getInstance() { + if (instance == null) { + instance = new NonAsciiPatternWithAdditionalproperties1(); + } + return instance; + } + + public NonAsciiPatternWithAdditionalpropertiesMap getNewInstance(Map arg, List pathToItem, PathToSchemasMap pathToSchemas) { + LinkedHashMap properties = new LinkedHashMap<>(); + for(Map.Entry entry: arg.entrySet()) { + @Nullable Object entryKey = entry.getKey(); + if (!(entryKey instanceof String)) { + throw new InvalidTypeException("Invalid non-string key value"); + } + String propertyName = (String) entryKey; + List propertyPathToItem = new ArrayList<>(pathToItem); + propertyPathToItem.add(propertyName); + Object value = entry.getValue(); + LinkedHashMap schemas = pathToSchemas.get(propertyPathToItem); + if (schemas == null) { + throw new InvalidTypeException("Validation result is invalid, schemas must exist for a pathToItem"); + } + JsonSchema propertySchema = schemas.entrySet().iterator().next().getKey(); + @Nullable Object propertyInstance = propertySchema.getNewInstance(value, propertyPathToItem, pathToSchemas); + properties.put(propertyName, propertyInstance); + } + FrozenMap<@Nullable Object> castProperties = new FrozenMap<>(properties); + return new NonAsciiPatternWithAdditionalpropertiesMap(castProperties); + } + + public NonAsciiPatternWithAdditionalpropertiesMap validate(Map arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + Set> pathSet = new HashSet<>(); + List pathToItem = List.of("args[0"); + Map castArg = castToAllowedTypes(arg, pathToItem, pathSet); + SchemaConfiguration usedConfiguration = Objects.requireNonNullElseGet(configuration, () -> new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone())); + ValidationMetadata validationMetadata = new ValidationMetadata(pathToItem, usedConfiguration, new PathToSchemasMap(), new LinkedHashSet<>()); + PathToSchemasMap pathToSchemasMap = getPathToSchemas(this, castArg, validationMetadata, pathSet); + return getNewInstance(castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + + + @Override + public @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + if (arg instanceof Map) { + return validate((Map) arg, configuration); + } + throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be validated by this schema"); + } + @Override + public @Nullable Object getNewInstance(@Nullable Object arg, List pathToItem, PathToSchemasMap pathToSchemas) throws InvalidTypeException { + if (arg instanceof Map) { + return getNewInstance((Map) arg, pathToItem, pathToSchemas); + } + throw new InvalidTypeException("Invalid input type="+getClass(arg)+". It can't be instantiated by this schema"); + } + } + +} diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java index 81adeddb054..fd6fa6a4d29 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java @@ -20,7 +20,8 @@ public AdditionalPropertiesValidator(Class additionalPrope @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java index 0c662704072..313e2d97446 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java @@ -16,7 +16,8 @@ public AllOfValidator(List> allOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); for(Class allOfClass: allOf) { diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java index f170798d97c..a4754dda464 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java @@ -19,7 +19,8 @@ public AnyOfValidator(List> anyOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedAnyOfClasses = new ArrayList<>(); diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java index f77d5360885..f797c68ab2e 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java @@ -20,7 +20,8 @@ public ConstValidator(@Nullable Object constValue) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { BigDecimal castArg = getBigDecimal((Number) arg); diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java index a4459d8a9db..deaa878d5af 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java @@ -19,7 +19,8 @@ public ContainsValidator(Class contains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java index 554a49120d0..a5e92887928 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java @@ -21,7 +21,8 @@ public DependentRequiredValidator(Map> dependentRequired) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java index 6ad17c0d139..0ffa3b351ca 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java @@ -21,7 +21,8 @@ public DependentSchemasValidator(Map> depend @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java index ad242f735b2..6cc9459e1a8 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java @@ -25,7 +25,8 @@ private boolean enumContainsArg(@Nullable Object arg){ @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (enumValues.isEmpty()) { throw new ValidationException("No value can match enum because enum is empty"); diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java index 64d86b2722a..432d5b0f4de 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java @@ -18,7 +18,8 @@ public ExclusiveMaximumValidator(Number exclusiveMaximum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java index a596a7e80ce..d60c96f8325 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java @@ -18,7 +18,8 @@ public ExclusiveMinimumValidator(Number exclusiveMinimum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java index be5e2d928b5..d782f2ce4a2 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java @@ -149,7 +149,8 @@ private Void validateStringFormat(String arg, ValidationMetadata validationMetad @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { validateNumericFormat( diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java new file mode 100644 index 00000000000..e1634bd1b00 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java @@ -0,0 +1,56 @@ +package org.openapijsonschematools.client.schemas.validation; + +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class IfValidator implements KeywordValidator { + public final Class ifSchema; + + public IfValidator(Class ifSchema) { + this.ifSchema = ifSchema; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List containsPathToSchemas, + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas + ) { + if (ifPathToSchemas == null) { + throw new ValidationException("Invalid type for ifPathToSchemas"); + } + /* + if is false use case + ifPathToSchemas == {} + no need to add any data to pathToSchemas + + if true, then true -> true for whole schema + so validate_then will add ifPathToSchemas data to pathToSchemas + */ + return null; + } + + public PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + JsonSchema ifSchemaInstance = JsonSchemaFactory.getInstance(ifSchema); + PathToSchemasMap pathToSchemas = new PathToSchemasMap(); + try { + var otherPathToSchemas = JsonSchema.validate(ifSchemaInstance, arg, validationMetadata); + pathToSchemas.update(otherPathToSchemas); + } catch (ValidationException | InvalidTypeException ignored) {} + return pathToSchemas; + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java index cf66ce04470..5d146ab250c 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java @@ -18,7 +18,8 @@ public ItemsValidator(Class items) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java index 33fc4a78e91..551c586665c 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java @@ -54,6 +54,7 @@ public abstract class JsonSchema { public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; public @Nullable List> prefixItems; + public final @Nullable Class ifSchema; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -292,6 +293,13 @@ protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { new PrefixItemsValidator(this.prefixItems) ); } + this.ifSchema = jsonSchemaInfo.ifSchema; + if (this.ifSchema != null) { + keywordToValidator.put( + "if", + new IfValidator(this.ifSchema) + ); + } this.keywordToValidator = keywordToValidator; } @@ -316,6 +324,11 @@ public static PathToSchemasMap validate( if (patternPropertiesValidator != null) { patternPropertiesPathToSchemas = patternPropertiesValidator.getPatternPropertiesPathToSchemas(arg, validationMetadata); } + @Nullable PathToSchemasMap ifPathToSchemas = null; + KeywordValidator ifValidator = thisKeywordToValidator.get("if"); + if (ifValidator != null) { + ifPathToSchemas = ifValidator.getIfPathToSchemas(arg, validationMetadata); + } for (Map.Entry entry: thisKeywordToValidator.entrySet()) { String jsonKeyword = entry.getKey(); if (disabledKeywords.contains(jsonKeyword)) { @@ -330,7 +343,8 @@ public static PathToSchemasMap validate( arg, validationMetadata, containsPathToSchemas, - patternPropertiesPathToSchemas + patternPropertiesPathToSchemas, + ifPathToSchemas ); if (otherPathToSchemas == null) { continue; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java index 16554a769d5..6d59bf27219 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java @@ -182,4 +182,9 @@ public JsonSchemaInfo prefixItems(List> prefixItems) this.prefixItems = prefixItems; return this; } + public @Nullable Class ifSchema = null; + public JsonSchemaInfo ifSchema(Class ifSchema) { + this.ifSchema = ifSchema; + return this; + } } \ No newline at end of file diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java index 3ff931654e5..41b4b85eb2e 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java @@ -12,7 +12,8 @@ public interface KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) throws ValidationException; default List getContainsPathToSchemas( @@ -28,4 +29,11 @@ default PathToSchemasMap getPatternPropertiesPathToSchemas( ) { return new PathToSchemasMap(); } + + default PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + return new PathToSchemasMap(); + } } \ No newline at end of file diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java index a234c2907bd..25482139fab 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java @@ -18,7 +18,8 @@ public MaxContainsValidator(int maxContains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java index 21d175aeb60..bda6fb43ece 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java @@ -18,7 +18,8 @@ public MaxItemsValidator(int maxItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java index 4309ad392ab..1a78623e0f4 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java @@ -18,7 +18,8 @@ public MaxLengthValidator(int maxLength) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java index 0933d14568b..5928ec588ac 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java @@ -19,7 +19,8 @@ public MaxPropertiesValidator(int maxProperties) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java index b7c08a08cb5..25faceb4022 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java @@ -18,7 +18,8 @@ public MaximumValidator(Number maximum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java index 70239e3fa3b..2f34127155e 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java @@ -18,7 +18,8 @@ public MinContainsValidator(int minContains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java index 5b452150aef..7c46cbe8f94 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java @@ -18,7 +18,8 @@ public MinItemsValidator(int minItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java index 9dbac1aeb11..7c92205a9cf 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java @@ -18,7 +18,8 @@ public MinLengthValidator(int minLength) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java index 24bb979c613..c52b16000d8 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java @@ -19,7 +19,8 @@ public MinPropertiesValidator(int minProperties) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java index 34d6d27c5bf..dec192d47df 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java @@ -18,7 +18,8 @@ public MinimumValidator(Number minimum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java index b5601e16fc9..15230b54275 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java @@ -19,7 +19,8 @@ public MultipleOfValidator(BigDecimal multipleOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java index 5a9e59f530b..507c7f40fbc 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java @@ -23,7 +23,8 @@ public NotValidator(Class not) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas; try { diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java index e0c51fe2a11..5bc4bbd297b 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java @@ -19,7 +19,8 @@ public OneOfValidator(List> oneOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedOneOfClasses = new ArrayList<>(); diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java index fa486ddcdab..6104329139f 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java @@ -21,7 +21,8 @@ public PatternPropertiesValidator(Map> patt @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java index 92678f1cca4..37e7a545711 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java @@ -19,7 +19,8 @@ public PatternValidator(Pattern pattern) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java index 4163833addb..a8b2bda2a21 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java @@ -18,7 +18,8 @@ public PrefixItemsValidator(List> prefixItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java index 94599597a13..9b7d50b28d8 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java @@ -21,7 +21,8 @@ public PropertiesValidator(Map> properties) @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java index f4ec5ab6239..5154911d484 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java @@ -19,7 +19,8 @@ public PropertyNamesValidator(Class propertyNames) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java index 148be09c410..f68aef2b87a 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java @@ -21,7 +21,8 @@ public RequiredValidator(Set required) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java index fd827d49e13..f1fcd9d5cdd 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java @@ -20,7 +20,8 @@ public TypeValidator(Set> type) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { Class argClass; if (arg == null) { diff --git a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java index 419823634e3..4cdbbe01060 100644 --- a/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java @@ -20,7 +20,8 @@ public UniqueItemsValidator(boolean uniqueItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElseTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElseTest.java new file mode 100644 index 00000000000..562794f036d --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/IgnoreIfWithoutThenOrElseTest.java @@ -0,0 +1,39 @@ +package org.openapijsonschematools.client.components.schemas; + +import org.junit.Assert; +import org.junit.Test; +import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags; +import org.openapijsonschematools.client.configurations.SchemaConfiguration; +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.openapijsonschematools.client.schemas.validation.MapUtils; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.AbstractMap; + +public class IgnoreIfWithoutThenOrElseTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testValidWhenInvalidAgainstLoneIfPasses() { + // valid when invalid against lone if + final var schema = IgnoreIfWithoutThenOrElse.IgnoreIfWithoutThenOrElse1.getInstance(); + schema.validate( + "hello", + configuration + ); + } + + @Test + public void testValidWhenValidAgainstLoneIfPasses() { + // valid when valid against lone if + final var schema = IgnoreIfWithoutThenOrElse.IgnoreIfWithoutThenOrElse1.getInstance(); + schema.validate( + 0, + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalpropertiesTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalpropertiesTest.java new file mode 100644 index 00000000000..b4ca44fbe2a --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/NonAsciiPatternWithAdditionalpropertiesTest.java @@ -0,0 +1,54 @@ +package org.openapijsonschematools.client.components.schemas; + +import org.junit.Assert; +import org.junit.Test; +import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags; +import org.openapijsonschematools.client.configurations.SchemaConfiguration; +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.openapijsonschematools.client.schemas.validation.MapUtils; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.AbstractMap; + +public class NonAsciiPatternWithAdditionalpropertiesTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testNotMatchingThePatternIsInvalidFails() { + // not matching the pattern is invalid + final var schema = NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalproperties1.getInstance(); + try { + schema.validate( + MapUtils.makeMap( + new AbstractMap.SimpleEntry( + "élmény", + 2 + ) + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } + + @Test + public void testMatchingThePatternIsValidPasses() { + // matching the pattern is valid + final var schema = NonAsciiPatternWithAdditionalproperties.NonAsciiPatternWithAdditionalproperties1.getInstance(); + schema.validate( + MapUtils.makeMap( + new AbstractMap.SimpleEntry( + "ármányos", + 2 + ) + ), + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java index e23076a75b1..7e6d7d09535 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java @@ -79,6 +79,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -110,6 +111,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -134,6 +136,7 @@ public void testIncorrectPropertyValueFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java index 69ffff00ce1..87a6bafc05f 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java @@ -35,6 +35,7 @@ public void testIntFormatSucceedsWithFloat() { 1.0f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -48,6 +49,7 @@ public void testIntFormatFailsWithFloat() { 3.14f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -60,6 +62,7 @@ public void testIntFormatSucceedsWithInt() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -73,6 +76,7 @@ public void testInt32UnderMinFails() { -2147483649L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -85,6 +89,7 @@ public void testInt32InclusiveMinSucceeds() { -2147483648, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -98,6 +103,7 @@ public void testInt32InclusiveMaxSucceeds() { 2147483647, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -111,6 +117,7 @@ public void testInt32OverMaxFails() { 2147483648L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -124,6 +131,7 @@ public void testInt64UnderMinFails() { new BigInteger("-9223372036854775809"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -136,6 +144,7 @@ public void testInt64InclusiveMinSucceeds() { -9223372036854775808L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -149,6 +158,7 @@ public void testInt64InclusiveMaxSucceeds() { 9223372036854775807L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -163,6 +173,7 @@ public void testInt64OverMaxFails() { new BigInteger("9223372036854775808"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -175,6 +186,7 @@ public void testFloatUnderMinFails() { -3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -187,6 +199,7 @@ public void testFloatInclusiveMinSucceeds() { -3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -200,6 +213,7 @@ public void testFloatInclusiveMaxSucceeds() { 3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -213,6 +227,7 @@ public void testFloatOverMaxFails() { 3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -225,6 +240,7 @@ public void testDoubleUnderMinFails() { new BigDecimal("-1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -237,6 +253,7 @@ public void testDoubleInclusiveMinSucceeds() { -1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -250,6 +267,7 @@ public void testDoubleInclusiveMaxSucceeds() { 1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -263,6 +281,7 @@ public void testDoubleOverMaxFails() { new BigDecimal("1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -275,6 +294,7 @@ public void testInvalidNumberStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -287,6 +307,7 @@ public void testValidFloatNumberStringSucceeds() { "3.14", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -300,6 +321,7 @@ public void testValidIntNumberStringSucceeds() { "1", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -313,6 +335,7 @@ public void testInvalidDateStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -325,6 +348,7 @@ public void testValidDateStringSucceeds() { "2017-01-20", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -338,6 +362,7 @@ public void testInvalidDateTimeStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -350,6 +375,7 @@ public void testValidDateTimeStringSucceeds() { "2017-07-21T17:32:28Z", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java index 2e3fcdb5129..f9c539091f3 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java @@ -38,6 +38,7 @@ public void testCorrectItemsSucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -69,6 +70,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -92,6 +94,7 @@ public void testIncorrectItemFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java index 9367dc3268d..ea58d090f1f 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java @@ -42,6 +42,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -75,6 +76,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -101,6 +103,7 @@ public void testIncorrectPropertyValueFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java index 53d0fced6ca..2c26d7c7954 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java @@ -41,6 +41,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -64,6 +65,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -90,6 +92,7 @@ public void testIncorrectPropertyFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java index 1dffdb7eb98..48433e51455 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java @@ -33,6 +33,7 @@ public void testValidateSucceeds() { "hi", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -54,6 +55,7 @@ public void testValidateFailsIntIsNotString() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/petstore/java/.openapi-generator/FILES b/samples/client/petstore/java/.openapi-generator/FILES index 8b8e9472022..eaed21fc5cf 100644 --- a/samples/client/petstore/java/.openapi-generator/FILES +++ b/samples/client/petstore/java/.openapi-generator/FILES @@ -703,6 +703,7 @@ src/main/java/org/openapijsonschematools/client/schemas/validation/FloatValueMet src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenList.java src/main/java/org/openapijsonschematools/client/schemas/validation/FrozenMap.java +src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/IntegerEnumValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/IntegerValueMethod.java src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java index 81adeddb054..fd6fa6a4d29 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidator.java @@ -20,7 +20,8 @@ public AdditionalPropertiesValidator(Class additionalPrope @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java index 0c662704072..313e2d97446 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java @@ -16,7 +16,8 @@ public AllOfValidator(List> allOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); for(Class allOfClass: allOf) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java index f170798d97c..a4754dda464 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/AnyOfValidator.java @@ -19,7 +19,8 @@ public AnyOfValidator(List> anyOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedAnyOfClasses = new ArrayList<>(); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java index f77d5360885..f797c68ab2e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ConstValidator.java @@ -20,7 +20,8 @@ public ConstValidator(@Nullable Object constValue) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { BigDecimal castArg = getBigDecimal((Number) arg); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java index a4459d8a9db..deaa878d5af 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ContainsValidator.java @@ -19,7 +19,8 @@ public ContainsValidator(Class contains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java index 554a49120d0..a5e92887928 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentRequiredValidator.java @@ -21,7 +21,8 @@ public DependentRequiredValidator(Map> dependentRequired) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java index 6ad17c0d139..0ffa3b351ca 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/DependentSchemasValidator.java @@ -21,7 +21,8 @@ public DependentSchemasValidator(Map> depend @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java index ad242f735b2..6cc9459e1a8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/EnumValidator.java @@ -25,7 +25,8 @@ private boolean enumContainsArg(@Nullable Object arg){ @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (enumValues.isEmpty()) { throw new ValidationException("No value can match enum because enum is empty"); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java index 64d86b2722a..432d5b0f4de 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMaximumValidator.java @@ -18,7 +18,8 @@ public ExclusiveMaximumValidator(Number exclusiveMaximum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java index a596a7e80ce..d60c96f8325 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ExclusiveMinimumValidator.java @@ -18,7 +18,8 @@ public ExclusiveMinimumValidator(Number exclusiveMinimum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java index be5e2d928b5..d782f2ce4a2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/FormatValidator.java @@ -149,7 +149,8 @@ private Void validateStringFormat(String arg, ValidationMetadata validationMetad @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { validateNumericFormat( diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java new file mode 100644 index 00000000000..e1634bd1b00 --- /dev/null +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/IfValidator.java @@ -0,0 +1,56 @@ +package org.openapijsonschematools.client.schemas.validation; + +import org.openapijsonschematools.client.exceptions.ValidationException; +import org.openapijsonschematools.client.exceptions.InvalidTypeException; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class IfValidator implements KeywordValidator { + public final Class ifSchema; + + public IfValidator(Class ifSchema) { + this.ifSchema = ifSchema; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List containsPathToSchemas, + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas + ) { + if (ifPathToSchemas == null) { + throw new ValidationException("Invalid type for ifPathToSchemas"); + } + /* + if is false use case + ifPathToSchemas == {} + no need to add any data to pathToSchemas + + if true, then true -> true for whole schema + so validate_then will add ifPathToSchemas data to pathToSchemas + */ + return null; + } + + public PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + JsonSchema ifSchemaInstance = JsonSchemaFactory.getInstance(ifSchema); + PathToSchemasMap pathToSchemas = new PathToSchemasMap(); + try { + var otherPathToSchemas = JsonSchema.validate(ifSchemaInstance, arg, validationMetadata); + pathToSchemas.update(otherPathToSchemas); + } catch (ValidationException | InvalidTypeException ignored) {} + return pathToSchemas; + } +} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java index cf66ce04470..5d146ab250c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java @@ -18,7 +18,8 @@ public ItemsValidator(Class items) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java index 33fc4a78e91..551c586665c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchema.java @@ -54,6 +54,7 @@ public abstract class JsonSchema { public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; public @Nullable List> prefixItems; + public final @Nullable Class ifSchema; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -292,6 +293,13 @@ protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { new PrefixItemsValidator(this.prefixItems) ); } + this.ifSchema = jsonSchemaInfo.ifSchema; + if (this.ifSchema != null) { + keywordToValidator.put( + "if", + new IfValidator(this.ifSchema) + ); + } this.keywordToValidator = keywordToValidator; } @@ -316,6 +324,11 @@ public static PathToSchemasMap validate( if (patternPropertiesValidator != null) { patternPropertiesPathToSchemas = patternPropertiesValidator.getPatternPropertiesPathToSchemas(arg, validationMetadata); } + @Nullable PathToSchemasMap ifPathToSchemas = null; + KeywordValidator ifValidator = thisKeywordToValidator.get("if"); + if (ifValidator != null) { + ifPathToSchemas = ifValidator.getIfPathToSchemas(arg, validationMetadata); + } for (Map.Entry entry: thisKeywordToValidator.entrySet()) { String jsonKeyword = entry.getKey(); if (disabledKeywords.contains(jsonKeyword)) { @@ -330,7 +343,8 @@ public static PathToSchemasMap validate( arg, validationMetadata, containsPathToSchemas, - patternPropertiesPathToSchemas + patternPropertiesPathToSchemas, + ifPathToSchemas ); if (otherPathToSchemas == null) { continue; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java index 16554a769d5..6d59bf27219 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/JsonSchemaInfo.java @@ -182,4 +182,9 @@ public JsonSchemaInfo prefixItems(List> prefixItems) this.prefixItems = prefixItems; return this; } + public @Nullable Class ifSchema = null; + public JsonSchemaInfo ifSchema(Class ifSchema) { + this.ifSchema = ifSchema; + return this; + } } \ No newline at end of file diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java index 3ff931654e5..41b4b85eb2e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/KeywordValidator.java @@ -12,7 +12,8 @@ public interface KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) throws ValidationException; default List getContainsPathToSchemas( @@ -28,4 +29,11 @@ default PathToSchemasMap getPatternPropertiesPathToSchemas( ) { return new PathToSchemasMap(); } + + default PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + return new PathToSchemasMap(); + } } \ No newline at end of file diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java index a234c2907bd..25482139fab 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxContainsValidator.java @@ -18,7 +18,8 @@ public MaxContainsValidator(int maxContains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java index 21d175aeb60..bda6fb43ece 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxItemsValidator.java @@ -18,7 +18,8 @@ public MaxItemsValidator(int maxItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java index 4309ad392ab..1a78623e0f4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxLengthValidator.java @@ -18,7 +18,8 @@ public MaxLengthValidator(int maxLength) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java index 0933d14568b..5928ec588ac 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaxPropertiesValidator.java @@ -19,7 +19,8 @@ public MaxPropertiesValidator(int maxProperties) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java index b7c08a08cb5..25faceb4022 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MaximumValidator.java @@ -18,7 +18,8 @@ public MaximumValidator(Number maximum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java index 70239e3fa3b..2f34127155e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinContainsValidator.java @@ -18,7 +18,8 @@ public MinContainsValidator(int minContains) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java index 5b452150aef..7c46cbe8f94 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinItemsValidator.java @@ -18,7 +18,8 @@ public MinItemsValidator(int minItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java index 9dbac1aeb11..7c92205a9cf 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinLengthValidator.java @@ -18,7 +18,8 @@ public MinLengthValidator(int minLength) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java index 24bb979c613..c52b16000d8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinPropertiesValidator.java @@ -19,7 +19,8 @@ public MinPropertiesValidator(int minProperties) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java index 34d6d27c5bf..dec192d47df 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MinimumValidator.java @@ -18,7 +18,8 @@ public MinimumValidator(Number minimum) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java index b5601e16fc9..15230b54275 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/MultipleOfValidator.java @@ -19,7 +19,8 @@ public MultipleOfValidator(BigDecimal multipleOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java index 5a9e59f530b..507c7f40fbc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/NotValidator.java @@ -23,7 +23,8 @@ public NotValidator(Class not) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas; try { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java index e0c51fe2a11..5bc4bbd297b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidator.java @@ -19,7 +19,8 @@ public OneOfValidator(List> oneOf) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedOneOfClasses = new ArrayList<>(); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java index fa486ddcdab..6104329139f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java @@ -21,7 +21,8 @@ public PatternPropertiesValidator(Map> patt @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java index 92678f1cca4..37e7a545711 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java @@ -19,7 +19,8 @@ public PatternValidator(Pattern pattern) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java index 4163833addb..a8b2bda2a21 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java @@ -18,7 +18,8 @@ public PrefixItemsValidator(List> prefixItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java index 94599597a13..9b7d50b28d8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java @@ -21,7 +21,8 @@ public PropertiesValidator(Map> properties) @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java index f4ec5ab6239..5154911d484 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java @@ -19,7 +19,8 @@ public PropertyNamesValidator(Class propertyNames) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java index 148be09c410..f68aef2b87a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/RequiredValidator.java @@ -21,7 +21,8 @@ public RequiredValidator(Set required) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java index fd827d49e13..f1fcd9d5cdd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/TypeValidator.java @@ -20,7 +20,8 @@ public TypeValidator(Set> type) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { Class argClass; if (arg == null) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java index 419823634e3..4cdbbe01060 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/UniqueItemsValidator.java @@ -20,7 +20,8 @@ public UniqueItemsValidator(boolean uniqueItems) { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java index e23076a75b1..7e6d7d09535 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/AdditionalPropertiesValidatorTest.java @@ -79,6 +79,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -110,6 +111,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -134,6 +136,7 @@ public void testIncorrectPropertyValueFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java index 69ffff00ce1..87a6bafc05f 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/FormatValidatorTest.java @@ -35,6 +35,7 @@ public void testIntFormatSucceedsWithFloat() { 1.0f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -48,6 +49,7 @@ public void testIntFormatFailsWithFloat() { 3.14f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -60,6 +62,7 @@ public void testIntFormatSucceedsWithInt() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -73,6 +76,7 @@ public void testInt32UnderMinFails() { -2147483649L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -85,6 +89,7 @@ public void testInt32InclusiveMinSucceeds() { -2147483648, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -98,6 +103,7 @@ public void testInt32InclusiveMaxSucceeds() { 2147483647, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -111,6 +117,7 @@ public void testInt32OverMaxFails() { 2147483648L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -124,6 +131,7 @@ public void testInt64UnderMinFails() { new BigInteger("-9223372036854775809"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -136,6 +144,7 @@ public void testInt64InclusiveMinSucceeds() { -9223372036854775808L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -149,6 +158,7 @@ public void testInt64InclusiveMaxSucceeds() { 9223372036854775807L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -163,6 +173,7 @@ public void testInt64OverMaxFails() { new BigInteger("9223372036854775808"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -175,6 +186,7 @@ public void testFloatUnderMinFails() { -3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -187,6 +199,7 @@ public void testFloatInclusiveMinSucceeds() { -3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -200,6 +213,7 @@ public void testFloatInclusiveMaxSucceeds() { 3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -213,6 +227,7 @@ public void testFloatOverMaxFails() { 3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -225,6 +240,7 @@ public void testDoubleUnderMinFails() { new BigDecimal("-1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -237,6 +253,7 @@ public void testDoubleInclusiveMinSucceeds() { -1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -250,6 +267,7 @@ public void testDoubleInclusiveMaxSucceeds() { 1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -263,6 +281,7 @@ public void testDoubleOverMaxFails() { new BigDecimal("1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -275,6 +294,7 @@ public void testInvalidNumberStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -287,6 +307,7 @@ public void testValidFloatNumberStringSucceeds() { "3.14", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -300,6 +321,7 @@ public void testValidIntNumberStringSucceeds() { "1", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -313,6 +335,7 @@ public void testInvalidDateStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -325,6 +348,7 @@ public void testValidDateStringSucceeds() { "2017-01-20", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -338,6 +362,7 @@ public void testInvalidDateTimeStringFails() { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -350,6 +375,7 @@ public void testValidDateTimeStringSucceeds() { "2017-07-21T17:32:28Z", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java index 2e3fcdb5129..f9c539091f3 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/ItemsValidatorTest.java @@ -38,6 +38,7 @@ public void testCorrectItemsSucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -69,6 +70,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -92,6 +94,7 @@ public void testIncorrectItemFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java index 9367dc3268d..ea58d090f1f 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidatorTest.java @@ -42,6 +42,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -75,6 +76,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -101,6 +103,7 @@ public void testIncorrectPropertyValueFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java index 53d0fced6ca..2c26d7c7954 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/RequiredValidatorTest.java @@ -41,6 +41,7 @@ public void testCorrectPropertySucceeds() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -64,6 +65,7 @@ public void testNotApplicableTypeReturnsNull() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -90,6 +92,7 @@ public void testIncorrectPropertyFails() { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java index 1dffdb7eb98..48433e51455 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/client/schemas/validation/TypeValidatorTest.java @@ -33,6 +33,7 @@ public void testValidateSucceeds() { "hi", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -54,6 +55,7 @@ public void testValidateFailsIntIsNotString() { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java index 3b96433ae9b..b2aadbde0fc 100644 --- a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java +++ b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java @@ -266,7 +266,7 @@ public JavaClientGenerator() { SchemaFeature.ExclusiveMaximum, SchemaFeature.ExclusiveMinimum, SchemaFeature.Format, - // SchemaFeature.If, + SchemaFeature.If, SchemaFeature.Items, SchemaFeature.MaxContains, SchemaFeature.MaxItems, @@ -579,6 +579,7 @@ public void processOpts() { keywordValidatorFiles.add("FormatValidator"); keywordValidatorFiles.add("FrozenList"); keywordValidatorFiles.add("FrozenMap"); + keywordValidatorFiles.add("IfValidator"); keywordValidatorFiles.add("IntegerEnumValidator"); keywordValidatorFiles.add("IntegerValueMethod"); keywordValidatorFiles.add("ItemsValidator"); diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs index e6cc59cc638..e832aa82553 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs @@ -123,6 +123,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements { {{#if prefixItems}} {{> src/main/java/packagename/components/schemas/SchemaClass/_prefixItems }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -132,15 +135,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements { } return instance; } -{{#if prefixItems}} - {{!> components/schemas/schema_cls/_prefix_items }} -{{/if}} {{#if hasDiscriminatorWithNonEmptyMapping}} {{!> components/schemas/schema_cls/_discriminator }} {{/if}} -{{#if if_}} - {{!> components/schemas/schema_cls/_if }} -{{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_boolean.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_boolean.hbs index df2ae1fdf0c..067ffb074e5 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_boolean.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_boolean.hbs @@ -41,6 +41,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements B {{#if constInfo}} {{> src/main/java/packagename/components/schemas/SchemaClass/_const }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -50,9 +53,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements B } return instance; } -{{#if if_}} - {{!> components/schemas/schema_cls/_if }} -{{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_list.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_list.hbs index 8fba1860d25..7125f76bafd 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_list.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_list.hbs @@ -56,6 +56,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements L {{#if prefixItems}} {{> src/main/java/packagename/components/schemas/SchemaClass/_prefixItems }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -65,9 +68,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements L } return instance; } - {{#if if_}} - {{!> components/schemas/schema_cls/_if }} - {{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_map.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_map.hbs index ff80da53117..c4d7ec4419a 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_map.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_map.hbs @@ -59,6 +59,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements M {{#if patternProperties}} {{> src/main/java/packagename/components/schemas/SchemaClass/_patternProperties }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -71,9 +74,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements M {{#if hasDiscriminatorWithNonEmptyMapping}} {{!> components/schemas/schema_cls/_discriminator }} {{/if}} - {{#if if_}} - {{!> components/schemas/schema_cls/_if }} - {{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_null.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_null.hbs index 166f3640f09..60de29faba0 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_null.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_null.hbs @@ -41,6 +41,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements N {{#if constInfo}} {{> src/main/java/packagename/components/schemas/SchemaClass/_const }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -50,9 +53,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements N } return instance; } -{{#if if_}} - {{!> components/schemas/schema_cls/_if }} -{{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_number.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_number.hbs index 459ea277fa3..3d5f5bcbe0c 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_number.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_number.hbs @@ -59,6 +59,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements { {{#if constInfo}} {{> src/main/java/packagename/components/schemas/SchemaClass/_const }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -68,9 +71,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements { } return instance; } -{{#if if_}} - {{!> components/schemas/schema_cls/_if }} -{{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_string.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_string.hbs index 9ce7e6df581..56391283885 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_string.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_Schema_string.hbs @@ -53,6 +53,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements S {{#if constInfo}} {{> src/main/java/packagename/components/schemas/SchemaClass/_const }} {{/if}} + {{#if if_}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} + {{/if}} ); } @@ -62,9 +65,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements S } return instance; } -{{#if if_}} - {{!> components/schemas/schema_cls/_if }} -{{/if}} {{#if then}} {{!> components/schemas/schema_cls/_then }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_if.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_if.hbs new file mode 100644 index 00000000000..249c6e24556 --- /dev/null +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_if.hbs @@ -0,0 +1,17 @@ +{{#if forDocs}} + {{#with if_}} + {{#if refInfo.refClass}} + {{#if refInfo.refModule}} +if = [{{refInfo.refModule}}.{{refInfo.refClass}}.class]({{docRoot}}{{refInfo.ref.pathFromDocRoot}}.md#{{refInfo.ref.jsonPathPiece.kebabCase}}) + {{~else}} +if = [{{refInfo.refClass}}.class](#{{refInfo.ref.jsonPathPiece.kebabCase}}) + {{~/if}} + {{else}} +if = [{{jsonPathPiece.pascalCase}}.class](#{{jsonPathPiece.kebabCase}}) + {{~/if}} + {{~/with}} +{{else}} + {{#with if_}} +.ifSchema({{#if refInfo.refClass}}{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}}{{else}}{{jsonPathPiece.pascalCase}}{{/if}}.class) + {{/with}} +{{/if}} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_fields_field.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_fields_field.hbs index 830c439869d..9db6927dd1f 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_fields_field.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_fields_field.hbs @@ -97,3 +97,6 @@ {{#if prefixItems}} | List> | {{> src/main/java/packagename/components/schemas/SchemaClass/_prefixItems }} | {{/if}} +{{#if if_}} +| Class | {{> src/main/java/packagename/components/schemas/SchemaClass/_if }} | +{{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/AdditionalPropertiesValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/AdditionalPropertiesValidator.hbs index a663139ed25..643b6496c4b 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/AdditionalPropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/AdditionalPropertiesValidator.hbs @@ -20,7 +20,8 @@ public class AdditionalPropertiesValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/AllOfValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/AllOfValidator.hbs index 2b854c663a7..505d16c9096 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/AllOfValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/AllOfValidator.hbs @@ -16,7 +16,8 @@ public class AllOfValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); for(Class allOfClass: allOf) { diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/AnyOfValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/AnyOfValidator.hbs index b8388f6b1ea..5c838eea6e8 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/AnyOfValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/AnyOfValidator.hbs @@ -19,7 +19,8 @@ public class AnyOfValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedAnyOfClasses = new ArrayList<>(); diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/ConstValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/ConstValidator.hbs index dd7ce482763..26874dbc717 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/ConstValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/ConstValidator.hbs @@ -20,7 +20,8 @@ public class ConstValidator extends BigDecimalValidator implements KeywordValida @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { BigDecimal castArg = getBigDecimal((Number) arg); diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/ContainsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/ContainsValidator.hbs index 3fe088160e3..664d34edcf5 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/ContainsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/ContainsValidator.hbs @@ -19,7 +19,8 @@ public class ContainsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentRequiredValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentRequiredValidator.hbs index d2e4cf54127..d100dddd2af 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentRequiredValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentRequiredValidator.hbs @@ -21,7 +21,8 @@ public class DependentRequiredValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentSchemasValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentSchemasValidator.hbs index ccba0e0ccb0..5e78857a6f8 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentSchemasValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/DependentSchemasValidator.hbs @@ -21,7 +21,8 @@ public class DependentSchemasValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/EnumValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/EnumValidator.hbs index f01d44a9283..9ebbb8359be 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/EnumValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/EnumValidator.hbs @@ -25,7 +25,8 @@ public class EnumValidator extends BigDecimalValidator implements KeywordValidat @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (enumValues.isEmpty()) { throw new ValidationException("No value can match enum because enum is empty"); diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMaximumValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMaximumValidator.hbs index 0bd17793d00..933c3bbd8fe 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMaximumValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMaximumValidator.hbs @@ -18,7 +18,8 @@ public class ExclusiveMaximumValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMinimumValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMinimumValidator.hbs index 0769eb5a234..8b6ddb286c5 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMinimumValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/ExclusiveMinimumValidator.hbs @@ -18,7 +18,8 @@ public class ExclusiveMinimumValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/FormatValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/FormatValidator.hbs index a72c29dc9a7..e3a03aebd6a 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/FormatValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/FormatValidator.hbs @@ -149,7 +149,8 @@ public class FormatValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (arg instanceof Number) { validateNumericFormat( diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/IfValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/IfValidator.hbs new file mode 100644 index 00000000000..5b174883b2b --- /dev/null +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/IfValidator.hbs @@ -0,0 +1,56 @@ +package {{{packageName}}}.schemas.validation; + +import {{{packageName}}}.exceptions.ValidationException; +import {{{packageName}}}.exceptions.InvalidTypeException; +import org.checkerframework.checker.nullness.qual.Nullable; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class IfValidator implements KeywordValidator { + public final Class ifSchema; + + public IfValidator(Class ifSchema) { + this.ifSchema = ifSchema; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List containsPathToSchemas, + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas + ) { + if (ifPathToSchemas == null) { + throw new ValidationException("Invalid type for ifPathToSchemas"); + } + /* + if is false use case + ifPathToSchemas == {} + no need to add any data to pathToSchemas + + if true, then true -> true for whole schema + so validate_then will add ifPathToSchemas data to pathToSchemas + */ + return null; + } + + public PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + JsonSchema ifSchemaInstance = JsonSchemaFactory.getInstance(ifSchema); + PathToSchemasMap pathToSchemas = new PathToSchemasMap(); + try { + var otherPathToSchemas = JsonSchema.validate(ifSchemaInstance, arg, validationMetadata); + pathToSchemas.update(otherPathToSchemas); + } catch (ValidationException | InvalidTypeException ignored) {} + return pathToSchemas; + } +} diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/ItemsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/ItemsValidator.hbs index 6baca87231c..8f97f9bff13 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/ItemsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/ItemsValidator.hbs @@ -18,7 +18,8 @@ public class ItemsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchema.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchema.hbs index cc15f405870..e0af16453e0 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchema.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchema.hbs @@ -54,6 +54,7 @@ public abstract class JsonSchema { public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; public @Nullable List> prefixItems; + public final @Nullable Class ifSchema; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -292,6 +293,13 @@ public abstract class JsonSchema { new PrefixItemsValidator(this.prefixItems) ); } + this.ifSchema = jsonSchemaInfo.ifSchema; + if (this.ifSchema != null) { + keywordToValidator.put( + "if", + new IfValidator(this.ifSchema) + ); + } this.keywordToValidator = keywordToValidator; } @@ -316,6 +324,11 @@ public abstract class JsonSchema { if (patternPropertiesValidator != null) { patternPropertiesPathToSchemas = patternPropertiesValidator.getPatternPropertiesPathToSchemas(arg, validationMetadata); } + @Nullable PathToSchemasMap ifPathToSchemas = null; + KeywordValidator ifValidator = thisKeywordToValidator.get("if"); + if (ifValidator != null) { + ifPathToSchemas = ifValidator.getIfPathToSchemas(arg, validationMetadata); + } for (Map.Entry entry: thisKeywordToValidator.entrySet()) { String jsonKeyword = entry.getKey(); if (disabledKeywords.contains(jsonKeyword)) { @@ -330,7 +343,8 @@ public abstract class JsonSchema { arg, validationMetadata, containsPathToSchemas, - patternPropertiesPathToSchemas + patternPropertiesPathToSchemas, + ifPathToSchemas ); if (otherPathToSchemas == null) { continue; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchemaInfo.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchemaInfo.hbs index 90e1935f18d..4c5f6638e62 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchemaInfo.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/JsonSchemaInfo.hbs @@ -182,4 +182,9 @@ public class JsonSchemaInfo { this.prefixItems = prefixItems; return this; } + public @Nullable Class ifSchema = null; + public JsonSchemaInfo ifSchema(Class ifSchema) { + this.ifSchema = ifSchema; + return this; + } } \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/KeywordValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/KeywordValidator.hbs index 88d7d629c71..381228b3282 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/KeywordValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/KeywordValidator.hbs @@ -12,7 +12,8 @@ public interface KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) throws ValidationException; default List getContainsPathToSchemas( @@ -28,4 +29,11 @@ public interface KeywordValidator { ) { return new PathToSchemasMap(); } + + default PathToSchemasMap getIfPathToSchemas( + @Nullable Object arg, + ValidationMetadata validationMetadata + ) { + return new PathToSchemasMap(); + } } \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxContainsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxContainsValidator.hbs index 21f5cacfdf7..4308f9e46e9 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxContainsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxContainsValidator.hbs @@ -18,7 +18,8 @@ public class MaxContainsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxItemsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxItemsValidator.hbs index 1a10c405461..98591a67fd0 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxItemsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxItemsValidator.hbs @@ -18,7 +18,8 @@ public class MaxItemsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxLengthValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxLengthValidator.hbs index 57c0bd7d43b..fb970be06fb 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxLengthValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxLengthValidator.hbs @@ -18,7 +18,8 @@ public class MaxLengthValidator extends LengthValidator implements KeywordValida @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxPropertiesValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxPropertiesValidator.hbs index 5da40fbdbb2..c3c398dd1e7 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxPropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaxPropertiesValidator.hbs @@ -19,7 +19,8 @@ public class MaxPropertiesValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaximumValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaximumValidator.hbs index cdbf12e8a53..67afa868a6f 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MaximumValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MaximumValidator.hbs @@ -18,7 +18,8 @@ public class MaximumValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinContainsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinContainsValidator.hbs index 3be311d9c06..0dfa4ff0795 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinContainsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinContainsValidator.hbs @@ -18,7 +18,8 @@ public class MinContainsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinItemsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinItemsValidator.hbs index 91bbe5aae6f..9216734c461 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinItemsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinItemsValidator.hbs @@ -18,7 +18,8 @@ public class MinItemsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinLengthValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinLengthValidator.hbs index 15a5b461493..925f83e5a3c 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinLengthValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinLengthValidator.hbs @@ -18,7 +18,8 @@ public class MinLengthValidator extends LengthValidator implements KeywordValida @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinPropertiesValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinPropertiesValidator.hbs index 626a62f39a7..80ea144457f 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinPropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinPropertiesValidator.hbs @@ -19,7 +19,8 @@ public class MinPropertiesValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinimumValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinimumValidator.hbs index 0fb2e9655bb..55b9ed98cc2 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MinimumValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MinimumValidator.hbs @@ -18,7 +18,8 @@ public class MinimumValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/MultipleOfValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/MultipleOfValidator.hbs index 69c4e69b012..df3ed47bfc3 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/MultipleOfValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/MultipleOfValidator.hbs @@ -19,7 +19,8 @@ public class MultipleOfValidator extends BigDecimalValidator implements KeywordV @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Number)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/NotValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/NotValidator.hbs index 0d94f56e4a1..3ac7c4b3507 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/NotValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/NotValidator.hbs @@ -23,7 +23,8 @@ public class NotValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas; try { diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/OneOfValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/OneOfValidator.hbs index 249e16a37c1..a55f2f7b8ab 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/OneOfValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/OneOfValidator.hbs @@ -19,7 +19,8 @@ public class OneOfValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { PathToSchemasMap pathToSchemas = new PathToSchemasMap(); List> validatedOneOfClasses = new ArrayList<>(); diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternPropertiesValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternPropertiesValidator.hbs index f63d9e740ec..b67f6f1c97e 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternPropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternPropertiesValidator.hbs @@ -21,7 +21,8 @@ public class PatternPropertiesValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternValidator.hbs index 3d8c157a278..6cdc7f21a77 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/PatternValidator.hbs @@ -19,7 +19,8 @@ public class PatternValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof String)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/PrefixItemsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/PrefixItemsValidator.hbs index 58124290093..a938edfd38b 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/PrefixItemsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/PrefixItemsValidator.hbs @@ -18,7 +18,8 @@ public class PrefixItemsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List listArg)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertiesValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertiesValidator.hbs index 8d80522f127..0a60eefd072 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertiesValidator.hbs @@ -21,7 +21,8 @@ public class PropertiesValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map mapArg)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertyNamesValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertyNamesValidator.hbs index 78b9241fe64..adeea3fe3bf 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertyNamesValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/PropertyNamesValidator.hbs @@ -19,7 +19,8 @@ public class PropertyNamesValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/RequiredValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/RequiredValidator.hbs index a8588e19e80..33d8e66bf6d 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/RequiredValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/RequiredValidator.hbs @@ -21,7 +21,8 @@ public class RequiredValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof Map)) { return null; diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/TypeValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/TypeValidator.hbs index a505eab1c62..c8d37de1477 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/TypeValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/TypeValidator.hbs @@ -20,7 +20,8 @@ public class TypeValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { Class argClass; if (arg == null) { diff --git a/src/main/resources/java/src/main/java/packagename/schemas/validation/UniqueItemsValidator.hbs b/src/main/resources/java/src/main/java/packagename/schemas/validation/UniqueItemsValidator.hbs index 2cf70f5c6e1..06bce39321b 100644 --- a/src/main/resources/java/src/main/java/packagename/schemas/validation/UniqueItemsValidator.hbs +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/UniqueItemsValidator.hbs @@ -20,7 +20,8 @@ public class UniqueItemsValidator implements KeywordValidator { @Nullable Object arg, ValidationMetadata validationMetadata, @Nullable List containsPathToSchemas, - @Nullable PathToSchemasMap patternPropertiesPathToSchemas + @Nullable PathToSchemasMap patternPropertiesPathToSchemas, + @Nullable PathToSchemasMap ifPathToSchemas ) { if (!(arg instanceof List)) { return null; diff --git a/src/main/resources/java/src/test/java/packagename/schemas/validation/AdditionalPropertiesValidatorTest.hbs b/src/main/resources/java/src/test/java/packagename/schemas/validation/AdditionalPropertiesValidatorTest.hbs index 479ff44de01..2e1a80bc048 100644 --- a/src/main/resources/java/src/test/java/packagename/schemas/validation/AdditionalPropertiesValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/packagename/schemas/validation/AdditionalPropertiesValidatorTest.hbs @@ -79,6 +79,7 @@ public class AdditionalPropertiesValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -110,6 +111,7 @@ public class AdditionalPropertiesValidatorTest { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -134,6 +136,7 @@ public class AdditionalPropertiesValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/src/main/resources/java/src/test/java/packagename/schemas/validation/FormatValidatorTest.hbs b/src/main/resources/java/src/test/java/packagename/schemas/validation/FormatValidatorTest.hbs index f086fec751c..c9027395af2 100644 --- a/src/main/resources/java/src/test/java/packagename/schemas/validation/FormatValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/packagename/schemas/validation/FormatValidatorTest.hbs @@ -35,6 +35,7 @@ public class FormatValidatorTest { 1.0f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -48,6 +49,7 @@ public class FormatValidatorTest { 3.14f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -60,6 +62,7 @@ public class FormatValidatorTest { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -73,6 +76,7 @@ public class FormatValidatorTest { -2147483649L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -85,6 +89,7 @@ public class FormatValidatorTest { -2147483648, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -98,6 +103,7 @@ public class FormatValidatorTest { 2147483647, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -111,6 +117,7 @@ public class FormatValidatorTest { 2147483648L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -124,6 +131,7 @@ public class FormatValidatorTest { new BigInteger("-9223372036854775809"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -136,6 +144,7 @@ public class FormatValidatorTest { -9223372036854775808L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -149,6 +158,7 @@ public class FormatValidatorTest { 9223372036854775807L, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -163,6 +173,7 @@ public class FormatValidatorTest { new BigInteger("9223372036854775808"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -175,6 +186,7 @@ public class FormatValidatorTest { -3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -187,6 +199,7 @@ public class FormatValidatorTest { -3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -200,6 +213,7 @@ public class FormatValidatorTest { 3.4028234663852886e+38f, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -213,6 +227,7 @@ public class FormatValidatorTest { 3.402823466385289e+38d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -225,6 +240,7 @@ public class FormatValidatorTest { new BigDecimal("-1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -237,6 +253,7 @@ public class FormatValidatorTest { -1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -250,6 +267,7 @@ public class FormatValidatorTest { 1.7976931348623157E+308d, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -263,6 +281,7 @@ public class FormatValidatorTest { new BigDecimal("1.7976931348623157082e+308"), validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -275,6 +294,7 @@ public class FormatValidatorTest { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -287,6 +307,7 @@ public class FormatValidatorTest { "3.14", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -300,6 +321,7 @@ public class FormatValidatorTest { "1", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -313,6 +335,7 @@ public class FormatValidatorTest { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -325,6 +348,7 @@ public class FormatValidatorTest { "2017-01-20", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -338,6 +362,7 @@ public class FormatValidatorTest { "abc", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } @@ -350,6 +375,7 @@ public class FormatValidatorTest { "2017-07-21T17:32:28Z", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); diff --git a/src/main/resources/java/src/test/java/packagename/schemas/validation/ItemsValidatorTest.hbs b/src/main/resources/java/src/test/java/packagename/schemas/validation/ItemsValidatorTest.hbs index 64b81a509e2..84f2ebfc8b3 100644 --- a/src/main/resources/java/src/test/java/packagename/schemas/validation/ItemsValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/packagename/schemas/validation/ItemsValidatorTest.hbs @@ -38,6 +38,7 @@ public class ItemsValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -69,6 +70,7 @@ public class ItemsValidatorTest { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -92,6 +94,7 @@ public class ItemsValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/src/main/resources/java/src/test/java/packagename/schemas/validation/PropertiesValidatorTest.hbs b/src/main/resources/java/src/test/java/packagename/schemas/validation/PropertiesValidatorTest.hbs index 3c78216d94e..05c565fabb9 100644 --- a/src/main/resources/java/src/test/java/packagename/schemas/validation/PropertiesValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/packagename/schemas/validation/PropertiesValidatorTest.hbs @@ -42,6 +42,7 @@ public class PropertiesValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); if (pathToSchemas == null) { @@ -75,6 +76,7 @@ public class PropertiesValidatorTest { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -101,6 +103,7 @@ public class PropertiesValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/src/main/resources/java/src/test/java/packagename/schemas/validation/RequiredValidatorTest.hbs b/src/main/resources/java/src/test/java/packagename/schemas/validation/RequiredValidatorTest.hbs index 2389c80a55f..746409eff44 100644 --- a/src/main/resources/java/src/test/java/packagename/schemas/validation/RequiredValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/packagename/schemas/validation/RequiredValidatorTest.hbs @@ -41,6 +41,7 @@ public class RequiredValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -64,6 +65,7 @@ public class RequiredValidatorTest { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemas); @@ -90,6 +92,7 @@ public class RequiredValidatorTest { arg, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/src/main/resources/java/src/test/java/packagename/schemas/validation/TypeValidatorTest.hbs b/src/main/resources/java/src/test/java/packagename/schemas/validation/TypeValidatorTest.hbs index ff19572c628..3ce4264cd1c 100644 --- a/src/main/resources/java/src/test/java/packagename/schemas/validation/TypeValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/packagename/schemas/validation/TypeValidatorTest.hbs @@ -33,6 +33,7 @@ public class TypeValidatorTest { "hi", validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() ); assertNull(pathToSchemasMap); @@ -54,6 +55,7 @@ public class TypeValidatorTest { 1, validationMetadata, new ArrayList<>(), + new PathToSchemasMap(), new PathToSchemasMap() )); } diff --git a/src/test/resources/3_1/unit_test_spec/3_1_0_unit_test_spec_nopaths.yaml b/src/test/resources/3_1/unit_test_spec/3_1_0_unit_test_spec_nopaths.yaml index 53a18f8c67c..1d9c8726387 100644 --- a/src/test/resources/3_1/unit_test_spec/3_1_0_unit_test_spec_nopaths.yaml +++ b/src/test/resources/3_1/unit_test_spec/3_1_0_unit_test_spec_nopaths.yaml @@ -10,6 +10,11 @@ tags: [] paths: {} components: schemas: + NonAsciiPatternWithAdditionalproperties: + $schema: https://json-schema.org/draft/2020-12/schema + patternProperties: + "^\xE1": {} + additionalProperties: false AdditionalpropertiesWithSchema: $schema: https://json-schema.org/draft/2020-12/schema properties: @@ -304,6 +309,10 @@ components: DurationFormat: $schema: https://json-schema.org/draft/2020-12/schema format: duration + IgnoreIfWithoutThenOrElse: + $schema: https://json-schema.org/draft/2020-12/schema + if: + const: 0 NestedItems: $schema: https://json-schema.org/draft/2020-12/schema type: array @@ -670,6 +679,19 @@ components: - type: boolean uniqueItems: false x-schema-test-examples: + NonAsciiPatternWithAdditionalproperties: + MatchingThePatternIsValid: + description: matching the pattern is valid + data: + "\xE1rm\xE1nyos": 2 + valid: true + comment: null + NotMatchingThePatternIsInvalid: + description: not matching the pattern is invalid + data: + "\xE9lm\xE9ny": 2 + valid: false + comment: null AdditionalpropertiesWithSchema: NoAdditionalPropertiesIsValid: description: no additional properties is valid @@ -2145,6 +2167,17 @@ components: data: PT1D valid: true comment: null + IgnoreIfWithoutThenOrElse: + ValidWhenValidAgainstLoneIf: + description: valid when valid against lone if + data: 0 + valid: true + comment: null + ValidWhenInvalidAgainstLoneIf: + description: valid when invalid against lone if + data: hello + valid: true + comment: null NestedItems: ValidNestedArray: description: valid nested array diff --git a/src/test/resources/3_1/unit_test_spec/spec_writer.py b/src/test/resources/3_1/unit_test_spec/spec_writer.py index a3a83e150d0..7faaef919d8 100644 --- a/src/test/resources/3_1/unit_test_spec/spec_writer.py +++ b/src/test/resources/3_1/unit_test_spec/spec_writer.py @@ -701,7 +701,6 @@ def write_openapi_spec(): openapi.tags = [] removed_cases = { 'UnevaluateditemsDependsOnMultipleNestedContains', - 'IgnoreIfWithoutThenOrElse', 'IfAndThenWithoutElse', 'IfAndElseWithoutThen', 'ValidateAgainstCorrectBranchThenVsElse', @@ -709,7 +708,6 @@ def write_openapi_spec(): 'IfAppearsAtTheEndWhenSerializedKeywordProcessingSequence', 'IgnoreThenWithoutIf', 'IgnoreElseWithoutIf', - 'NonAsciiPatternWithAdditionalproperties', 'UnevaluateditemsAsSchema', 'UnevaluateditemsWithNullInstanceElements', 'UnevaluatedpropertiesNotAffectedByPropertynames',