-
-
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.
* Turns on prefixItems test cases * java 310 sample gen * Adds PrefixItemsValidator validate functionality * Adds listItemSchema * Fixes most java tests * FIxes java tests, sample+docs regen * Python array types updated * Adjusts python Unpack usage in tuples
- Loading branch information
Showing
95 changed files
with
4,457 additions
and
142 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
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
46 changes: 46 additions & 0 deletions
46
.../main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.openapijsonschematools.client.schemas.validation; | ||
|
||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class PrefixItemsValidator implements KeywordValidator { | ||
public final List<Class<? extends JsonSchema>> prefixItems; | ||
|
||
public PrefixItemsValidator(List<Class<? extends JsonSchema>> prefixItems) { | ||
this.prefixItems = prefixItems; | ||
} | ||
|
||
@Override | ||
public @Nullable PathToSchemasMap validate( | ||
JsonSchema schema, | ||
@Nullable Object arg, | ||
ValidationMetadata validationMetadata, | ||
@Nullable List<PathToSchemasMap> containsPathToSchemas, | ||
@Nullable PathToSchemasMap patternPropertiesPathToSchemas | ||
) { | ||
if (!(arg instanceof List<?> listArg)) { | ||
return null; | ||
} | ||
if (listArg.isEmpty()) { | ||
return null; | ||
} | ||
PathToSchemasMap pathToSchemas = new PathToSchemasMap(); | ||
int maxIndex = Math.min(listArg.size(), prefixItems.size()); | ||
for (int i=0; i < maxIndex; i++) { | ||
List<Object> itemPathToItem = new ArrayList<>(validationMetadata.pathToItem()); | ||
itemPathToItem.add(i); | ||
ValidationMetadata itemValidationMetadata = new ValidationMetadata( | ||
itemPathToItem, | ||
validationMetadata.configuration(), | ||
validationMetadata.validatedPathToSchemas(), | ||
validationMetadata.seenClasses() | ||
); | ||
JsonSchema itemsSchema = JsonSchemaFactory.getInstance(prefixItems.get(i)); | ||
PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, listArg.get(i), itemValidationMetadata); | ||
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
Oops, something went wrong.