-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java, refactoring to simplify schema validate (#370)
* Updates many validators to accept a single input * Updates remaining keywordValidators * Fixes enum validator * Adds vars to fix nullness checks * Fixes TypeValidatorTest * Fixes AdditionalPropertiesValidatorTest * Fixes PropertiesValidatorTest * Updates ItemsValidatorTest * Updates FormatValidatorTest * Extracts getContainsPathToSchemas * Extracts getPatternPropertiesPathToSchemas * Extracts getIfPathToSchemas * Updates 5 validators * Fixes AdditionalPropertiesValidatorTest * Updates ItemsValidatorTest * Updates RequiredValidatorTest * Updates TypeValidatorTest * Updates PropertiesValidatorTest * Adds final modifers to schema data * Adds functionalinterface annotation * Samples regen
- Loading branch information
Showing
176 changed files
with
3,428 additions
and
4,936 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 6 additions & 17 deletions
23
...va/src/main/java/org/openapijsonschematools/client/schemas/validation/AllOfValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,21 @@ | ||
package org.openapijsonschematools.client.schemas.validation; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
import java.util.List; | ||
|
||
public class AllOfValidator implements KeywordValidator { | ||
public final List<Class<? extends JsonSchema>> allOf; | ||
|
||
public AllOfValidator(List<Class<? extends JsonSchema>> allOf) { | ||
this.allOf = allOf; | ||
} | ||
|
||
@Override | ||
public @Nullable PathToSchemasMap validate( | ||
JsonSchema schema, | ||
@Nullable Object arg, | ||
ValidationMetadata validationMetadata, | ||
@Nullable List<PathToSchemasMap> containsPathToSchemas, | ||
@Nullable PathToSchemasMap patternPropertiesPathToSchemas, | ||
@Nullable PathToSchemasMap ifPathToSchemas | ||
ValidationData data | ||
) { | ||
var allOf = data.schema().allOf; | ||
if (allOf == null) { | ||
return null; | ||
} | ||
PathToSchemasMap pathToSchemas = new PathToSchemasMap(); | ||
for(Class<? extends JsonSchema> allOfClass: allOf) { | ||
JsonSchema allOfSchema = JsonSchemaFactory.getInstance(allOfClass); | ||
PathToSchemasMap otherPathToSchemas = JsonSchema.validate(allOfSchema, arg, validationMetadata); | ||
PathToSchemasMap otherPathToSchemas = JsonSchema.validate(allOfSchema, data.arg(), data.validationMetadata()); | ||
pathToSchemas.update(otherPathToSchemas); | ||
} | ||
return pathToSchemas; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.