diff --git a/docs/generators/java.md b/docs/generators/java.md index a620205f723..34b9d793e6a 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -305,7 +305,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |OneOf|✓|OAS3 |Pattern|✓|OAS2,OAS3 |PatternProperties|✓|OAS3 -|PrefixItems|✗|OAS3 +|PrefixItems|✓|OAS3 |Properties|✓|OAS2,OAS3 |PropertyNames|✓|OAS3 |Ref|✓|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 cb9d2945326..83ee5fdf66f 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 @@ -259,6 +259,7 @@ src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidato src/main/java/org/openapijsonschematools/client/schemas/validation/PathToSchemasMap.java src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java +src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyEntry.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java 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 bf3ee6ecf15..cf66ce04470 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 @@ -20,13 +20,16 @@ public ItemsValidator(Class items) { @Nullable List containsPathToSchemas, @Nullable PathToSchemasMap patternPropertiesPathToSchemas ) { - if (!(arg instanceof List)) { + if (!(arg instanceof List listArg)) { + return null; + } + if (listArg.isEmpty()) { return null; } PathToSchemasMap pathToSchemas = new PathToSchemasMap(); - // todo add handling for prefixItems - int i = 0; - for(Object itemValue: (List) arg) { + int minIndex = schema.prefixItems != null ? schema.prefixItems.size() : 0; + JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); + for(int i = minIndex; i < listArg.size(); i++) { List itemPathToItem = new ArrayList<>(validationMetadata.pathToItem()); itemPathToItem.add(i); ValidationMetadata itemValidationMetadata = new ValidationMetadata( @@ -35,15 +38,12 @@ public ItemsValidator(Class items) { validationMetadata.validatedPathToSchemas(), validationMetadata.seenClasses() ); - JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); if (itemValidationMetadata.validationRanEarlier(itemsSchema)) { // todo add_deeper_validated_schemas - i +=1; continue; } - PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, itemValue, itemValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, listArg.get(i), itemValidationMetadata); pathToSchemas.update(otherPathToSchemas); - i += 1; } return pathToSchemas; } 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 e567b7f5dc2..33fc4a78e91 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 @@ -53,6 +53,7 @@ public abstract class JsonSchema { public @Nullable Map> dependentRequired; public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; + public @Nullable List> prefixItems; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -284,6 +285,13 @@ protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { new PatternPropertiesValidator(this.patternProperties) ); } + this.prefixItems = jsonSchemaInfo.prefixItems; + if (this.prefixItems != null) { + keywordToValidator.put( + "prefixItems", + new PrefixItemsValidator(this.prefixItems) + ); + } this.keywordToValidator = keywordToValidator; } 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 45c911b0c18..16554a769d5 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 @@ -177,4 +177,9 @@ public JsonSchemaInfo patternProperties(Map this.patternProperties = patternProperties; return this; } + public @Nullable List> prefixItems = null; + public JsonSchemaInfo prefixItems(List> prefixItems) { + this.prefixItems = prefixItems; + 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/PrefixItemsValidator.java b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java new file mode 100644 index 00000000000..4163833addb --- /dev/null +++ b/samples/client/3_0_3_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java @@ -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> prefixItems; + + public PrefixItemsValidator(List> prefixItems) { + this.prefixItems = prefixItems; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List 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 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; + } +} 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 1aa3d5b1e04..502dec2548c 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 @@ -1,4 +1,6 @@ README.md +docs/components/schemas/ASchemaGivenForPrefixitems.md +docs/components/schemas/AdditionalItemsAreAllowedByDefault.md docs/components/schemas/AdditionalpropertiesAreAllowedByDefault.md docs/components/schemas/AdditionalpropertiesCanExistByItself.md docs/components/schemas/AdditionalpropertiesDoesNotLookInApplicators.md @@ -51,6 +53,7 @@ docs/components/schemas/Ipv6Format.md docs/components/schemas/IriFormat.md docs/components/schemas/IriReferenceFormat.md docs/components/schemas/ItemsContains.md +docs/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.md docs/components/schemas/ItemsWithNullInstanceElements.md docs/components/schemas/JsonPointerFormat.md docs/components/schemas/MaxcontainsWithoutContainsIsIgnored.md @@ -90,6 +93,8 @@ docs/components/schemas/PatternIsNotAnchored.md docs/components/schemas/PatternValidation.md docs/components/schemas/PatternpropertiesValidatesPropertiesMatchingARegex.md docs/components/schemas/PatternpropertiesWithNullValuedInstanceProperties.md +docs/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.md +docs/components/schemas/PrefixitemsWithNullInstanceElements.md docs/components/schemas/PropertiesPatternpropertiesAdditionalpropertiesInteraction.md docs/components/schemas/PropertiesWhoseNamesAreJavascriptObjectPropertyNames.md docs/components/schemas/PropertiesWithEscapedCharacters.md @@ -116,13 +121,17 @@ docs/components/schemas/UnevaluateditemsWithItems.md docs/components/schemas/UnevaluatedpropertiesWithAdjacentAdditionalproperties.md docs/components/schemas/UnevaluatedpropertiesWithNullValuedInstanceProperties.md docs/components/schemas/UniqueitemsFalseValidation.md +docs/components/schemas/UniqueitemsFalseWithAnArrayOfItems.md docs/components/schemas/UniqueitemsValidation.md +docs/components/schemas/UniqueitemsWithAnArrayOfItems.md docs/components/schemas/UriFormat.md docs/components/schemas/UriReferenceFormat.md docs/components/schemas/UriTemplateFormat.md docs/components/schemas/UuidFormat.md docs/servers/Server0.md pom.xml +src/main/java/org/openapijsonschematools/client/components/schemas/ASchemaGivenForPrefixitems.java +src/main/java/org/openapijsonschematools/client/components/schemas/AdditionalItemsAreAllowedByDefault.java src/main/java/org/openapijsonschematools/client/components/schemas/AdditionalpropertiesAreAllowedByDefault.java src/main/java/org/openapijsonschematools/client/components/schemas/AdditionalpropertiesCanExistByItself.java src/main/java/org/openapijsonschematools/client/components/schemas/AdditionalpropertiesDoesNotLookInApplicators.java @@ -175,6 +184,7 @@ src/main/java/org/openapijsonschematools/client/components/schemas/Ipv6Format.ja src/main/java/org/openapijsonschematools/client/components/schemas/IriFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/IriReferenceFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/ItemsContains.java +src/main/java/org/openapijsonschematools/client/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.java src/main/java/org/openapijsonschematools/client/components/schemas/ItemsWithNullInstanceElements.java src/main/java/org/openapijsonschematools/client/components/schemas/JsonPointerFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/MaxcontainsWithoutContainsIsIgnored.java @@ -214,6 +224,8 @@ src/main/java/org/openapijsonschematools/client/components/schemas/PatternIsNotA src/main/java/org/openapijsonschematools/client/components/schemas/PatternValidation.java src/main/java/org/openapijsonschematools/client/components/schemas/PatternpropertiesValidatesPropertiesMatchingARegex.java src/main/java/org/openapijsonschematools/client/components/schemas/PatternpropertiesWithNullValuedInstanceProperties.java +src/main/java/org/openapijsonschematools/client/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.java +src/main/java/org/openapijsonschematools/client/components/schemas/PrefixitemsWithNullInstanceElements.java src/main/java/org/openapijsonschematools/client/components/schemas/PropertiesPatternpropertiesAdditionalpropertiesInteraction.java src/main/java/org/openapijsonschematools/client/components/schemas/PropertiesWhoseNamesAreJavascriptObjectPropertyNames.java src/main/java/org/openapijsonschematools/client/components/schemas/PropertiesWithEscapedCharacters.java @@ -240,7 +252,9 @@ src/main/java/org/openapijsonschematools/client/components/schemas/Unevaluatedit src/main/java/org/openapijsonschematools/client/components/schemas/UnevaluatedpropertiesWithAdjacentAdditionalproperties.java src/main/java/org/openapijsonschematools/client/components/schemas/UnevaluatedpropertiesWithNullValuedInstanceProperties.java src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseValidation.java +src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseWithAnArrayOfItems.java src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsValidation.java +src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsWithAnArrayOfItems.java src/main/java/org/openapijsonschematools/client/components/schemas/UriFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/UriReferenceFormat.java src/main/java/org/openapijsonschematools/client/components/schemas/UriTemplateFormat.java @@ -329,6 +343,7 @@ src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidato src/main/java/org/openapijsonschematools/client/schemas/validation/PathToSchemasMap.java src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java +src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyEntry.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.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 feaf7979fd3..2b260c96abe 100644 --- a/samples/client/3_1_0_unit_test/java/README.md +++ b/samples/client/3_1_0_unit_test/java/README.md @@ -157,6 +157,8 @@ allowed input and output types. | Class | Description | | ----- | ----------- | +| [ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1](docs/components/schemas/ASchemaGivenForPrefixitems.md#aschemagivenforprefixitems1) | | +| [AdditionalItemsAreAllowedByDefault.AdditionalItemsAreAllowedByDefault1](docs/components/schemas/AdditionalItemsAreAllowedByDefault.md#additionalitemsareallowedbydefault1) | | | [AdditionalpropertiesAreAllowedByDefault.AdditionalpropertiesAreAllowedByDefault1](docs/components/schemas/AdditionalpropertiesAreAllowedByDefault.md#additionalpropertiesareallowedbydefault1) | | | [AdditionalpropertiesCanExistByItself.AdditionalpropertiesCanExistByItself1](docs/components/schemas/AdditionalpropertiesCanExistByItself.md#additionalpropertiescanexistbyitself1) | | | [AdditionalpropertiesDoesNotLookInApplicators.AdditionalpropertiesDoesNotLookInApplicators1](docs/components/schemas/AdditionalpropertiesDoesNotLookInApplicators.md#additionalpropertiesdoesnotlookinapplicators1) | | @@ -209,6 +211,7 @@ allowed input and output types. | [IriFormat.IriFormat1](docs/components/schemas/IriFormat.md#iriformat1) | | | [IriReferenceFormat.IriReferenceFormat1](docs/components/schemas/IriReferenceFormat.md#irireferenceformat1) | | | [ItemsContains.ItemsContains1](docs/components/schemas/ItemsContains.md#itemscontains1) | | +| [ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCase1](docs/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.md#itemsdoesnotlookinapplicatorsvalidcase1) | | | [ItemsWithNullInstanceElements.ItemsWithNullInstanceElements1](docs/components/schemas/ItemsWithNullInstanceElements.md#itemswithnullinstanceelements1) | | | [JsonPointerFormat.JsonPointerFormat1](docs/components/schemas/JsonPointerFormat.md#jsonpointerformat1) | | | [MaxcontainsWithoutContainsIsIgnored.MaxcontainsWithoutContainsIsIgnored1](docs/components/schemas/MaxcontainsWithoutContainsIsIgnored.md#maxcontainswithoutcontainsisignored1) | | @@ -248,6 +251,8 @@ allowed input and output types. | [PatternValidation.PatternValidation1](docs/components/schemas/PatternValidation.md#patternvalidation1) | | | [PatternpropertiesValidatesPropertiesMatchingARegex.PatternpropertiesValidatesPropertiesMatchingARegex1](docs/components/schemas/PatternpropertiesValidatesPropertiesMatchingARegex.md#patternpropertiesvalidatespropertiesmatchingaregex1) | | | [PatternpropertiesWithNullValuedInstanceProperties.PatternpropertiesWithNullValuedInstanceProperties1](docs/components/schemas/PatternpropertiesWithNullValuedInstanceProperties.md#patternpropertieswithnullvaluedinstanceproperties1) | | +| [PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItems1](docs/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.md#prefixitemsvalidationadjuststhestartingindexforitems1) | | +| [PrefixitemsWithNullInstanceElements.PrefixitemsWithNullInstanceElements1](docs/components/schemas/PrefixitemsWithNullInstanceElements.md#prefixitemswithnullinstanceelements1) | | | [PropertiesPatternpropertiesAdditionalpropertiesInteraction.PropertiesPatternpropertiesAdditionalpropertiesInteraction1](docs/components/schemas/PropertiesPatternpropertiesAdditionalpropertiesInteraction.md#propertiespatternpropertiesadditionalpropertiesinteraction1) | | | [PropertiesWhoseNamesAreJavascriptObjectPropertyNames.PropertiesWhoseNamesAreJavascriptObjectPropertyNames1](docs/components/schemas/PropertiesWhoseNamesAreJavascriptObjectPropertyNames.md#propertieswhosenamesarejavascriptobjectpropertynames1) | | | [PropertiesWithEscapedCharacters.PropertiesWithEscapedCharacters1](docs/components/schemas/PropertiesWithEscapedCharacters.md#propertieswithescapedcharacters1) | | @@ -274,7 +279,9 @@ allowed input and output types. | [UnevaluatedpropertiesWithAdjacentAdditionalproperties.UnevaluatedpropertiesWithAdjacentAdditionalproperties1](docs/components/schemas/UnevaluatedpropertiesWithAdjacentAdditionalproperties.md#unevaluatedpropertieswithadjacentadditionalproperties1) | | | [UnevaluatedpropertiesWithNullValuedInstanceProperties.UnevaluatedpropertiesWithNullValuedInstanceProperties1](docs/components/schemas/UnevaluatedpropertiesWithNullValuedInstanceProperties.md#unevaluatedpropertieswithnullvaluedinstanceproperties1) | | | [UniqueitemsFalseValidation.UniqueitemsFalseValidation1](docs/components/schemas/UniqueitemsFalseValidation.md#uniqueitemsfalsevalidation1) | | +| [UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1](docs/components/schemas/UniqueitemsFalseWithAnArrayOfItems.md#uniqueitemsfalsewithanarrayofitems1) | | | [UniqueitemsValidation.UniqueitemsValidation1](docs/components/schemas/UniqueitemsValidation.md#uniqueitemsvalidation1) | | +| [UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1](docs/components/schemas/UniqueitemsWithAnArrayOfItems.md#uniqueitemswithanarrayofitems1) | | | [UriFormat.UriFormat1](docs/components/schemas/UriFormat.md#uriformat1) | | | [UriReferenceFormat.UriReferenceFormat1](docs/components/schemas/UriReferenceFormat.md#urireferenceformat1) | | | [UriTemplateFormat.UriTemplateFormat1](docs/components/schemas/UriTemplateFormat.md#uritemplateformat1) | | diff --git a/samples/client/3_1_0_unit_test/java/docs/components/schemas/ASchemaGivenForPrefixitems.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/ASchemaGivenForPrefixitems.md new file mode 100644 index 00000000000..0f607458413 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/ASchemaGivenForPrefixitems.md @@ -0,0 +1,100 @@ +# ASchemaGivenForPrefixitems +org.openapijsonschematools.client.components.schemas.ASchemaGivenForPrefixitems.java +public class ASchemaGivenForPrefixitems + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1](#aschemagivenforprefixitems1)
schema class | +| static class | [ASchemaGivenForPrefixitems.Schema1](#schema1)
schema class | +| static class | [ASchemaGivenForPrefixitems.Schema0](#schema0)
schema class | +| static class | [ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitemsListBuilder](#aschemagivenforprefixitemslistbuilder)
builder for List payloads | +| static class | [ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitemsList](#aschemagivenforprefixitemslist)
output class for List payloads | + +## ASchemaGivenForPrefixitems1 +public static class ASchemaGivenForPrefixitems1
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| List> | prefixItems = List.of(
    [Schema0.class](#schema0),
    [Schema1.class](#schema1)
)
| + +### 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) | +| [ASchemaGivenForPrefixitemsList](#aschemagivenforprefixitemslist) | validate([List](#aschemagivenforprefixitemslistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## Schema1 +public static class Schema1
+extends StringJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.StringJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## Schema0 +public static class Schema0
+extends IntJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.IntJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## ASchemaGivenForPrefixitemsListBuilder +public class ASchemaGivenForPrefixitemsListBuilder
+builder for `List<@Nullable Object>` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| ASchemaGivenForPrefixitemsListBuilder()
Creates an empty list | +| ASchemaGivenForPrefixitemsListBuilder(List<@Nullable Object> items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| ASchemaGivenForPrefixitemsListBuilder | add(Void item) | +| ASchemaGivenForPrefixitemsListBuilder | add(boolean item) | +| ASchemaGivenForPrefixitemsListBuilder | add(String item) | +| ASchemaGivenForPrefixitemsListBuilder | add(int item) | +| ASchemaGivenForPrefixitemsListBuilder | add(float item) | +| ASchemaGivenForPrefixitemsListBuilder | add(long item) | +| ASchemaGivenForPrefixitemsListBuilder | add(double item) | +| ASchemaGivenForPrefixitemsListBuilder | add(List item) | +| ASchemaGivenForPrefixitemsListBuilder | add(Map item) | +| List<@Nullable Object> | build()
Returns list input that should be used with Schema.validate | + +## ASchemaGivenForPrefixitemsList +public class ASchemaGivenForPrefixitemsList
+extends `FrozenList<@Nullable Object>` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [ASchemaGivenForPrefixitemsList](#aschemagivenforprefixitemslist) | of([List](#aschemagivenforprefixitemslistbuilder) arg, SchemaConfiguration configuration) | + +[[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/AdditionalItemsAreAllowedByDefault.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/AdditionalItemsAreAllowedByDefault.md new file mode 100644 index 00000000000..ebdeae87c05 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/AdditionalItemsAreAllowedByDefault.md @@ -0,0 +1,89 @@ +# AdditionalItemsAreAllowedByDefault +org.openapijsonschematools.client.components.schemas.AdditionalItemsAreAllowedByDefault.java +public class AdditionalItemsAreAllowedByDefault + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [AdditionalItemsAreAllowedByDefault.AdditionalItemsAreAllowedByDefault1](#additionalitemsareallowedbydefault1)
schema class | +| static class | [AdditionalItemsAreAllowedByDefault.Schema0](#schema0)
schema class | +| static class | [AdditionalItemsAreAllowedByDefault.AdditionalItemsAreAllowedByDefaultListBuilder](#additionalitemsareallowedbydefaultlistbuilder)
builder for List payloads | +| static class | [AdditionalItemsAreAllowedByDefault.AdditionalItemsAreAllowedByDefaultList](#additionalitemsareallowedbydefaultlist)
output class for List payloads | + +## AdditionalItemsAreAllowedByDefault1 +public static class AdditionalItemsAreAllowedByDefault1
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| List> | prefixItems = List.of(
    [Schema0.class](#schema0)
)
| + +### 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) | +| [AdditionalItemsAreAllowedByDefaultList](#additionalitemsareallowedbydefaultlist) | validate([List](#additionalitemsareallowedbydefaultlistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## Schema0 +public static class Schema0
+extends IntJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.IntJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## AdditionalItemsAreAllowedByDefaultListBuilder +public class AdditionalItemsAreAllowedByDefaultListBuilder
+builder for `List<@Nullable Object>` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| AdditionalItemsAreAllowedByDefaultListBuilder()
Creates an empty list | +| AdditionalItemsAreAllowedByDefaultListBuilder(List<@Nullable Object> items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(Void item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(boolean item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(String item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(int item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(float item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(long item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(double item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(List item) | +| AdditionalItemsAreAllowedByDefaultListBuilder | add(Map item) | +| List<@Nullable Object> | build()
Returns list input that should be used with Schema.validate | + +## AdditionalItemsAreAllowedByDefaultList +public class AdditionalItemsAreAllowedByDefaultList
+extends `FrozenList<@Nullable Object>` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [AdditionalItemsAreAllowedByDefaultList](#additionalitemsareallowedbydefaultlist) | of([List](#additionalitemsareallowedbydefaultlistbuilder) arg, SchemaConfiguration configuration) | + +[[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/ItemsDoesNotLookInApplicatorsValidCase.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.md new file mode 100644 index 00000000000..43c03e490c6 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.md @@ -0,0 +1,120 @@ +# ItemsDoesNotLookInApplicatorsValidCase +org.openapijsonschematools.client.components.schemas.ItemsDoesNotLookInApplicatorsValidCase.java +public class ItemsDoesNotLookInApplicatorsValidCase + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCase1](#itemsdoesnotlookinapplicatorsvalidcase1)
schema class | +| static class | [ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCaseListBuilder](#itemsdoesnotlookinapplicatorsvalidcaselistbuilder)
builder for List payloads | +| static class | [ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCaseList](#itemsdoesnotlookinapplicatorsvalidcaselist)
output class for List payloads | +| static class | [ItemsDoesNotLookInApplicatorsValidCase.Items](#items)
schema class | + +## ItemsDoesNotLookInApplicatorsValidCase1 +public static class ItemsDoesNotLookInApplicatorsValidCase1
+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()); + +// List validation +ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCaseList validatedPayload = + ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCase1.validate( + new ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCaseListBuilder() + .build(), + configuration +); +``` + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Set> | type = Set.of(List.class) | +| Class | items = [Items.class](#items) | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| [ItemsDoesNotLookInApplicatorsValidCaseList](#itemsdoesnotlookinapplicatorsvalidcaselist) | validate([List](#itemsdoesnotlookinapplicatorsvalidcaselistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## ItemsDoesNotLookInApplicatorsValidCaseListBuilder +public class ItemsDoesNotLookInApplicatorsValidCaseListBuilder
+builder for `List<@Nullable Object>` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder()
Creates an empty list | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder(List<@Nullable Object> items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(Void item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(boolean item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(String item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(int item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(float item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(long item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(double item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(List item) | +| ItemsDoesNotLookInApplicatorsValidCaseListBuilder | add(Map item) | +| List<@Nullable Object> | build()
Returns list input that should be used with Schema.validate | + +## ItemsDoesNotLookInApplicatorsValidCaseList +public class ItemsDoesNotLookInApplicatorsValidCaseList
+extends `FrozenList<@Nullable Object>` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [ItemsDoesNotLookInApplicatorsValidCaseList](#itemsdoesnotlookinapplicatorsvalidcaselist) | of([List](#itemsdoesnotlookinapplicatorsvalidcaselistbuilder) arg, SchemaConfiguration configuration) | + +## Items +public static class Items
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Number | minimum = 5 | + +### 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) | +[[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/ItemsWithNullInstanceElements.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/ItemsWithNullInstanceElements.md index 2124fe57bc3..44743de12fb 100644 --- a/samples/client/3_1_0_unit_test/java/docs/components/schemas/ItemsWithNullInstanceElements.md +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/ItemsWithNullInstanceElements.md @@ -40,7 +40,7 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch ItemsWithNullInstanceElements.ItemsWithNullInstanceElementsList validatedPayload = ItemsWithNullInstanceElements.ItemsWithNullInstanceElements1.validate( new ItemsWithNullInstanceElements.ItemsWithNullInstanceElementsListBuilder() - .add(null) + .add((Void) null) .build(), configuration diff --git a/samples/client/3_1_0_unit_test/java/docs/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.md new file mode 100644 index 00000000000..0c55b531de1 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.md @@ -0,0 +1,116 @@ +# PrefixitemsValidationAdjustsTheStartingIndexForItems +org.openapijsonschematools.client.components.schemas.PrefixitemsValidationAdjustsTheStartingIndexForItems.java +public class PrefixitemsValidationAdjustsTheStartingIndexForItems + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItems1](#prefixitemsvalidationadjuststhestartingindexforitems1)
schema class | +| static class | [PrefixitemsValidationAdjustsTheStartingIndexForItems.Schema0](#schema0)
schema class | +| static class | [PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder](#prefixitemsvalidationadjuststhestartingindexforitemslistbuilder)
builder for List payloads | +| static class | [PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItemsList](#prefixitemsvalidationadjuststhestartingindexforitemslist)
output class for List payloads | +| static class | [PrefixitemsValidationAdjustsTheStartingIndexForItems.Items](#items)
schema class | + +## PrefixitemsValidationAdjustsTheStartingIndexForItems1 +public static class PrefixitemsValidationAdjustsTheStartingIndexForItems1
+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()); + +// List validation +PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItemsList validatedPayload = + PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItems1.validate( + new PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder() + .add(1) + + .build(), + configuration +); +``` + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Set> | type = Set.of(List.class) | +| Class | items = [Items.class](#items) | +| List> | prefixItems = List.of(
    [Schema0.class](#schema0)
)
| + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| [PrefixitemsValidationAdjustsTheStartingIndexForItemsList](#prefixitemsvalidationadjuststhestartingindexforitemslist) | validate([List](#prefixitemsvalidationadjuststhestartingindexforitemslistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## Schema0 +public static class Schema0
+extends StringJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.StringJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder +public class PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder
+builder for `List` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder()
Creates an empty list | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder(List items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder | add(int item) | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder | add(float item) | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder | add(long item) | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder | add(double item) | +| PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder | add(String item) | +| List | build()
Returns list input that should be used with Schema.validate | + +## PrefixitemsValidationAdjustsTheStartingIndexForItemsList +public class PrefixitemsValidationAdjustsTheStartingIndexForItemsList
+extends `FrozenList` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [PrefixitemsValidationAdjustsTheStartingIndexForItemsList](#prefixitemsvalidationadjuststhestartingindexforitemslist) | of([List](#prefixitemsvalidationadjuststhestartingindexforitemslistbuilder) arg, SchemaConfiguration configuration) | + +## Items +public static class Items
+extends IntJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.IntJsonSchema | +| ------------------------------------------------------------------ | +| 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/docs/components/schemas/PrefixitemsWithNullInstanceElements.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/PrefixitemsWithNullInstanceElements.md new file mode 100644 index 00000000000..4f349bd0d5d --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/PrefixitemsWithNullInstanceElements.md @@ -0,0 +1,89 @@ +# PrefixitemsWithNullInstanceElements +org.openapijsonschematools.client.components.schemas.PrefixitemsWithNullInstanceElements.java +public class PrefixitemsWithNullInstanceElements + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [PrefixitemsWithNullInstanceElements.PrefixitemsWithNullInstanceElements1](#prefixitemswithnullinstanceelements1)
schema class | +| static class | [PrefixitemsWithNullInstanceElements.Schema0](#schema0)
schema class | +| static class | [PrefixitemsWithNullInstanceElements.PrefixitemsWithNullInstanceElementsListBuilder](#prefixitemswithnullinstanceelementslistbuilder)
builder for List payloads | +| static class | [PrefixitemsWithNullInstanceElements.PrefixitemsWithNullInstanceElementsList](#prefixitemswithnullinstanceelementslist)
output class for List payloads | + +## PrefixitemsWithNullInstanceElements1 +public static class PrefixitemsWithNullInstanceElements1
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| List> | prefixItems = List.of(
    [Schema0.class](#schema0)
)
| + +### 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) | +| [PrefixitemsWithNullInstanceElementsList](#prefixitemswithnullinstanceelementslist) | validate([List](#prefixitemswithnullinstanceelementslistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## Schema0 +public static class Schema0
+extends NullJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.NumberJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## PrefixitemsWithNullInstanceElementsListBuilder +public class PrefixitemsWithNullInstanceElementsListBuilder
+builder for `List<@Nullable Object>` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| PrefixitemsWithNullInstanceElementsListBuilder()
Creates an empty list | +| PrefixitemsWithNullInstanceElementsListBuilder(List<@Nullable Object> items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| PrefixitemsWithNullInstanceElementsListBuilder | add(Void item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(boolean item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(String item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(int item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(float item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(long item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(double item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(List item) | +| PrefixitemsWithNullInstanceElementsListBuilder | add(Map item) | +| List<@Nullable Object> | build()
Returns list input that should be used with Schema.validate | + +## PrefixitemsWithNullInstanceElementsList +public class PrefixitemsWithNullInstanceElementsList
+extends `FrozenList<@Nullable Object>` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [PrefixitemsWithNullInstanceElementsList](#prefixitemswithnullinstanceelementslist) | of([List](#prefixitemswithnullinstanceelementslistbuilder) arg, SchemaConfiguration configuration) | + +[[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/UniqueitemsFalseWithAnArrayOfItems.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/UniqueitemsFalseWithAnArrayOfItems.md new file mode 100644 index 00000000000..c00934f2ebf --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/UniqueitemsFalseWithAnArrayOfItems.md @@ -0,0 +1,101 @@ +# UniqueitemsFalseWithAnArrayOfItems +org.openapijsonschematools.client.components.schemas.UniqueitemsFalseWithAnArrayOfItems.java +public class UniqueitemsFalseWithAnArrayOfItems + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1](#uniqueitemsfalsewithanarrayofitems1)
schema class | +| static class | [UniqueitemsFalseWithAnArrayOfItems.Schema1](#schema1)
schema class | +| static class | [UniqueitemsFalseWithAnArrayOfItems.Schema0](#schema0)
schema class | +| static class | [UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder](#uniqueitemsfalsewithanarrayofitemslistbuilder)
builder for List payloads | +| static class | [UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsList](#uniqueitemsfalsewithanarrayofitemslist)
output class for List payloads | + +## UniqueitemsFalseWithAnArrayOfItems1 +public static class UniqueitemsFalseWithAnArrayOfItems1
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Boolean | uniqueItems = false | +| List> | prefixItems = List.of(
    [Schema0.class](#schema0),
    [Schema1.class](#schema1)
)
| + +### 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) | +| [UniqueitemsFalseWithAnArrayOfItemsList](#uniqueitemsfalsewithanarrayofitemslist) | validate([List](#uniqueitemsfalsewithanarrayofitemslistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## Schema1 +public static class Schema1
+extends BooleanJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## Schema0 +public static class Schema0
+extends BooleanJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## UniqueitemsFalseWithAnArrayOfItemsListBuilder +public class UniqueitemsFalseWithAnArrayOfItemsListBuilder
+builder for `List<@Nullable Object>` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder()
Creates an empty list | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder(List<@Nullable Object> items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(Void item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(boolean item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(String item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(int item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(float item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(long item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(double item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(List item) | +| UniqueitemsFalseWithAnArrayOfItemsListBuilder | add(Map item) | +| List<@Nullable Object> | build()
Returns list input that should be used with Schema.validate | + +## UniqueitemsFalseWithAnArrayOfItemsList +public class UniqueitemsFalseWithAnArrayOfItemsList
+extends `FrozenList<@Nullable Object>` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [UniqueitemsFalseWithAnArrayOfItemsList](#uniqueitemsfalsewithanarrayofitemslist) | of([List](#uniqueitemsfalsewithanarrayofitemslistbuilder) arg, SchemaConfiguration configuration) | + +[[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/UniqueitemsWithAnArrayOfItems.md b/samples/client/3_1_0_unit_test/java/docs/components/schemas/UniqueitemsWithAnArrayOfItems.md new file mode 100644 index 00000000000..6a65e3402ff --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/docs/components/schemas/UniqueitemsWithAnArrayOfItems.md @@ -0,0 +1,101 @@ +# UniqueitemsWithAnArrayOfItems +org.openapijsonschematools.client.components.schemas.UniqueitemsWithAnArrayOfItems.java +public class UniqueitemsWithAnArrayOfItems + +A class that contains necessary nested +- schema classes (which validate payloads), extends JsonSchema +- classes to store validated list payloads, extends FrozenList +- classes to build inputs for list payloads + +## Nested Class Summary +| Modifier and Type | Class and Description | +| ----------------- | ---------------------- | +| static class | [UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1](#uniqueitemswithanarrayofitems1)
schema class | +| static class | [UniqueitemsWithAnArrayOfItems.Schema1](#schema1)
schema class | +| static class | [UniqueitemsWithAnArrayOfItems.Schema0](#schema0)
schema class | +| static class | [UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItemsListBuilder](#uniqueitemswithanarrayofitemslistbuilder)
builder for List payloads | +| static class | [UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItemsList](#uniqueitemswithanarrayofitemslist)
output class for List payloads | + +## UniqueitemsWithAnArrayOfItems1 +public static class UniqueitemsWithAnArrayOfItems1
+extends JsonSchema + +A schema class that validates payloads + +### Field Summary +| Modifier and Type | Field and Description | +| ----------------- | ---------------------- | +| Boolean | uniqueItems = true | +| List> | prefixItems = List.of(
    [Schema0.class](#schema0),
    [Schema1.class](#schema1)
)
| + +### 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) | +| [UniqueitemsWithAnArrayOfItemsList](#uniqueitemswithanarrayofitemslist) | validate([List](#uniqueitemswithanarrayofitemslistbuilder) arg, SchemaConfiguration configuration) | +| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) | +## Schema1 +public static class Schema1
+extends BooleanJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## Schema0 +public static class Schema0
+extends BooleanJsonSchema + +A schema class that validates payloads + +| Methods Inherited from class org.openapijsonschematools.client.schemas.BooleanJsonSchema | +| ------------------------------------------------------------------ | +| validate | + +## UniqueitemsWithAnArrayOfItemsListBuilder +public class UniqueitemsWithAnArrayOfItemsListBuilder
+builder for `List<@Nullable Object>` + +A class that builds the List input type + +### Constructor Summary +| Constructor and Description | +| --------------------------- | +| UniqueitemsWithAnArrayOfItemsListBuilder()
Creates an empty list | +| UniqueitemsWithAnArrayOfItemsListBuilder(List<@Nullable Object> items)
Stores the items in a list | + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(Void item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(boolean item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(String item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(int item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(float item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(long item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(double item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(List item) | +| UniqueitemsWithAnArrayOfItemsListBuilder | add(Map item) | +| List<@Nullable Object> | build()
Returns list input that should be used with Schema.validate | + +## UniqueitemsWithAnArrayOfItemsList +public class UniqueitemsWithAnArrayOfItemsList
+extends `FrozenList<@Nullable Object>` + +A class to store validated List payloads + +### Method Summary +| Modifier and Type | Method and Description | +| ----------------- | ---------------------- | +| static [UniqueitemsWithAnArrayOfItemsList](#uniqueitemswithanarrayofitemslist) | of([List](#uniqueitemswithanarrayofitemslistbuilder) arg, SchemaConfiguration configuration) | + +[[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/ASchemaGivenForPrefixitems.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/ASchemaGivenForPrefixitems.java new file mode 100644 index 00000000000..bdf23d3229f --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/ASchemaGivenForPrefixitems.java @@ -0,0 +1,337 @@ +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.IntJsonSchema; +import org.openapijsonschematools.client.schemas.StringJsonSchema; +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.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class ASchemaGivenForPrefixitems { + // nest classes so all schemas and input/output classes can be public + + + public static class ASchemaGivenForPrefixitemsList extends FrozenList<@Nullable Object> { + protected ASchemaGivenForPrefixitemsList(FrozenList<@Nullable Object> m) { + super(m); + } + public static ASchemaGivenForPrefixitemsList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return ASchemaGivenForPrefixitems1.getInstance().validate(arg, configuration); + } + } + + public static class ASchemaGivenForPrefixitemsListBuilder { + // class to build List<@Nullable Object> + private final List<@Nullable Object> list; + + public ASchemaGivenForPrefixitemsListBuilder() { + list = new ArrayList<>(); + } + + public ASchemaGivenForPrefixitemsListBuilder(List<@Nullable Object> list) { + this.list = list; + } + + public ASchemaGivenForPrefixitemsListBuilder add(Void item) { + list.add(null); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(boolean item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(String item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(int item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(float item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(long item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(double item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(List item) { + list.add(item); + return this; + } + + public ASchemaGivenForPrefixitemsListBuilder add(Map item) { + list.add(item); + return this; + } + + public List<@Nullable Object> build() { + return list; + } + } + + + public static class Schema0 extends IntJsonSchema { + private static @Nullable Schema0 instance = null; + public static Schema0 getInstance() { + if (instance == null) { + instance = new Schema0(); + } + return instance; + } + } + + + public static class Schema1 extends StringJsonSchema { + private static @Nullable Schema1 instance = null; + public static Schema1 getInstance() { + if (instance == null) { + instance = new Schema1(); + } + return instance; + } + } + + + public static class ASchemaGivenForPrefixitems1 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 ASchemaGivenForPrefixitems1 instance = null; + + protected ASchemaGivenForPrefixitems1() { + super(new JsonSchemaInfo() + .prefixItems(List.of( + Schema0.class, + Schema1.class + )) + ); + } + + public static ASchemaGivenForPrefixitems1 getInstance() { + if (instance == null) { + instance = new ASchemaGivenForPrefixitems1(); + } + 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 ASchemaGivenForPrefixitemsList 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 new ASchemaGivenForPrefixitemsList(newInstanceItems); + } + + public ASchemaGivenForPrefixitemsList 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/AdditionalItemsAreAllowedByDefault.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/AdditionalItemsAreAllowedByDefault.java new file mode 100644 index 00000000000..172fc6de967 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/AdditionalItemsAreAllowedByDefault.java @@ -0,0 +1,324 @@ +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.IntJsonSchema; +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.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class AdditionalItemsAreAllowedByDefault { + // nest classes so all schemas and input/output classes can be public + + + public static class AdditionalItemsAreAllowedByDefaultList extends FrozenList<@Nullable Object> { + protected AdditionalItemsAreAllowedByDefaultList(FrozenList<@Nullable Object> m) { + super(m); + } + public static AdditionalItemsAreAllowedByDefaultList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return AdditionalItemsAreAllowedByDefault1.getInstance().validate(arg, configuration); + } + } + + public static class AdditionalItemsAreAllowedByDefaultListBuilder { + // class to build List<@Nullable Object> + private final List<@Nullable Object> list; + + public AdditionalItemsAreAllowedByDefaultListBuilder() { + list = new ArrayList<>(); + } + + public AdditionalItemsAreAllowedByDefaultListBuilder(List<@Nullable Object> list) { + this.list = list; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(Void item) { + list.add(null); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(boolean item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(String item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(int item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(float item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(long item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(double item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(List item) { + list.add(item); + return this; + } + + public AdditionalItemsAreAllowedByDefaultListBuilder add(Map item) { + list.add(item); + return this; + } + + public List<@Nullable Object> build() { + return list; + } + } + + + public static class Schema0 extends IntJsonSchema { + private static @Nullable Schema0 instance = null; + public static Schema0 getInstance() { + if (instance == null) { + instance = new Schema0(); + } + return instance; + } + } + + + public static class AdditionalItemsAreAllowedByDefault1 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 AdditionalItemsAreAllowedByDefault1 instance = null; + + protected AdditionalItemsAreAllowedByDefault1() { + super(new JsonSchemaInfo() + .prefixItems(List.of( + Schema0.class + )) + ); + } + + public static AdditionalItemsAreAllowedByDefault1 getInstance() { + if (instance == null) { + instance = new AdditionalItemsAreAllowedByDefault1(); + } + 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 AdditionalItemsAreAllowedByDefaultList 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 new AdditionalItemsAreAllowedByDefaultList(newInstanceItems); + } + + public AdditionalItemsAreAllowedByDefaultList 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/ItemsDoesNotLookInApplicatorsValidCase.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.java new file mode 100644 index 00000000000..9d32fe1a6c0 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/ItemsDoesNotLookInApplicatorsValidCase.java @@ -0,0 +1,373 @@ +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.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class ItemsDoesNotLookInApplicatorsValidCase { + // nest classes so all schemas and input/output classes can be public + + + public static class Items extends JsonSchema implements NullSchemaValidator, BooleanSchemaValidator, NumberSchemaValidator, StringSchemaValidator, ListSchemaValidator>, MapSchemaValidator> { + private static @Nullable Items instance = null; + + protected Items() { + super(new JsonSchemaInfo() + .minimum(5) + ); + } + + public static Items getInstance() { + if (instance == null) { + instance = new Items(); + } + 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 ItemsDoesNotLookInApplicatorsValidCaseList extends FrozenList<@Nullable Object> { + protected ItemsDoesNotLookInApplicatorsValidCaseList(FrozenList<@Nullable Object> m) { + super(m); + } + public static ItemsDoesNotLookInApplicatorsValidCaseList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return ItemsDoesNotLookInApplicatorsValidCase1.getInstance().validate(arg, configuration); + } + } + + public static class ItemsDoesNotLookInApplicatorsValidCaseListBuilder { + // class to build List<@Nullable Object> + private final List<@Nullable Object> list; + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder() { + list = new ArrayList<>(); + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder(List<@Nullable Object> list) { + this.list = list; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(Void item) { + list.add(null); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(boolean item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(String item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(int item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(float item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(long item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(double item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(List item) { + list.add(item); + return this; + } + + public ItemsDoesNotLookInApplicatorsValidCaseListBuilder add(Map item) { + list.add(item); + return this; + } + + public List<@Nullable Object> build() { + return list; + } + } + + + public static class ItemsDoesNotLookInApplicatorsValidCase1 extends JsonSchema implements ListSchemaValidator { + /* + 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 ItemsDoesNotLookInApplicatorsValidCase1 instance = null; + + protected ItemsDoesNotLookInApplicatorsValidCase1() { + super(new JsonSchemaInfo() + .type(Set.of(List.class)) + .items(Items.class) + ); + } + + public static ItemsDoesNotLookInApplicatorsValidCase1 getInstance() { + if (instance == null) { + instance = new ItemsDoesNotLookInApplicatorsValidCase1(); + } + return instance; + } + + @Override + public ItemsDoesNotLookInApplicatorsValidCaseList 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 new ItemsDoesNotLookInApplicatorsValidCaseList(newInstanceItems); + } + + public ItemsDoesNotLookInApplicatorsValidCaseList 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 @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + if (arg instanceof List) { + return validate((List) 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 List) { + return getNewInstance((List) 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/PrefixitemsValidationAdjustsTheStartingIndexForItems.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.java new file mode 100644 index 00000000000..380ac89c81b --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItems.java @@ -0,0 +1,175 @@ +package org.openapijsonschematools.client.components.schemas; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +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.IntJsonSchema; +import org.openapijsonschematools.client.schemas.StringJsonSchema; +import org.openapijsonschematools.client.schemas.validation.FrozenList; +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.PathToSchemasMap; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class PrefixitemsValidationAdjustsTheStartingIndexForItems { + // nest classes so all schemas and input/output classes can be public + + + public static class Items extends IntJsonSchema { + private static @Nullable Items instance = null; + public static Items getInstance() { + if (instance == null) { + instance = new Items(); + } + return instance; + } + } + + + public static class PrefixitemsValidationAdjustsTheStartingIndexForItemsList extends FrozenList { + protected PrefixitemsValidationAdjustsTheStartingIndexForItemsList(FrozenList m) { + super(m); + } + public static PrefixitemsValidationAdjustsTheStartingIndexForItemsList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return PrefixitemsValidationAdjustsTheStartingIndexForItems1.getInstance().validate(arg, configuration); + } + } + + public static class PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder { + // class to build List + private final List list; + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder() { + list = new ArrayList<>(); + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder(List list) { + this.list = list; + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder add(int item) { + list.add(item); + return this; + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder add(float item) { + list.add(item); + return this; + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder add(long item) { + list.add(item); + return this; + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder add(double item) { + list.add(item); + return this; + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder add(String item) { + list.add(item); + return this; + } + + public List build() { + return list; + } + } + + + public static class Schema0 extends StringJsonSchema { + private static @Nullable Schema0 instance = null; + public static Schema0 getInstance() { + if (instance == null) { + instance = new Schema0(); + } + return instance; + } + } + + + public static class PrefixitemsValidationAdjustsTheStartingIndexForItems1 extends JsonSchema implements ListSchemaValidator { + /* + 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 PrefixitemsValidationAdjustsTheStartingIndexForItems1 instance = null; + + protected PrefixitemsValidationAdjustsTheStartingIndexForItems1() { + super(new JsonSchemaInfo() + .type(Set.of(List.class)) + .items(Items.class) + .prefixItems(List.of( + Schema0.class + )) + ); + } + + public static PrefixitemsValidationAdjustsTheStartingIndexForItems1 getInstance() { + if (instance == null) { + instance = new PrefixitemsValidationAdjustsTheStartingIndexForItems1(); + } + return instance; + } + + @Override + public PrefixitemsValidationAdjustsTheStartingIndexForItemsList getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + List 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); + if (!(itemInstance instanceof Object)) { + throw new InvalidTypeException("Invalid instantiated value"); + } + items.add((Object) itemInstance); + i += 1; + } + FrozenList newInstanceItems = new FrozenList<>(items); + return new PrefixitemsValidationAdjustsTheStartingIndexForItemsList(newInstanceItems); + } + + public PrefixitemsValidationAdjustsTheStartingIndexForItemsList 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 @Nullable Object validate(@Nullable Object arg, SchemaConfiguration configuration) throws ValidationException, InvalidTypeException { + if (arg instanceof List) { + return validate((List) 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 List) { + return getNewInstance((List) 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/PrefixitemsWithNullInstanceElements.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/PrefixitemsWithNullInstanceElements.java new file mode 100644 index 00000000000..d7aacf54e69 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/PrefixitemsWithNullInstanceElements.java @@ -0,0 +1,324 @@ +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.NullJsonSchema; +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.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class PrefixitemsWithNullInstanceElements { + // nest classes so all schemas and input/output classes can be public + + + public static class PrefixitemsWithNullInstanceElementsList extends FrozenList<@Nullable Object> { + protected PrefixitemsWithNullInstanceElementsList(FrozenList<@Nullable Object> m) { + super(m); + } + public static PrefixitemsWithNullInstanceElementsList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return PrefixitemsWithNullInstanceElements1.getInstance().validate(arg, configuration); + } + } + + public static class PrefixitemsWithNullInstanceElementsListBuilder { + // class to build List<@Nullable Object> + private final List<@Nullable Object> list; + + public PrefixitemsWithNullInstanceElementsListBuilder() { + list = new ArrayList<>(); + } + + public PrefixitemsWithNullInstanceElementsListBuilder(List<@Nullable Object> list) { + this.list = list; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(Void item) { + list.add(null); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(boolean item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(String item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(int item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(float item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(long item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(double item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(List item) { + list.add(item); + return this; + } + + public PrefixitemsWithNullInstanceElementsListBuilder add(Map item) { + list.add(item); + return this; + } + + public List<@Nullable Object> build() { + return list; + } + } + + + public static class Schema0 extends NullJsonSchema { + private static @Nullable Schema0 instance = null; + public static Schema0 getInstance() { + if (instance == null) { + instance = new Schema0(); + } + return instance; + } + } + + + public static class PrefixitemsWithNullInstanceElements1 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 PrefixitemsWithNullInstanceElements1 instance = null; + + protected PrefixitemsWithNullInstanceElements1() { + super(new JsonSchemaInfo() + .prefixItems(List.of( + Schema0.class + )) + ); + } + + public static PrefixitemsWithNullInstanceElements1 getInstance() { + if (instance == null) { + instance = new PrefixitemsWithNullInstanceElements1(); + } + 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 PrefixitemsWithNullInstanceElementsList 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 new PrefixitemsWithNullInstanceElementsList(newInstanceItems); + } + + public PrefixitemsWithNullInstanceElementsList 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/UniqueitemsFalseWithAnArrayOfItems.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseWithAnArrayOfItems.java new file mode 100644 index 00000000000..42cb50ed66a --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseWithAnArrayOfItems.java @@ -0,0 +1,337 @@ +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.BooleanJsonSchema; +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.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class UniqueitemsFalseWithAnArrayOfItems { + // nest classes so all schemas and input/output classes can be public + + + public static class UniqueitemsFalseWithAnArrayOfItemsList extends FrozenList<@Nullable Object> { + protected UniqueitemsFalseWithAnArrayOfItemsList(FrozenList<@Nullable Object> m) { + super(m); + } + public static UniqueitemsFalseWithAnArrayOfItemsList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return UniqueitemsFalseWithAnArrayOfItems1.getInstance().validate(arg, configuration); + } + } + + public static class UniqueitemsFalseWithAnArrayOfItemsListBuilder { + // class to build List<@Nullable Object> + private final List<@Nullable Object> list; + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder() { + list = new ArrayList<>(); + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder(List<@Nullable Object> list) { + this.list = list; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(Void item) { + list.add(null); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(boolean item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(String item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(int item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(float item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(long item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(double item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(List item) { + list.add(item); + return this; + } + + public UniqueitemsFalseWithAnArrayOfItemsListBuilder add(Map item) { + list.add(item); + return this; + } + + public List<@Nullable Object> build() { + return list; + } + } + + + public static class Schema0 extends BooleanJsonSchema { + private static @Nullable Schema0 instance = null; + public static Schema0 getInstance() { + if (instance == null) { + instance = new Schema0(); + } + return instance; + } + } + + + public static class Schema1 extends BooleanJsonSchema { + private static @Nullable Schema1 instance = null; + public static Schema1 getInstance() { + if (instance == null) { + instance = new Schema1(); + } + return instance; + } + } + + + public static class UniqueitemsFalseWithAnArrayOfItems1 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 UniqueitemsFalseWithAnArrayOfItems1 instance = null; + + protected UniqueitemsFalseWithAnArrayOfItems1() { + super(new JsonSchemaInfo() + .uniqueItems(false) + .prefixItems(List.of( + Schema0.class, + Schema1.class + )) + ); + } + + public static UniqueitemsFalseWithAnArrayOfItems1 getInstance() { + if (instance == null) { + instance = new UniqueitemsFalseWithAnArrayOfItems1(); + } + 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 UniqueitemsFalseWithAnArrayOfItemsList 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 new UniqueitemsFalseWithAnArrayOfItemsList(newInstanceItems); + } + + public UniqueitemsFalseWithAnArrayOfItemsList 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/UniqueitemsWithAnArrayOfItems.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsWithAnArrayOfItems.java new file mode 100644 index 00000000000..5ebd10207a6 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/components/schemas/UniqueitemsWithAnArrayOfItems.java @@ -0,0 +1,337 @@ +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.BooleanJsonSchema; +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.StringSchemaValidator; +import org.openapijsonschematools.client.schemas.validation.ValidationMetadata; + +public class UniqueitemsWithAnArrayOfItems { + // nest classes so all schemas and input/output classes can be public + + + public static class UniqueitemsWithAnArrayOfItemsList extends FrozenList<@Nullable Object> { + protected UniqueitemsWithAnArrayOfItemsList(FrozenList<@Nullable Object> m) { + super(m); + } + public static UniqueitemsWithAnArrayOfItemsList of(List arg, SchemaConfiguration configuration) throws ValidationException { + return UniqueitemsWithAnArrayOfItems1.getInstance().validate(arg, configuration); + } + } + + public static class UniqueitemsWithAnArrayOfItemsListBuilder { + // class to build List<@Nullable Object> + private final List<@Nullable Object> list; + + public UniqueitemsWithAnArrayOfItemsListBuilder() { + list = new ArrayList<>(); + } + + public UniqueitemsWithAnArrayOfItemsListBuilder(List<@Nullable Object> list) { + this.list = list; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(Void item) { + list.add(null); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(boolean item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(String item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(int item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(float item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(long item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(double item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(List item) { + list.add(item); + return this; + } + + public UniqueitemsWithAnArrayOfItemsListBuilder add(Map item) { + list.add(item); + return this; + } + + public List<@Nullable Object> build() { + return list; + } + } + + + public static class Schema0 extends BooleanJsonSchema { + private static @Nullable Schema0 instance = null; + public static Schema0 getInstance() { + if (instance == null) { + instance = new Schema0(); + } + return instance; + } + } + + + public static class Schema1 extends BooleanJsonSchema { + private static @Nullable Schema1 instance = null; + public static Schema1 getInstance() { + if (instance == null) { + instance = new Schema1(); + } + return instance; + } + } + + + public static class UniqueitemsWithAnArrayOfItems1 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 UniqueitemsWithAnArrayOfItems1 instance = null; + + protected UniqueitemsWithAnArrayOfItems1() { + super(new JsonSchemaInfo() + .uniqueItems(true) + .prefixItems(List.of( + Schema0.class, + Schema1.class + )) + ); + } + + public static UniqueitemsWithAnArrayOfItems1 getInstance() { + if (instance == null) { + instance = new UniqueitemsWithAnArrayOfItems1(); + } + 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 UniqueitemsWithAnArrayOfItemsList 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 new UniqueitemsWithAnArrayOfItemsList(newInstanceItems); + } + + public UniqueitemsWithAnArrayOfItemsList 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/schemas/validation/ItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/ItemsValidator.java index bf3ee6ecf15..cf66ce04470 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 @@ -20,13 +20,16 @@ public ItemsValidator(Class items) { @Nullable List containsPathToSchemas, @Nullable PathToSchemasMap patternPropertiesPathToSchemas ) { - if (!(arg instanceof List)) { + if (!(arg instanceof List listArg)) { + return null; + } + if (listArg.isEmpty()) { return null; } PathToSchemasMap pathToSchemas = new PathToSchemasMap(); - // todo add handling for prefixItems - int i = 0; - for(Object itemValue: (List) arg) { + int minIndex = schema.prefixItems != null ? schema.prefixItems.size() : 0; + JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); + for(int i = minIndex; i < listArg.size(); i++) { List itemPathToItem = new ArrayList<>(validationMetadata.pathToItem()); itemPathToItem.add(i); ValidationMetadata itemValidationMetadata = new ValidationMetadata( @@ -35,15 +38,12 @@ public ItemsValidator(Class items) { validationMetadata.validatedPathToSchemas(), validationMetadata.seenClasses() ); - JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); if (itemValidationMetadata.validationRanEarlier(itemsSchema)) { // todo add_deeper_validated_schemas - i +=1; continue; } - PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, itemValue, itemValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, listArg.get(i), itemValidationMetadata); pathToSchemas.update(otherPathToSchemas); - i += 1; } return pathToSchemas; } 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 e567b7f5dc2..33fc4a78e91 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 @@ -53,6 +53,7 @@ public abstract class JsonSchema { public @Nullable Map> dependentRequired; public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; + public @Nullable List> prefixItems; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -284,6 +285,13 @@ protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { new PatternPropertiesValidator(this.patternProperties) ); } + this.prefixItems = jsonSchemaInfo.prefixItems; + if (this.prefixItems != null) { + keywordToValidator.put( + "prefixItems", + new PrefixItemsValidator(this.prefixItems) + ); + } this.keywordToValidator = keywordToValidator; } 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 45c911b0c18..16554a769d5 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 @@ -177,4 +177,9 @@ public JsonSchemaInfo patternProperties(Map this.patternProperties = patternProperties; return this; } + public @Nullable List> prefixItems = null; + public JsonSchemaInfo prefixItems(List> prefixItems) { + this.prefixItems = prefixItems; + 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/PrefixItemsValidator.java b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java new file mode 100644 index 00000000000..4163833addb --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java @@ -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> prefixItems; + + public PrefixItemsValidator(List> prefixItems) { + this.prefixItems = prefixItems; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List 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 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; + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ASchemaGivenForPrefixitemsTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ASchemaGivenForPrefixitemsTest.java new file mode 100644 index 00000000000..bf8415219c8 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ASchemaGivenForPrefixitemsTest.java @@ -0,0 +1,116 @@ +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 ASchemaGivenForPrefixitemsTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testCorrectTypesPasses() { + // correct types + final var schema = ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1.getInstance(); + schema.validate( + new ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitemsListBuilder() + .add(1) + + .add("foo") + + .build(), + configuration + ); + } + + @Test + public void testArrayWithAdditionalItemsPasses() { + // array with additional items + final var schema = ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1.getInstance(); + schema.validate( + new ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitemsListBuilder() + .add(1) + + .add("foo") + + .add(true) + + .build(), + configuration + ); + } + + @Test + public void testJavascriptPseudoArrayIsValidPasses() { + // JavaScript pseudo-array is valid + final var schema = ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1.getInstance(); + schema.validate( + MapUtils.makeMap( + new AbstractMap.SimpleEntry( + "0", + "invalid" + ), + new AbstractMap.SimpleEntry( + "1", + "valid" + ), + new AbstractMap.SimpleEntry( + "length", + 2 + ) + ), + configuration + ); + } + + @Test + public void testEmptyArrayPasses() { + // empty array + final var schema = ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1.getInstance(); + schema.validate( + new ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitemsListBuilder() + .build(), + configuration + ); + } + + @Test + public void testWrongTypesFails() { + // wrong types + final var schema = ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1.getInstance(); + try { + schema.validate( + Arrays.asList( + "foo", + 1 + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } + + @Test + public void testIncompleteArrayOfItemsPasses() { + // incomplete array of items + final var schema = ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitems1.getInstance(); + schema.validate( + new ASchemaGivenForPrefixitems.ASchemaGivenForPrefixitemsListBuilder() + .add(1) + + .build(), + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/AdditionalItemsAreAllowedByDefaultTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/AdditionalItemsAreAllowedByDefaultTest.java new file mode 100644 index 00000000000..f6bfb6cc8e7 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/AdditionalItemsAreAllowedByDefaultTest.java @@ -0,0 +1,36 @@ +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 AdditionalItemsAreAllowedByDefaultTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testOnlyTheFirstItemIsValidatedPasses() { + // only the first item is validated + final var schema = AdditionalItemsAreAllowedByDefault.AdditionalItemsAreAllowedByDefault1.getInstance(); + schema.validate( + new AdditionalItemsAreAllowedByDefault.AdditionalItemsAreAllowedByDefaultListBuilder() + .add(1) + + .add("foo") + + .add(false) + + .build(), + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsDoesNotLookInApplicatorsValidCaseTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsDoesNotLookInApplicatorsValidCaseTest.java new file mode 100644 index 00000000000..9a8df4453bf --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsDoesNotLookInApplicatorsValidCaseTest.java @@ -0,0 +1,52 @@ +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 ItemsDoesNotLookInApplicatorsValidCaseTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testPrefixitemsInAllofDoesNotConstrainItemsValidCasePasses() { + // prefixItems in allOf does not constrain items, valid case + final var schema = ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCase1.getInstance(); + schema.validate( + new ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCaseListBuilder() + .add(5) + + .add(5) + + .build(), + configuration + ); + } + + @Test + public void testPrefixitemsInAllofDoesNotConstrainItemsInvalidCaseFails() { + // prefixItems in allOf does not constrain items, invalid case + final var schema = ItemsDoesNotLookInApplicatorsValidCase.ItemsDoesNotLookInApplicatorsValidCase1.getInstance(); + try { + schema.validate( + Arrays.asList( + 3, + 5 + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsWithNullInstanceElementsTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsWithNullInstanceElementsTest.java index cf0057104b1..5f08a2d94e1 100644 --- a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsWithNullInstanceElementsTest.java +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/ItemsWithNullInstanceElementsTest.java @@ -23,7 +23,7 @@ public void testAllowsNullElementsPasses() { final var schema = ItemsWithNullInstanceElements.ItemsWithNullInstanceElements1.getInstance(); schema.validate( new ItemsWithNullInstanceElements.ItemsWithNullInstanceElementsListBuilder() - .add(null) + .add((Void) null) .build(), configuration diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItemsTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItemsTest.java new file mode 100644 index 00000000000..46f31690d6f --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/PrefixitemsValidationAdjustsTheStartingIndexForItemsTest.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 PrefixitemsValidationAdjustsTheStartingIndexForItemsTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testValidItemsPasses() { + // valid items + final var schema = PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItems1.getInstance(); + schema.validate( + new PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItemsListBuilder() + .add("x") + + .add(2) + + .add(3) + + .build(), + configuration + ); + } + + @Test + public void testWrongTypeOfSecondItemFails() { + // wrong type of second item + final var schema = PrefixitemsValidationAdjustsTheStartingIndexForItems.PrefixitemsValidationAdjustsTheStartingIndexForItems1.getInstance(); + try { + schema.validate( + Arrays.asList( + "x", + "y" + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/PrefixitemsWithNullInstanceElementsTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/PrefixitemsWithNullInstanceElementsTest.java new file mode 100644 index 00000000000..50a6ac70f42 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/PrefixitemsWithNullInstanceElementsTest.java @@ -0,0 +1,32 @@ +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 PrefixitemsWithNullInstanceElementsTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testAllowsNullElementsPasses() { + // allows null elements + final var schema = PrefixitemsWithNullInstanceElements.PrefixitemsWithNullInstanceElements1.getInstance(); + schema.validate( + new PrefixitemsWithNullInstanceElements.PrefixitemsWithNullInstanceElementsListBuilder() + .add((Void) null) + + .build(), + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseWithAnArrayOfItemsTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseWithAnArrayOfItemsTest.java new file mode 100644 index 00000000000..f8354dbe7f9 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/UniqueitemsFalseWithAnArrayOfItemsTest.java @@ -0,0 +1,155 @@ +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 UniqueitemsFalseWithAnArrayOfItemsTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testFalseFalseFromItemsArrayIsValidPasses() { + // [false, false] from items array is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(false) + + .add(false) + + .build(), + configuration + ); + } + + @Test + public void testNonUniqueArrayExtendedFromFalseTrueIsValidPasses() { + // non-unique array extended from [false, true] is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(false) + + .add(true) + + .add("foo") + + .add("foo") + + .build(), + configuration + ); + } + + @Test + public void testTrueTrueFromItemsArrayIsValidPasses() { + // [true, true] from items array is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(true) + + .add(true) + + .build(), + configuration + ); + } + + @Test + public void testUniqueArrayExtendedFromFalseTrueIsValidPasses() { + // unique array extended from [false, true] is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(false) + + .add(true) + + .add("foo") + + .add("bar") + + .build(), + configuration + ); + } + + @Test + public void testUniqueArrayExtendedFromTrueFalseIsValidPasses() { + // unique array extended from [true, false] is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(true) + + .add(false) + + .add("foo") + + .add("bar") + + .build(), + configuration + ); + } + + @Test + public void testFalseTrueFromItemsArrayIsValidPasses() { + // [false, true] from items array is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(false) + + .add(true) + + .build(), + configuration + ); + } + + @Test + public void testTrueFalseFromItemsArrayIsValidPasses() { + // [true, false] from items array is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(true) + + .add(false) + + .build(), + configuration + ); + } + + @Test + public void testNonUniqueArrayExtendedFromTrueFalseIsValidPasses() { + // non-unique array extended from [true, false] is valid + final var schema = UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsFalseWithAnArrayOfItems.UniqueitemsFalseWithAnArrayOfItemsListBuilder() + .add(true) + + .add(false) + + .add("foo") + + .add("foo") + + .build(), + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/UniqueitemsWithAnArrayOfItemsTest.java b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/UniqueitemsWithAnArrayOfItemsTest.java new file mode 100644 index 00000000000..3c89da2ab31 --- /dev/null +++ b/samples/client/3_1_0_unit_test/java/src/test/java/org/openapijsonschematools/client/components/schemas/UniqueitemsWithAnArrayOfItemsTest.java @@ -0,0 +1,163 @@ +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 UniqueitemsWithAnArrayOfItemsTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.onlyFormat()); + + @Test + public void testTrueTrueFromItemsArrayIsNotValidFails() { + // [true, true] from items array is not valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + try { + schema.validate( + Arrays.asList( + true, + true + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } + + @Test + public void testUniqueArrayExtendedFromFalseTrueIsValidPasses() { + // unique array extended from [false, true] is valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItemsListBuilder() + .add(false) + + .add(true) + + .add("foo") + + .add("bar") + + .build(), + configuration + ); + } + + @Test + public void testFalseFalseFromItemsArrayIsNotValidFails() { + // [false, false] from items array is not valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + try { + schema.validate( + Arrays.asList( + false, + false + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } + + @Test + public void testUniqueArrayExtendedFromTrueFalseIsValidPasses() { + // unique array extended from [true, false] is valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItemsListBuilder() + .add(true) + + .add(false) + + .add("foo") + + .add("bar") + + .build(), + configuration + ); + } + + @Test + public void testNonUniqueArrayExtendedFromFalseTrueIsNotValidFails() { + // non-unique array extended from [false, true] is not valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + try { + schema.validate( + Arrays.asList( + false, + true, + "foo", + "foo" + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } + + @Test + public void testNonUniqueArrayExtendedFromTrueFalseIsNotValidFails() { + // non-unique array extended from [true, false] is not valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + try { + schema.validate( + Arrays.asList( + true, + false, + "foo", + "foo" + ), + configuration + ); + throw new RuntimeException("A different exception must be thrown"); + } catch (ValidationException | InvalidTypeException ignored) { + ; + } + } + + @Test + public void testFalseTrueFromItemsArrayIsValidPasses() { + // [false, true] from items array is valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItemsListBuilder() + .add(false) + + .add(true) + + .build(), + configuration + ); + } + + @Test + public void testTrueFalseFromItemsArrayIsValidPasses() { + // [true, false] from items array is valid + final var schema = UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItems1.getInstance(); + schema.validate( + new UniqueitemsWithAnArrayOfItems.UniqueitemsWithAnArrayOfItemsListBuilder() + .add(true) + + .add(false) + + .build(), + configuration + ); + } +} diff --git a/samples/client/3_1_0_unit_test/python/docs/components/schema/a_schema_given_for_prefixitems.md b/samples/client/3_1_0_unit_test/python/docs/components/schema/a_schema_given_for_prefixitems.md index 66fd80d65b9..b9fa7ced2cb 100644 --- a/samples/client/3_1_0_unit_test/python/docs/components/schema/a_schema_given_for_prefixitems.md +++ b/samples/client/3_1_0_unit_test/python/docs/components/schema/a_schema_given_for_prefixitems.md @@ -7,6 +7,6 @@ type: schemas.Schema ## validate method Input Type | Return Type | Notes ------------ | ------------- | ------------- -dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | +dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [ASchemaGivenForPrefixitemsTupleInput](#aschemagivenforprefixitemstupleinput), [ASchemaGivenForPrefixitemsTuple](#aschemagivenforprefixitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [ASchemaGivenForPrefixitemsTuple](#aschemagivenforprefixitemstuple), bytes, io.FileIO | [[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/python/docs/components/schema/additional_items_are_allowed_by_default.md b/samples/client/3_1_0_unit_test/python/docs/components/schema/additional_items_are_allowed_by_default.md index 55e49c5605e..4506f70cedb 100644 --- a/samples/client/3_1_0_unit_test/python/docs/components/schema/additional_items_are_allowed_by_default.md +++ b/samples/client/3_1_0_unit_test/python/docs/components/schema/additional_items_are_allowed_by_default.md @@ -7,6 +7,6 @@ type: schemas.Schema ## validate method Input Type | Return Type | Notes ------------ | ------------- | ------------- -dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | +dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [AdditionalItemsAreAllowedByDefaultTupleInput](#additionalitemsareallowedbydefaulttupleinput), [AdditionalItemsAreAllowedByDefaultTuple](#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [AdditionalItemsAreAllowedByDefaultTuple](#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO | [[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/python/docs/components/schema/prefixitems_with_null_instance_elements.md b/samples/client/3_1_0_unit_test/python/docs/components/schema/prefixitems_with_null_instance_elements.md index 8b93a2b6ebf..e1c66535f91 100644 --- a/samples/client/3_1_0_unit_test/python/docs/components/schema/prefixitems_with_null_instance_elements.md +++ b/samples/client/3_1_0_unit_test/python/docs/components/schema/prefixitems_with_null_instance_elements.md @@ -7,6 +7,6 @@ type: schemas.Schema ## validate method Input Type | Return Type | Notes ------------ | ------------- | ------------- -dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | +dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [PrefixitemsWithNullInstanceElementsTupleInput](#prefixitemswithnullinstanceelementstupleinput), [PrefixitemsWithNullInstanceElementsTuple](#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [PrefixitemsWithNullInstanceElementsTuple](#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO | [[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/python/docs/components/schema/uniqueitems_false_with_an_array_of_items.md b/samples/client/3_1_0_unit_test/python/docs/components/schema/uniqueitems_false_with_an_array_of_items.md index 3cb30ae5e28..f8e419b5c71 100644 --- a/samples/client/3_1_0_unit_test/python/docs/components/schema/uniqueitems_false_with_an_array_of_items.md +++ b/samples/client/3_1_0_unit_test/python/docs/components/schema/uniqueitems_false_with_an_array_of_items.md @@ -7,6 +7,6 @@ type: schemas.Schema ## validate method Input Type | Return Type | Notes ------------ | ------------- | ------------- -dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | +dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [UniqueitemsFalseWithAnArrayOfItemsTupleInput](#uniqueitemsfalsewithanarrayofitemstupleinput), [UniqueitemsFalseWithAnArrayOfItemsTuple](#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [UniqueitemsFalseWithAnArrayOfItemsTuple](#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO | [[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/python/docs/components/schema/uniqueitems_with_an_array_of_items.md b/samples/client/3_1_0_unit_test/python/docs/components/schema/uniqueitems_with_an_array_of_items.md index 56e87c27a8f..29abd65a114 100644 --- a/samples/client/3_1_0_unit_test/python/docs/components/schema/uniqueitems_with_an_array_of_items.md +++ b/samples/client/3_1_0_unit_test/python/docs/components/schema/uniqueitems_with_an_array_of_items.md @@ -7,6 +7,6 @@ type: schemas.Schema ## validate method Input Type | Return Type | Notes ------------ | ------------- | ------------- -dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | +dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [UniqueitemsWithAnArrayOfItemsTupleInput](#uniqueitemswithanarrayofitemstupleinput), [UniqueitemsWithAnArrayOfItemsTuple](#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [UniqueitemsWithAnArrayOfItemsTuple](#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO | [[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/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post.md index a19c1b57681..e45318ad04d 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post.md @@ -27,7 +27,7 @@ unit_test_api.paths.request_body_post_a_schema_given_for_prefixitems_request_bod Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader] | required | +[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTupleInput](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstupleinput), [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO, io.BufferedReader] | required | content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body. value must be one of ['application/json'] server_index | typing.Optional[int] | default is None | Allows one to select a different [server](#servers). If not None, must be one of [0] stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file @@ -49,7 +49,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTupleInput](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstupleinput), [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO ## Return Types diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post/request_body/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post/request_body/content/application_json/schema.md index f56d6c21ecc..546cbadff04 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post/request_body/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_a_schema_given_for_prefixitems_request_body/post/request_body/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../../../../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../../../../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTupleInput](../../../../../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstupleinput), [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../../../../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../../../../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post.md index 94507c7bb9b..0fad63d5795 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post.md @@ -27,7 +27,7 @@ unit_test_api.paths.request_body_post_additional_items_are_allowed_by_default_re Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader] | required | +[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTupleInput](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttupleinput), [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO, io.BufferedReader] | required | content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body. value must be one of ['application/json'] server_index | typing.Optional[int] | default is None | Allows one to select a different [server](#servers). If not None, must be one of [0] stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file @@ -49,7 +49,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTupleInput](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttupleinput), [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO ## Return Types diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post/request_body/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post/request_body/content/application_json/schema.md index 1cde4c52537..7507e21423d 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post/request_body/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_additional_items_are_allowed_by_default_request_body/post/request_body/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../../../../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../../../../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTupleInput](../../../../../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttupleinput), [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../../../../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../../../../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post.md index 3011704a181..9ec78f25a24 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post.md @@ -27,7 +27,7 @@ unit_test_api.paths.request_body_post_prefixitems_with_null_instance_elements_re Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader] | required | +[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTupleInput](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstupleinput), [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO, io.BufferedReader] | required | content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body. value must be one of ['application/json'] server_index | typing.Optional[int] | default is None | Allows one to select a different [server](#servers). If not None, must be one of [0] stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file @@ -49,7 +49,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTupleInput](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstupleinput), [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO ## Return Types diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post/request_body/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post/request_body/content/application_json/schema.md index 52a36fd9563..b5b7b581fb7 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post/request_body/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_prefixitems_with_null_instance_elements_request_body/post/request_body/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../../../../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../../../../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTupleInput](../../../../../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstupleinput), [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../../../../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../../../../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post.md index f5a5d0883dd..081a042616b 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post.md @@ -27,7 +27,7 @@ unit_test_api.paths.request_body_post_uniqueitems_false_with_an_array_of_items_r Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader] | required | +[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTupleInput](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstupleinput), [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader] | required | content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body. value must be one of ['application/json'] server_index | typing.Optional[int] | default is None | Allows one to select a different [server](#servers). If not None, must be one of [0] stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file @@ -49,7 +49,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTupleInput](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstupleinput), [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO ## Return Types diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md index f59d1cff670..a80d06fcc9a 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_false_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTupleInput](../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstupleinput), [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post.md index a4bba89645c..8502e128274 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post.md @@ -27,7 +27,7 @@ unit_test_api.paths.request_body_post_uniqueitems_with_an_array_of_items_request Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader] | required | +[body](#requestbody) | typing.Union[dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTupleInput](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstupleinput), [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader] | required | content_type | str | optional, default is 'application/json' | Selects the schema and serialization of the request body. value must be one of ['application/json'] server_index | typing.Optional[int] | default is None | Allows one to select a different [server](#servers). If not None, must be one of [0] stream | bool | default is False | if True then the response.content will be streamed and loaded from a file like object. When downloading a file, set this to True to force the code to deserialize the content to a FileSchema file @@ -49,7 +49,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTupleInput](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstupleinput), [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO ## Return Types diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md index f81c5acd050..8c4f018a3f2 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/request_body_post_uniqueitems_with_an_array_of_items_request_body/post/request_body/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../../../../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../../../../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTupleInput](../../../../../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstupleinput), [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../../../../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../../../../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post.md index bbeee255413..a3ae9793aa3 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post.md @@ -49,7 +49,7 @@ success Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | -[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | | +[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO | | headers | Unset | headers were not defined | ### ResponseFor200 Body @@ -66,7 +66,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTupleInput](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstupleinput), [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO ## Servers diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md index fc5d0f44cb2..dec76a4120a 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_a_schema_given_for_prefixitems_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../../../../../../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**a_schema_given_for_prefixitems.ASchemaGivenForPrefixitems**](../../../../../../../../components/schema/a_schema_given_for_prefixitems.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTupleInput](../../../../../../../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstupleinput), [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../../../../../../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [a_schema_given_for_prefixitems.ASchemaGivenForPrefixitemsTuple](../../../../../../../../components/schema/a_schema_given_for_prefixitems.md#aschemagivenforprefixitemstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post.md index 331816df77d..8eb7d332353 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post.md @@ -49,7 +49,7 @@ success Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | -[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | | +[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO | | headers | Unset | headers were not defined | ### ResponseFor200 Body @@ -66,7 +66,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTupleInput](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttupleinput), [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO ## Servers diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md index 020d2c956c2..7ae09f9acee 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_additional_items_are_allowed_by_default_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../../../../../../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefault**](../../../../../../../../components/schema/additional_items_are_allowed_by_default.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTupleInput](../../../../../../../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttupleinput), [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../../../../../../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [additional_items_are_allowed_by_default.AdditionalItemsAreAllowedByDefaultTuple](../../../../../../../../components/schema/additional_items_are_allowed_by_default.md#additionalitemsareallowedbydefaulttuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post.md index ed805d5b491..856d9af61af 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post.md @@ -49,7 +49,7 @@ success Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | -[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | | +[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO | | headers | Unset | headers were not defined | ### ResponseFor200 Body @@ -66,7 +66,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTupleInput](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstupleinput), [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO ## Servers diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md index f21a7b930c6..dbaee00bc05 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_prefixitems_with_null_instance_elements_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../../../../../../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElements**](../../../../../../../../components/schema/prefixitems_with_null_instance_elements.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTupleInput](../../../../../../../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstupleinput), [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../../../../../../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [prefixitems_with_null_instance_elements.PrefixitemsWithNullInstanceElementsTuple](../../../../../../../../components/schema/prefixitems_with_null_instance_elements.md#prefixitemswithnullinstanceelementstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post.md index b7f9ec6a65e..ba4a54c34c4 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post.md @@ -49,7 +49,7 @@ success Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | -[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | | +[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO | | headers | Unset | headers were not defined | ### ResponseFor200 Body @@ -66,7 +66,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTupleInput](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstupleinput), [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO ## Servers diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md index 73b54b8fa19..6d1432e61f0 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_false_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItems**](../../../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTupleInput](../../../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstupleinput), [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_false_with_an_array_of_items.UniqueitemsFalseWithAnArrayOfItemsTuple](../../../../../../../../components/schema/uniqueitems_false_with_an_array_of_items.md#uniqueitemsfalsewithanarrayofitemstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post.md index 86264ee03e4..492e171bcd6 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post.md @@ -49,7 +49,7 @@ success Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- response | urllib3.HTTPResponse | Raw response | -[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | | +[body](#responsefor200-body) | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO | | headers | Unset | headers were not defined | ### ResponseFor200 Body @@ -66,7 +66,7 @@ type: schemas.Schema ##### Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTupleInput](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstupleinput), [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO ## Servers diff --git a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md index f349abe4469..7a3a0bfc2c5 100644 --- a/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md +++ b/samples/client/3_1_0_unit_test/python/docs/paths/response_body_post_uniqueitems_with_an_array_of_items_response_body_for_content_types/post/responses/response_200/content/application_json/schema.md @@ -6,4 +6,4 @@ type: schemas.Schema ## Ref Schema Info Ref Schema | Input Type | Output Type ---------- | ---------- | ----------- -[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../../../../../../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO +[**uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItems**](../../../../../../../../components/schema/uniqueitems_with_an_array_of_items.md) | dict, schemas.immutabledict, str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTupleInput](../../../../../../../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstupleinput), [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../../../../../../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO, io.BufferedReader | schemas.immutabledict, str, float, int, bool, None, [uniqueitems_with_an_array_of_items.UniqueitemsWithAnArrayOfItemsTuple](../../../../../../../../components/schema/uniqueitems_with_an_array_of_items.md#uniqueitemswithanarrayofitemstuple), bytes, io.FileIO diff --git a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/a_schema_given_for_prefixitems.py b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/a_schema_given_for_prefixitems.py index 77fe200c2d7..2db85885783 100644 --- a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/a_schema_given_for_prefixitems.py +++ b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/a_schema_given_for_prefixitems.py @@ -10,13 +10,38 @@ from __future__ import annotations from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary] + + +class ASchemaGivenForPrefixitemsTuple( + typing.Tuple[ + int, + str, + typing_extensions.Unpack[typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]] + ] +): + + def __new__(cls, arg: typing.Union[ASchemaGivenForPrefixitemsTupleInput, ASchemaGivenForPrefixitemsTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None): + return ASchemaGivenForPrefixitems.validate(arg, configuration=configuration) +ASchemaGivenForPrefixitemsTupleInput = typing.Union[ + typing.List[ + typing.Union[ + schemas.INPUT_TYPES_ALL, + schemas.OUTPUT_BASE_TYPES + ], + ], + typing.Tuple[ + int, + str, + typing_extensions.Unpack[typing.Tuple[schemas.INPUT_TYPES_ALL, ...]] + ] +] _0: typing_extensions.TypeAlias = schemas.IntSchema _1: typing_extensions.TypeAlias = schemas.StrSchema @dataclasses.dataclass(frozen=True) class ASchemaGivenForPrefixitems( - schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]], + schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], ASchemaGivenForPrefixitemsTuple], ): """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -31,4 +56,12 @@ class ASchemaGivenForPrefixitems( _0, _1, ) + type_to_output_cls: typing.Mapping[ + typing.Type, + typing.Type + ] = dataclasses.field( + default_factory=lambda: { + tuple: ASchemaGivenForPrefixitemsTuple, + } + ) diff --git a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/additional_items_are_allowed_by_default.py b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/additional_items_are_allowed_by_default.py index 5b6e67fc234..47b6ea9b4b6 100644 --- a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/additional_items_are_allowed_by_default.py +++ b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/additional_items_are_allowed_by_default.py @@ -10,12 +10,35 @@ from __future__ import annotations from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary] + + +class AdditionalItemsAreAllowedByDefaultTuple( + typing.Tuple[ + int, + typing_extensions.Unpack[typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]] + ] +): + + def __new__(cls, arg: typing.Union[AdditionalItemsAreAllowedByDefaultTupleInput, AdditionalItemsAreAllowedByDefaultTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None): + return AdditionalItemsAreAllowedByDefault.validate(arg, configuration=configuration) +AdditionalItemsAreAllowedByDefaultTupleInput = typing.Union[ + typing.List[ + typing.Union[ + schemas.INPUT_TYPES_ALL, + schemas.OUTPUT_BASE_TYPES + ], + ], + typing.Tuple[ + int, + typing_extensions.Unpack[typing.Tuple[schemas.INPUT_TYPES_ALL, ...]] + ] +] _0: typing_extensions.TypeAlias = schemas.IntSchema @dataclasses.dataclass(frozen=True) class AdditionalItemsAreAllowedByDefault( - schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]], + schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], AdditionalItemsAreAllowedByDefaultTuple], ): """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -28,4 +51,12 @@ class AdditionalItemsAreAllowedByDefault( ] = ( _0, ) + type_to_output_cls: typing.Mapping[ + typing.Type, + typing.Type + ] = dataclasses.field( + default_factory=lambda: { + tuple: AdditionalItemsAreAllowedByDefaultTuple, + } + ) diff --git a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_validation_adjusts_the_starting_index_for_items.py b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_validation_adjusts_the_starting_index_for_items.py index 807b9de8239..4269f3a6fe7 100644 --- a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_validation_adjusts_the_starting_index_for_items.py +++ b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_validation_adjusts_the_starting_index_for_items.py @@ -15,8 +15,11 @@ class PrefixitemsValidationAdjustsTheStartingIndexForItemsTuple( typing.Tuple[ - int, - ... + str, + typing_extensions.Unpack[typing.Tuple[ + int, + ... + ]] ] ): @@ -24,11 +27,17 @@ def __new__(cls, arg: typing.Union[PrefixitemsValidationAdjustsTheStartingIndexF return PrefixitemsValidationAdjustsTheStartingIndexForItems.validate(arg, configuration=configuration) PrefixitemsValidationAdjustsTheStartingIndexForItemsTupleInput = typing.Union[ typing.List[ - int, + typing.Union[ + int, + str, + ], ], typing.Tuple[ - int, - ... + str, + typing_extensions.Unpack[typing.Tuple[ + int, + ... + ]] ] ] _0: typing_extensions.TypeAlias = schemas.StrSchema diff --git a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_with_null_instance_elements.py b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_with_null_instance_elements.py index 1846da2666c..dd6a7883f53 100644 --- a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_with_null_instance_elements.py +++ b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/prefixitems_with_null_instance_elements.py @@ -10,12 +10,35 @@ from __future__ import annotations from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary] + + +class PrefixitemsWithNullInstanceElementsTuple( + typing.Tuple[ + None, + typing_extensions.Unpack[typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]] + ] +): + + def __new__(cls, arg: typing.Union[PrefixitemsWithNullInstanceElementsTupleInput, PrefixitemsWithNullInstanceElementsTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None): + return PrefixitemsWithNullInstanceElements.validate(arg, configuration=configuration) +PrefixitemsWithNullInstanceElementsTupleInput = typing.Union[ + typing.List[ + typing.Union[ + schemas.INPUT_TYPES_ALL, + schemas.OUTPUT_BASE_TYPES + ], + ], + typing.Tuple[ + None, + typing_extensions.Unpack[typing.Tuple[schemas.INPUT_TYPES_ALL, ...]] + ] +] _0: typing_extensions.TypeAlias = schemas.NoneSchema @dataclasses.dataclass(frozen=True) class PrefixitemsWithNullInstanceElements( - schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]], + schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], PrefixitemsWithNullInstanceElementsTuple], ): """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -28,4 +51,12 @@ class PrefixitemsWithNullInstanceElements( ] = ( _0, ) + type_to_output_cls: typing.Mapping[ + typing.Type, + typing.Type + ] = dataclasses.field( + default_factory=lambda: { + tuple: PrefixitemsWithNullInstanceElementsTuple, + } + ) diff --git a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_with_an_array_of_items.py b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_with_an_array_of_items.py index c64ed411129..b2ee137a644 100644 --- a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_with_an_array_of_items.py +++ b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_with_an_array_of_items.py @@ -10,13 +10,38 @@ from __future__ import annotations from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary] + + +class UniqueitemsFalseWithAnArrayOfItemsTuple( + typing.Tuple[ + bool, + bool, + typing_extensions.Unpack[typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]] + ] +): + + def __new__(cls, arg: typing.Union[UniqueitemsFalseWithAnArrayOfItemsTupleInput, UniqueitemsFalseWithAnArrayOfItemsTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None): + return UniqueitemsFalseWithAnArrayOfItems.validate(arg, configuration=configuration) +UniqueitemsFalseWithAnArrayOfItemsTupleInput = typing.Union[ + typing.List[ + typing.Union[ + schemas.INPUT_TYPES_ALL, + schemas.OUTPUT_BASE_TYPES + ], + ], + typing.Tuple[ + bool, + bool, + typing_extensions.Unpack[typing.Tuple[schemas.INPUT_TYPES_ALL, ...]] + ] +] _0: typing_extensions.TypeAlias = schemas.BoolSchema _1: typing_extensions.TypeAlias = schemas.BoolSchema @dataclasses.dataclass(frozen=True) class UniqueitemsFalseWithAnArrayOfItems( - schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]], + schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], UniqueitemsFalseWithAnArrayOfItemsTuple], ): """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -32,4 +57,12 @@ class UniqueitemsFalseWithAnArrayOfItems( _1, ) unique_items: bool = False + type_to_output_cls: typing.Mapping[ + typing.Type, + typing.Type + ] = dataclasses.field( + default_factory=lambda: { + tuple: UniqueitemsFalseWithAnArrayOfItemsTuple, + } + ) diff --git a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_with_an_array_of_items.py b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_with_an_array_of_items.py index 6ea7d36dab8..0bd69fc4585 100644 --- a/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_with_an_array_of_items.py +++ b/samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_with_an_array_of_items.py @@ -10,13 +10,38 @@ from __future__ import annotations from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary] + + +class UniqueitemsWithAnArrayOfItemsTuple( + typing.Tuple[ + bool, + bool, + typing_extensions.Unpack[typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]] + ] +): + + def __new__(cls, arg: typing.Union[UniqueitemsWithAnArrayOfItemsTupleInput, UniqueitemsWithAnArrayOfItemsTuple], configuration: typing.Optional[schema_configuration.SchemaConfiguration] = None): + return UniqueitemsWithAnArrayOfItems.validate(arg, configuration=configuration) +UniqueitemsWithAnArrayOfItemsTupleInput = typing.Union[ + typing.List[ + typing.Union[ + schemas.INPUT_TYPES_ALL, + schemas.OUTPUT_BASE_TYPES + ], + ], + typing.Tuple[ + bool, + bool, + typing_extensions.Unpack[typing.Tuple[schemas.INPUT_TYPES_ALL, ...]] + ] +] _0: typing_extensions.TypeAlias = schemas.BoolSchema _1: typing_extensions.TypeAlias = schemas.BoolSchema @dataclasses.dataclass(frozen=True) class UniqueitemsWithAnArrayOfItems( - schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]], + schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], UniqueitemsWithAnArrayOfItemsTuple], ): """NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -32,4 +57,12 @@ class UniqueitemsWithAnArrayOfItems( _1, ) unique_items: bool = True + type_to_output_cls: typing.Mapping[ + typing.Type, + typing.Type + ] = dataclasses.field( + default_factory=lambda: { + tuple: UniqueitemsWithAnArrayOfItemsTuple, + } + ) diff --git a/samples/client/petstore/java/.openapi-generator/FILES b/samples/client/petstore/java/.openapi-generator/FILES index e9b99c98b10..8b8e9472022 100644 --- a/samples/client/petstore/java/.openapi-generator/FILES +++ b/samples/client/petstore/java/.openapi-generator/FILES @@ -737,6 +737,7 @@ src/main/java/org/openapijsonschematools/client/schemas/validation/OneOfValidato src/main/java/org/openapijsonschematools/client/schemas/validation/PathToSchemasMap.java src/main/java/org/openapijsonschematools/client/schemas/validation/PatternPropertiesValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PatternValidator.java +src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertiesValidator.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyEntry.java src/main/java/org/openapijsonschematools/client/schemas/validation/PropertyNamesValidator.java diff --git a/samples/client/petstore/java/docs/components/schemas/ArrayOfEnums.md b/samples/client/petstore/java/docs/components/schemas/ArrayOfEnums.md index f2e932de286..865006715cb 100644 --- a/samples/client/petstore/java/docs/components/schemas/ArrayOfEnums.md +++ b/samples/client/petstore/java/docs/components/schemas/ArrayOfEnums.md @@ -39,7 +39,7 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch ArrayOfEnums.ArrayOfEnumsList validatedPayload = ArrayOfEnums.ArrayOfEnums1.validate( new ArrayOfEnums.ArrayOfEnumsListBuilder() - .add(null) + .add((Void) null) .build(), configuration diff --git a/samples/client/petstore/java/docs/components/schemas/NullableClass.md b/samples/client/petstore/java/docs/components/schemas/NullableClass.md index c7620434051..b2935778aec 100644 --- a/samples/client/petstore/java/docs/components/schemas/NullableClass.md +++ b/samples/client/petstore/java/docs/components/schemas/NullableClass.md @@ -537,7 +537,7 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch NullableClass.ArrayItemsNullableList validatedPayload = NullableClass.ArrayItemsNullable.validate( new NullableClass.ArrayItemsNullableListBuilder() - .add(null) + .add((Void) null) .build(), configuration @@ -655,7 +655,7 @@ Void validatedPayload = NullableClass.ArrayAndItemsNullableProp.validate( NullableClass.ArrayAndItemsNullablePropList validatedPayload = NullableClass.ArrayAndItemsNullableProp.validate( new NullableClass.ArrayAndItemsNullablePropListBuilder() - .add(null) + .add((Void) null) .build(), configuration 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 bf3ee6ecf15..cf66ce04470 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 @@ -20,13 +20,16 @@ public ItemsValidator(Class items) { @Nullable List containsPathToSchemas, @Nullable PathToSchemasMap patternPropertiesPathToSchemas ) { - if (!(arg instanceof List)) { + if (!(arg instanceof List listArg)) { + return null; + } + if (listArg.isEmpty()) { return null; } PathToSchemasMap pathToSchemas = new PathToSchemasMap(); - // todo add handling for prefixItems - int i = 0; - for(Object itemValue: (List) arg) { + int minIndex = schema.prefixItems != null ? schema.prefixItems.size() : 0; + JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); + for(int i = minIndex; i < listArg.size(); i++) { List itemPathToItem = new ArrayList<>(validationMetadata.pathToItem()); itemPathToItem.add(i); ValidationMetadata itemValidationMetadata = new ValidationMetadata( @@ -35,15 +38,12 @@ public ItemsValidator(Class items) { validationMetadata.validatedPathToSchemas(), validationMetadata.seenClasses() ); - JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); if (itemValidationMetadata.validationRanEarlier(itemsSchema)) { // todo add_deeper_validated_schemas - i +=1; continue; } - PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, itemValue, itemValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, listArg.get(i), itemValidationMetadata); pathToSchemas.update(otherPathToSchemas); - i += 1; } return pathToSchemas; } 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 e567b7f5dc2..33fc4a78e91 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 @@ -53,6 +53,7 @@ public abstract class JsonSchema { public @Nullable Map> dependentRequired; public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; + public @Nullable List> prefixItems; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -284,6 +285,13 @@ protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { new PatternPropertiesValidator(this.patternProperties) ); } + this.prefixItems = jsonSchemaInfo.prefixItems; + if (this.prefixItems != null) { + keywordToValidator.put( + "prefixItems", + new PrefixItemsValidator(this.prefixItems) + ); + } this.keywordToValidator = keywordToValidator; } 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 45c911b0c18..16554a769d5 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 @@ -177,4 +177,9 @@ public JsonSchemaInfo patternProperties(Map this.patternProperties = patternProperties; return this; } + public @Nullable List> prefixItems = null; + public JsonSchemaInfo prefixItems(List> prefixItems) { + this.prefixItems = prefixItems; + return this; + } } \ No newline at end of file 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 new file mode 100644 index 00000000000..4163833addb --- /dev/null +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/client/schemas/validation/PrefixItemsValidator.java @@ -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> prefixItems; + + public PrefixItemsValidator(List> prefixItems) { + this.prefixItems = prefixItems; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List 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 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; + } +} diff --git a/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java b/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java index b3cdb2baf3b..652a4a068d4 100644 --- a/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java +++ b/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java @@ -2378,6 +2378,20 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ property.items = fromSchema( p.getItems(), sourceJsonPath, currentJsonPath + "/items"); } + if (property.prefixItems != null || property.items != null) { + if (property.prefixItems == null) { + property.listItemSchema = property.items; + } else if (property.items == null) { + // any type of items may be added on after prefixItems + property.listItemSchema = new CodegenSchema(); + } else { + // items + prefixItems exists + property.listItemSchema = property.items; + for (CodegenSchema prefixItem: property.prefixItems) { + property.listItemSchema = property.listItemSchema.add(prefixItem); + } + } + } if (p.getIf() != null) { property.if_ = fromSchema(p.getIf(), sourceJsonPath, currentJsonPath + "/if"); } @@ -2445,7 +2459,7 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ break; } } - if ((property.types == null || property.types.contains("array")) && sourceJsonPath != null && property.items != null) { + if ((property.types == null || property.types.contains("array")) && sourceJsonPath != null && (property.items != null || property.prefixItems != null)) { property.arrayOutputJsonPathPiece = getKey(currentName + arrayIOClassNamePiece, "schemaProperty", sourceJsonPath); property.arrayInputJsonPathPiece = getKey(currentName + arrayIOClassNamePiece+arrayObjectInputClassNameSuffix, "schemaProperty", sourceJsonPath); } diff --git a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java index 08b580f6fbd..3b96433ae9b 100644 --- a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java +++ b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java @@ -284,7 +284,7 @@ public JavaClientGenerator() { SchemaFeature.OneOf, SchemaFeature.Pattern, SchemaFeature.PatternProperties, - // SchemaFeature.PrefixItems, + SchemaFeature.PrefixItems, SchemaFeature.Properties, SchemaFeature.PropertyNames, SchemaFeature.Ref, @@ -613,6 +613,7 @@ public void processOpts() { keywordValidatorFiles.add("PathToSchemasMap"); keywordValidatorFiles.add("PatternPropertiesValidator"); keywordValidatorFiles.add("PatternValidator"); + keywordValidatorFiles.add("PrefixItemsValidator"); keywordValidatorFiles.add("PropertiesValidator"); keywordValidatorFiles.add("PropertyEntry"); keywordValidatorFiles.add("PropertyNamesValidator"); diff --git a/src/main/java/org/openapijsonschematools/codegen/generators/openapimodels/CodegenSchema.java b/src/main/java/org/openapijsonschematools/codegen/generators/openapimodels/CodegenSchema.java index 9def00182e4..ef243974c18 100644 --- a/src/main/java/org/openapijsonschematools/codegen/generators/openapimodels/CodegenSchema.java +++ b/src/main/java/org/openapijsonschematools/codegen/generators/openapimodels/CodegenSchema.java @@ -123,6 +123,7 @@ public class CodegenSchema { public CodegenKey containerJsonPathPiece; // needed by java, outer class that has inner nested schema classes public LinkedHashMap typeToExample = null; public List mapBuilders = null; // used by java + public CodegenSchema listItemSchema; // 3.1.0 the type of any list item public boolean isCustomSchema() { // true when schema class is directly extended, false otherwise @@ -620,21 +621,30 @@ public void getAllSchemas(ArrayList schemasBeforeImports, ArrayLi if (if_ != null) { if_.getAllSchemas(schemasBeforeImports, schemasAfterImports, level + 1, propertyInputTypesUnique); } - if (items != null) { - items.getAllSchemas(schemasBeforeImports, schemasAfterImports, level + 1, propertyInputTypesUnique); + if (arrayInputJsonPathPiece != null) { + if (items != null) { + items.getAllSchemas(schemasBeforeImports, schemasAfterImports, level + 1, propertyInputTypesUnique); + } CodegenSchema extraSchema = new CodegenSchema(); extraSchema.instanceType = "arrayOutputType"; extraSchema.items = items; + extraSchema.prefixItems = prefixItems; + extraSchema.listItemSchema = listItemSchema; extraSchema.arrayOutputJsonPathPiece = arrayOutputJsonPathPiece; // needed to define input type for new method extraSchema.arrayInputJsonPathPiece = arrayInputJsonPathPiece; // needed to invoke Schema validation from the output class extraSchema.jsonPathPiece = jsonPathPiece; extraSchema.jsonPath = jsonPath; - if (items.hasAnyRefs()) { - schemaAllAreInline = false; - schemasAfterImports.add(extraSchema); + if (items != null) { + if (items.hasAnyRefs()) { + schemaAllAreInline = false; + schemasAfterImports.add(extraSchema); + } else { + schemasBeforeImports.add(extraSchema); + } } else { + // assume no refs schemasBeforeImports.add(extraSchema); } } @@ -642,11 +652,18 @@ public void getAllSchemas(ArrayList schemasBeforeImports, ArrayLi CodegenSchema extraSchema = new CodegenSchema(); extraSchema.instanceType = "arrayInputType"; extraSchema.items = items; + extraSchema.prefixItems = prefixItems; + extraSchema.listItemSchema = listItemSchema; extraSchema.arrayInputJsonPathPiece = arrayInputJsonPathPiece; extraSchema.jsonPath = jsonPath; // needed to prevent recursion when rendering template data type - if (items.hasAnyRefs()) { - schemasAfterImports.add(extraSchema); + if (items != null) { + if (items.hasAnyRefs()) { + schemasAfterImports.add(extraSchema); + } else { + schemasBeforeImports.add(extraSchema); + } } else { + // assume no refs schemasBeforeImports.add(extraSchema); } } 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 7fc9005e25d..e6cc59cc638 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 @@ -120,6 +120,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements { {{#if patternProperties}} {{> src/main/java/packagename/components/schemas/SchemaClass/_patternProperties }} {{/if}} + {{#if prefixItems}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_prefixItems }} + {{/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 4a0f2355b4c..8fba1860d25 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 @@ -53,6 +53,9 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements L {{#neq minContains null}} {{> src/main/java/packagename/components/schemas/SchemaClass/_minContains }} {{/neq}} + {{#if prefixItems}} + {{> src/main/java/packagename/components/schemas/SchemaClass/_prefixItems }} + {{/if}} ); } @@ -62,9 +65,6 @@ public static class {{jsonPathPiece.pascalCase}} extends JsonSchema implements L } return instance; } - {{#if prefixItems}} - {{!> components/schemas/schema_cls/_prefix_items }} - {{/if}} {{#if if_}} {{!> components/schemas/schema_cls/_if }} {{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_prefixItems.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_prefixItems.hbs new file mode 100644 index 00000000000..a4eb8178e12 --- /dev/null +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_prefixItems.hbs @@ -0,0 +1,29 @@ +{{#if forDocs}} +prefixItems = List.of(
+ {{~#each prefixItems}} + {{#if refInfo.refClass}} + {{#if refInfo.refModule}} +    [{{refInfo.refModule}}.{{refInfo.refClass}}.class]({{docRoot}}{{refInfo.ref.pathFromDocRoot}}.md#{{refInfo.ref.jsonPathPiece.kebabCase}}){{#unless @last}},{{/unless}}
+ {{~else}} +    [{{refInfo.refClass}}.class](#{{refInfo.ref.jsonPathPiece.kebabCase}}){{#unless @last}},{{/unless}}
+ {{~/if}} + {{else}} +    [{{jsonPathPiece.pascalCase}}.class](#{{jsonPathPiece.kebabCase}}){{#unless @last}},{{/unless}}
+ {{~/if}} + {{/each}} +)
+{{~else}} +.prefixItems(List.of( + {{#each prefixItems}} + {{#if refInfo.refClass}} + {{#if refInfo.refModule}} + {{refInfo.refModule}}.{{refInfo.refClass}}.class{{#unless @last}},{{/unless}} + {{else}} + {{refInfo.refClass}}.class{{#unless @last}},{{/unless}} + {{/if}} + {{else}} + {{jsonPathPiece.pascalCase}}.class{{#unless @last}},{{/unless}} + {{/if}} + {{/each}} +)) +{{/if}} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_validate_implementor.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_validate_implementor.hbs index bc4c3c1a3d0..c4366dc64e7 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_validate_implementor.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/SchemaClass/_validate_implementor.hbs @@ -67,8 +67,8 @@ public {{#if ../mapOutputJsonPathPiece}}{{../mapOutputJsonPathPiece.pascalCase}} {{#eq this "array"}} @Override -public {{#if ../arrayOutputJsonPathPiece}}{{../arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with ../items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { - List<{{#with ../items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> items = new ArrayList<>(); +public {{#if ../arrayOutputJsonPathPiece}}{{../arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with ../listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + List<{{#with ../listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> items = new ArrayList<>(); int i = 0; for (Object item: arg) { List itemPathToItem = new ArrayList<>(pathToItem); @@ -79,21 +79,21 @@ public {{#if ../arrayOutputJsonPathPiece}}{{../arrayOutputJsonPathPiece.pascalCa } JsonSchema itemSchema = schemas.entrySet().iterator().next().getKey(); @Nullable Object itemInstance = itemSchema.getNewInstance(item, itemPathToItem, pathToSchemas); - {{#if ../items}} - {{#if ../items.isNullableObject }} + {{#if ../listItemSchema}} + {{#if ../listItemSchema.isNullableObject }} items.add(itemInstance); {{else}} - if (!({{#contains ../items.types "null" }}itemInstance == null || {{/contains}}itemInstance instanceof {{#with ../items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true noAnnotations=true }}{{else}}Object{{/with}})) { + if (!({{#contains ../listItemSchema.types "null" }}itemInstance == null || {{/contains}}itemInstance instanceof {{#with ../listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true noAnnotations=true }}{{else}}Object{{/with}})) { throw new InvalidTypeException("Invalid instantiated value"); } - items.add(({{#with ../items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}) itemInstance); + items.add(({{#with ../listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}) itemInstance); {{/if}} {{else}} items.add(itemInstance); {{/if}} i += 1; } - FrozenList<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> newInstanceItems = new FrozenList<>(items); + FrozenList<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> newInstanceItems = new FrozenList<>(items); {{#if ../arrayOutputJsonPathPiece}} return new {{../arrayOutputJsonPathPiece.pascalCase}}(newInstanceItems); {{else}} @@ -101,7 +101,7 @@ public {{#if ../arrayOutputJsonPathPiece}}{{../arrayOutputJsonPathPiece.pascalCa {{/if}} } -public {{#if ../arrayOutputJsonPathPiece}}{{../arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with ../items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} validate(List arg, SchemaConfiguration configuration) throws ValidationException { +public {{#if ../arrayOutputJsonPathPiece}}{{../arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with ../listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} validate(List arg, SchemaConfiguration configuration) throws ValidationException { Set> pathSet = new HashSet<>(); List pathToItem = List.of("args[0"); List castArg = castToAllowedTypes(arg, pathToItem, pathSet); @@ -324,8 +324,8 @@ public String validate(UUID arg, SchemaConfiguration configuration) throws Valid } @Override -public {{#if arrayOutputJsonPathPiece}}{{arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { - List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> items = new ArrayList<>(); +public {{#if arrayOutputJsonPathPiece}}{{arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} getNewInstance(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> items = new ArrayList<>(); int i = 0; for (Object item: arg) { List itemPathToItem = new ArrayList<>(pathToItem); @@ -336,21 +336,21 @@ public {{#if arrayOutputJsonPathPiece}}{{arrayOutputJsonPathPiece.pascalCase}}{{ } JsonSchema itemSchema = schemas.entrySet().iterator().next().getKey(); @Nullable Object itemInstance = itemSchema.getNewInstance(item, itemPathToItem, pathToSchemas); - {{#if items}} - {{#if items.isNullableObject }} + {{#if listItemSchema}} + {{#if listItemSchema.isNullableObject }} items.add(itemInstance); {{else}} - if (!({{#contains items.types "null" }}itemInstance == null || {{/contains}}itemInstance instanceof {{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true noAnnotations=true }}{{else}}Object{{/with}})) { + if (!({{#contains listItemSchema.types "null" }}itemInstance == null || {{/contains}}itemInstance instanceof {{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true noAnnotations=true }}{{else}}Object{{/with}})) { throw new InvalidTypeException("Invalid instantiated value"); } - items.add(({{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}) itemInstance); + items.add(({{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}) itemInstance); {{/if}} {{else}} items.add(itemInstance); {{/if}} i += 1; } - FrozenList<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> newInstanceItems = new FrozenList<>(items); + FrozenList<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}> newInstanceItems = new FrozenList<>(items); {{#if arrayOutputJsonPathPiece}} return new {{arrayOutputJsonPathPiece.pascalCase}}(newInstanceItems); {{else}} @@ -358,7 +358,7 @@ public {{#if arrayOutputJsonPathPiece}}{{arrayOutputJsonPathPiece.pascalCase}}{{ {{/if}} } -public {{#if arrayOutputJsonPathPiece}}{{arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with ../items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} validate(List arg, SchemaConfiguration configuration) throws ValidationException { +public {{#if arrayOutputJsonPathPiece}}{{arrayOutputJsonPathPiece.pascalCase}}{{else}}FrozenList<{{#with ../listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type sourceJsonPath=../jsonPath forceNull=true }}{{else}}@Nullable Object{{/with}}>{{/if}} validate(List arg, SchemaConfiguration configuration) throws ValidationException { Set> pathSet = new HashSet<>(); List pathToItem = List.of("args[0"); List castArg = castToAllowedTypes(arg, pathToItem, pathSet); diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/Schema_doc.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/Schema_doc.hbs index 472a539b792..b549a8905f7 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/Schema_doc.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/Schema_doc.hbs @@ -154,14 +154,14 @@ A class to store validated Map payloads {{> src/main/java/packagename/components/_helper_header_from_identifier_pieces headerSize=(join headerSize "#" "") identifierPieces=(append identifierPieces arrayOutputJsonPathPiece) }} public class {{arrayOutputJsonPathPiece.pascalCase}}
-extends `FrozenList<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type forceNull=true }}{{else}}Object{{/with}}>` +extends `FrozenList<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type forceNull=true }}{{else}}Object{{/with}}>` A class to store validated List payloads {{headerSize}}## Method Summary | Modifier and Type | Method and Description | | ----------------- | ---------------------- | -| static [{{arrayOutputJsonPathPiece.pascalCase}}](#{{> src/main/java/packagename/components/_helper_anchor_id identifierPieces=(append identifierPieces arrayOutputJsonPathPiece) }}) | of([List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true }}{{/with}}>](#{{> src/main/java/packagename/components/_helper_anchor_id identifierPieces=(append identifierPieces arrayInputJsonPathPiece) }}) arg, SchemaConfiguration configuration) | +| static [{{arrayOutputJsonPathPiece.pascalCase}}](#{{> src/main/java/packagename/components/_helper_anchor_id identifierPieces=(append identifierPieces arrayOutputJsonPathPiece) }}) | of([List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true }}{{/with}}>](#{{> src/main/java/packagename/components/_helper_anchor_id identifierPieces=(append identifierPieces arrayInputJsonPathPiece) }}) arg, SchemaConfiguration configuration) | {{else}} {{#eq instanceType "arrayInputType"}} {{> src/main/java/packagename/components/schemas/docschema_arrayInput }} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputAddItem.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputAddItem.hbs index e9e2f0e3e7e..f2855fbc365 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputAddItem.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputAddItem.hbs @@ -67,10 +67,10 @@ public {{builderClass}} add(double item) { {{else}} {{#eq this "array"}} {{#if forDocs }} -| {{builderClass}} | add(List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> item) | +| {{builderClass}} | add(List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> item) | {{else}} -public {{builderClass}} add(List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> item) { +public {{builderClass}} add(List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> item) { list.add(item); return this; } diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputType.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputType.hbs index bef693b308e..1f0b52755ca 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputType.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayInputType.hbs @@ -1,17 +1,17 @@ -{{#if items}} +{{#if listItemSchema}} public static class {{arrayInputJsonPathPiece.pascalCase}} { - // class to build List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> - private final List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> list; + // class to build List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> + private final List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> list; public {{arrayInputJsonPathPiece.pascalCase}}() { list = new ArrayList<>(); } - public {{arrayInputJsonPathPiece.pascalCase}}(List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> list) { + public {{arrayInputJsonPathPiece.pascalCase}}(List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> list) { this.list = list; } - {{#with items}} + {{#with listItemSchema}} {{#if refInfo }} {{#if refInfo.refModule}} {{#with getDeepestRef }} @@ -32,7 +32,7 @@ public static class {{arrayInputJsonPathPiece.pascalCase}} { {{! todo handle this, 3.1.0 document use-case }} {{/with}} - public List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> build() { + public List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{/with}}> build() { return list; } } diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayOutputType.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayOutputType.hbs index b62bf7351f0..157d668d23d 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayOutputType.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/_arrayOutputType.hbs @@ -1,10 +1,10 @@ -public static class {{arrayOutputJsonPathPiece.pascalCase}} extends FrozenList<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type fullRefModule="" forceNull=true }}{{/with}}> { - protected {{arrayOutputJsonPathPiece.pascalCase}}(FrozenList<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_output_type fullRefModule="" forceNull=true }}{{/with}}> m) { +public static class {{arrayOutputJsonPathPiece.pascalCase}} extends FrozenList<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type fullRefModule="" forceNull=true }}{{/with}}> { + protected {{arrayOutputJsonPathPiece.pascalCase}}(FrozenList<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_output_type fullRefModule="" forceNull=true }}{{/with}}> m) { super(m); } - public static {{arrayOutputJsonPathPiece.pascalCase}} of(List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true }}{{/with}}> arg, SchemaConfiguration configuration) throws ValidationException { + public static {{arrayOutputJsonPathPiece.pascalCase}} of(List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true }}{{/with}}> arg, SchemaConfiguration configuration) throws ValidationException { return {{jsonPathPiece.pascalCase}}.getInstance().validate(arg, configuration); } } diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_arrayInput.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_arrayInput.hbs index 1e9169a471d..5b1a941fbc6 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_arrayInput.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/docschema_arrayInput.hbs @@ -1,7 +1,7 @@ {{> src/main/java/packagename/components/_helper_header_from_identifier_pieces headerSize=(join headerSize "#" "") identifierPieces=(append identifierPieces arrayInputJsonPathPiece) }} public class {{arrayInputJsonPathPiece.pascalCase}}
-builder for `List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}>` +builder for `List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}>` A class that builds the List input type @@ -9,12 +9,12 @@ A class that builds the List input type | Constructor and Description | | --------------------------- | | {{arrayInputJsonPathPiece.pascalCase}}()
Creates an empty list | -| {{arrayInputJsonPathPiece.pascalCase}}(List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> items)
Stores the items in a list | +| {{arrayInputJsonPathPiece.pascalCase}}(List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> items)
Stores the items in a list | {{headerSize}}## Method Summary | Modifier and Type | Method and Description | | ----------------- | ---------------------- | -{{#with items}} +{{#with listItemSchema}} {{#if refInfo }} {{#if refInfo.refModule}} {{#with getDeepestRef }} @@ -30,4 +30,4 @@ A class that builds the List input type {{else}} {{! todo handle this, 3.1.0 document use-case }} {{/with}} -| List<{{#with items}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> | build()
Returns list input that should be used with Schema.validate | +| List<{{#with listItemSchema}}{{> src/main/java/packagename/components/schemas/types/schema_input_type sourceJsonPath=../jsonPath forceNull=true noExtends=true }}{{else}}@Nullable Object{{/with}}> | build()
Returns list input that should be used with Schema.validate | 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 f35d40c3a48..830c439869d 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 @@ -94,3 +94,6 @@ {{#if patternProperties}} | Map> | {{> src/main/java/packagename/components/schemas/SchemaClass/_patternProperties }} | {{/if}} +{{#if prefixItems}} +| List> | {{> src/main/java/packagename/components/schemas/SchemaClass/_prefixItems }} | +{{/if}} diff --git a/src/main/resources/java/src/main/java/packagename/components/schemas/helpers/payload_renderer.hbs b/src/main/resources/java/src/main/java/packagename/components/schemas/helpers/payload_renderer.hbs index c64a63b09dd..395b5ca3893 100644 --- a/src/main/resources/java/src/main/java/packagename/components/schemas/helpers/payload_renderer.hbs +++ b/src/main/resources/java/src/main/java/packagename/components/schemas/helpers/payload_renderer.hbs @@ -42,10 +42,10 @@ MapUtils.makeMap( {{#each value}} {{#or (eq type "array") (eq type "object")}} .add( - {{> src/main/java/packagename/components/schemas/helpers/payload_renderer endChar="" noVoid=true constructor=false }} + {{> src/main/java/packagename/components/schemas/helpers/payload_renderer endChar="" constructor=false }} ) {{else}} -.add({{> src/main/java/packagename/components/schemas/helpers/payload_renderer endChar=")" noVoid=true constructor=false }} +.add({{> src/main/java/packagename/components/schemas/helpers/payload_renderer endChar=")" constructor=false }} {{/or}} {{/each}} {{else}} 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 3cabd40e097..6baca87231c 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 @@ -20,13 +20,16 @@ public class ItemsValidator implements KeywordValidator { @Nullable List containsPathToSchemas, @Nullable PathToSchemasMap patternPropertiesPathToSchemas ) { - if (!(arg instanceof List)) { + if (!(arg instanceof List listArg)) { + return null; + } + if (listArg.isEmpty()) { return null; } PathToSchemasMap pathToSchemas = new PathToSchemasMap(); - // todo add handling for prefixItems - int i = 0; - for(Object itemValue: (List) arg) { + int minIndex = schema.prefixItems != null ? schema.prefixItems.size() : 0; + JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); + for(int i = minIndex; i < listArg.size(); i++) { List itemPathToItem = new ArrayList<>(validationMetadata.pathToItem()); itemPathToItem.add(i); ValidationMetadata itemValidationMetadata = new ValidationMetadata( @@ -35,15 +38,12 @@ public class ItemsValidator implements KeywordValidator { validationMetadata.validatedPathToSchemas(), validationMetadata.seenClasses() ); - JsonSchema itemsSchema = JsonSchemaFactory.getInstance(items); if (itemValidationMetadata.validationRanEarlier(itemsSchema)) { // todo add_deeper_validated_schemas - i +=1; continue; } - PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, itemValue, itemValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, listArg.get(i), itemValidationMetadata); pathToSchemas.update(otherPathToSchemas); - i += 1; } return pathToSchemas; } 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 a11e5e67d1d..cc15f405870 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 @@ -53,6 +53,7 @@ public abstract class JsonSchema { public @Nullable Map> dependentRequired; public final @Nullable Map> dependentSchemas; public @Nullable Map> patternProperties; + public @Nullable List> prefixItems; private final LinkedHashMap keywordToValidator; protected JsonSchema(JsonSchemaInfo jsonSchemaInfo) { @@ -284,6 +285,13 @@ public abstract class JsonSchema { new PatternPropertiesValidator(this.patternProperties) ); } + this.prefixItems = jsonSchemaInfo.prefixItems; + if (this.prefixItems != null) { + keywordToValidator.put( + "prefixItems", + new PrefixItemsValidator(this.prefixItems) + ); + } this.keywordToValidator = keywordToValidator; } 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 abe43046af9..90e1935f18d 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 @@ -177,4 +177,9 @@ public class JsonSchemaInfo { this.patternProperties = patternProperties; return this; } + public @Nullable List> prefixItems = null; + public JsonSchemaInfo prefixItems(List> prefixItems) { + this.prefixItems = prefixItems; + return this; + } } \ No newline at end of file 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 new file mode 100644 index 00000000000..58124290093 --- /dev/null +++ b/src/main/resources/java/src/main/java/packagename/schemas/validation/PrefixItemsValidator.hbs @@ -0,0 +1,46 @@ +package {{{packageName}}}.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> prefixItems; + + public PrefixItemsValidator(List> prefixItems) { + this.prefixItems = prefixItems; + } + + @Override + public @Nullable PathToSchemasMap validate( + JsonSchema schema, + @Nullable Object arg, + ValidationMetadata validationMetadata, + @Nullable List 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 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; + } +} diff --git a/src/main/resources/python/components/schemas/_array_input_type.hbs b/src/main/resources/python/components/schemas/_array_input_type.hbs index 9ef4bb6b711..df292cf527c 100644 --- a/src/main/resources/python/components/schemas/_array_input_type.hbs +++ b/src/main/resources/python/components/schemas/_array_input_type.hbs @@ -1,15 +1,27 @@ -{{#if items}} {{arrayInputJsonPathPiece.pascalCase}} = typing.Union[ typing.List[ - {{#with items}} + {{#with listItemSchema}} {{> components/schemas/types/schema_io_type paramName=false fullRefModule="" endChar="," rootClass=../arrayInputJsonPathPiece.pascalCase }} {{/with}} ], typing.Tuple[ - {{#with items}} + {{#if prefixItems}} + {{#each prefixItems}} {{> components/schemas/types/schema_io_type paramName=false fullRefModule="" endChar="," rootClass=../arrayInputJsonPathPiece.pascalCase }} + {{/each}} + {{#with items}} + typing_extensions.Unpack[typing.Tuple[ + {{> components/schemas/types/schema_io_type paramName=false fullRefModule="" endChar="," rootClass=../arrayInputJsonPathPiece.pascalCase }} + ... + ]] + {{else}} + typing_extensions.Unpack[typing.Tuple[schemas.INPUT_TYPES_ALL, ...]] + {{/with}} + {{else}} + {{#with items}} + {{> components/schemas/types/schema_io_type paramName=false fullRefModule="" endChar="," rootClass=../arrayInputJsonPathPiece.pascalCase }} + {{/with}} ... - {{/with}} + {{/if}} ] ] -{{/if}} diff --git a/src/main/resources/python/components/schemas/_array_output_type.hbs b/src/main/resources/python/components/schemas/_array_output_type.hbs index 648d6e9eeab..48f699da7f7 100644 --- a/src/main/resources/python/components/schemas/_array_output_type.hbs +++ b/src/main/resources/python/components/schemas/_array_output_type.hbs @@ -2,6 +2,28 @@ class {{arrayOutputJsonPathPiece.pascalCase}}( typing.Tuple[ + {{#if prefixItems}} + {{#each prefixItems}} + {{> components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="," }} + {{/each}} + {{#with items}} + typing_extensions.Unpack[typing.Tuple[ + {{#if refInfo.refClass}} + {{#eq refModule null}} + {{! self reference }} + {{> components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="," selfReference=true }} + {{else}} + {{> components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="," }} + {{/eq}} + {{else}} + {{> components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="," }} + {{/if}} + ... + ]] + {{else}} + typing_extensions.Unpack[typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]] + {{/with}} + {{else}} {{#with items}} {{#if refInfo.refClass}} {{#eq refModule null}} @@ -13,8 +35,11 @@ class {{arrayOutputJsonPathPiece.pascalCase}}( {{else}} {{> components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="," }} {{/if}} + {{else}} + schemas.OUTPUT_BASE_TYPES, {{/with}} ... + {{/if}} ] ): 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 0cafe38d3e7..53a18f8c67c 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 @@ -315,6 +315,19 @@ components: type: array items: type: number + ItemsDoesNotLookInApplicatorsValidCase: + $schema: https://json-schema.org/draft/2020-12/schema + allOf: + - prefixItems: + - minimum: 3 + items: + minimum: 5 + PrefixitemsValidationAdjustsTheStartingIndexForItems: + $schema: https://json-schema.org/draft/2020-12/schema + prefixItems: + - type: string + items: + type: integer ItemsWithNullInstanceElements: $schema: https://json-schema.org/draft/2020-12/schema items: @@ -471,6 +484,19 @@ components: patternProperties: ^.*bar$: type: 'null' + ASchemaGivenForPrefixitems: + $schema: https://json-schema.org/draft/2020-12/schema + prefixItems: + - type: integer + - type: string + AdditionalItemsAreAllowedByDefault: + $schema: https://json-schema.org/draft/2020-12/schema + prefixItems: + - type: integer + PrefixitemsWithNullInstanceElements: + $schema: https://json-schema.org/draft/2020-12/schema + prefixItems: + - type: 'null' ObjectPropertiesValidation: $schema: https://json-schema.org/draft/2020-12/schema properties: @@ -628,9 +654,21 @@ components: UniqueitemsValidation: $schema: https://json-schema.org/draft/2020-12/schema uniqueItems: true + UniqueitemsWithAnArrayOfItems: + $schema: https://json-schema.org/draft/2020-12/schema + prefixItems: + - type: boolean + - type: boolean + uniqueItems: true UniqueitemsFalseValidation: $schema: https://json-schema.org/draft/2020-12/schema uniqueItems: false + UniqueitemsFalseWithAnArrayOfItems: + $schema: https://json-schema.org/draft/2020-12/schema + prefixItems: + - type: boolean + - type: boolean + uniqueItems: false x-schema-test-examples: AdditionalpropertiesWithSchema: NoAdditionalPropertiesIsValid: @@ -2141,6 +2179,37 @@ components: - - 6 valid: false comment: null + ItemsDoesNotLookInApplicatorsValidCase: + PrefixitemsInAllofDoesNotConstrainItemsInvalidCase: + description: prefixItems in allOf does not constrain items, invalid case + data: + - 3 + - 5 + valid: false + comment: null + PrefixitemsInAllofDoesNotConstrainItemsValidCase: + description: prefixItems in allOf does not constrain items, valid case + data: + - 5 + - 5 + valid: true + comment: null + PrefixitemsValidationAdjustsTheStartingIndexForItems: + ValidItems: + description: valid items + data: + - x + - 2 + - 3 + valid: true + comment: null + WrongTypeOfSecondItem: + description: wrong type of second item + data: + - x + - y + valid: false + comment: null ItemsWithNullInstanceElements: AllowsNullElements: description: allows null elements @@ -2855,6 +2924,64 @@ components: foobar: null valid: true comment: null + ASchemaGivenForPrefixitems: + CorrectTypes: + description: correct types + data: + - 1 + - foo + valid: true + comment: null + WrongTypes: + description: wrong types + data: + - foo + - 1 + valid: false + comment: null + IncompleteArrayOfItems: + description: incomplete array of items + data: + - 1 + valid: true + comment: null + ArrayWithAdditionalItems: + description: array with additional items + data: + - 1 + - foo + - true + valid: true + comment: null + EmptyArray: + description: empty array + data: [] + valid: true + comment: null + JavascriptPseudoArrayIsValid: + description: JavaScript pseudo-array is valid + data: + '0': invalid + '1': valid + length: 2 + valid: true + comment: null + AdditionalItemsAreAllowedByDefault: + OnlyTheFirstItemIsValidated: + description: only the first item is validated + data: + - 1 + - foo + - false + valid: true + comment: null + PrefixitemsWithNullInstanceElements: + AllowsNullElements: + description: allows null elements + data: + - null + valid: true + comment: null ObjectPropertiesValidation: BothPropertiesPresentAndValidIsValid: description: both properties present and valid is valid @@ -3865,6 +3992,71 @@ components: - a: 1 valid: true comment: null + UniqueitemsWithAnArrayOfItems: + FalseTrueFromItemsArrayIsValid: + description: '[false, true] from items array is valid' + data: + - false + - true + valid: true + comment: null + TrueFalseFromItemsArrayIsValid: + description: '[true, false] from items array is valid' + data: + - true + - false + valid: true + comment: null + FalseFalseFromItemsArrayIsNotValid: + description: '[false, false] from items array is not valid' + data: + - false + - false + valid: false + comment: null + TrueTrueFromItemsArrayIsNotValid: + description: '[true, true] from items array is not valid' + data: + - true + - true + valid: false + comment: null + UniqueArrayExtendedFromFalseTrueIsValid: + description: unique array extended from [false, true] is valid + data: + - false + - true + - foo + - bar + valid: true + comment: null + UniqueArrayExtendedFromTrueFalseIsValid: + description: unique array extended from [true, false] is valid + data: + - true + - false + - foo + - bar + valid: true + comment: null + NonUniqueArrayExtendedFromFalseTrueIsNotValid: + description: non-unique array extended from [false, true] is not valid + data: + - false + - true + - foo + - foo + valid: false + comment: null + NonUniqueArrayExtendedFromTrueFalseIsNotValid: + description: non-unique array extended from [true, false] is not valid + data: + - true + - false + - foo + - foo + valid: false + comment: null UniqueitemsFalseValidation: UniqueArrayOfIntegersIsValid: description: unique array of integers is valid @@ -3987,3 +4179,68 @@ components: - 1 valid: true comment: null + UniqueitemsFalseWithAnArrayOfItems: + FalseTrueFromItemsArrayIsValid: + description: '[false, true] from items array is valid' + data: + - false + - true + valid: true + comment: null + TrueFalseFromItemsArrayIsValid: + description: '[true, false] from items array is valid' + data: + - true + - false + valid: true + comment: null + FalseFalseFromItemsArrayIsValid: + description: '[false, false] from items array is valid' + data: + - false + - false + valid: true + comment: null + TrueTrueFromItemsArrayIsValid: + description: '[true, true] from items array is valid' + data: + - true + - true + valid: true + comment: null + UniqueArrayExtendedFromFalseTrueIsValid: + description: unique array extended from [false, true] is valid + data: + - false + - true + - foo + - bar + valid: true + comment: null + UniqueArrayExtendedFromTrueFalseIsValid: + description: unique array extended from [true, false] is valid + data: + - true + - false + - foo + - bar + valid: true + comment: null + NonUniqueArrayExtendedFromFalseTrueIsValid: + description: non-unique array extended from [false, true] is valid + data: + - false + - true + - foo + - foo + valid: true + comment: null + NonUniqueArrayExtendedFromTrueFalseIsValid: + description: non-unique array extended from [true, false] is valid + data: + - true + - false + - foo + - foo + valid: true + comment: null 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 54283899f62..a3a83e150d0 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 @@ -700,13 +700,6 @@ def write_openapi_spec(): openapi.paths = {} openapi.tags = [] removed_cases = { - 'ItemsDoesNotLookInApplicatorsValidCase', - 'PrefixitemsValidationAdjustsTheStartingIndexForItems', - 'ASchemaGivenForPrefixitems', - 'AdditionalItemsAreAllowedByDefault', - 'PrefixitemsWithNullInstanceElements', - 'UniqueitemsWithAnArrayOfItems', - 'UniqueitemsFalseWithAnArrayOfItems', 'UnevaluateditemsDependsOnMultipleNestedContains', 'IgnoreIfWithoutThenOrElse', 'IfAndThenWithoutElse',