diff --git a/samples/client/petstore/java/.openapi-generator/FILES b/samples/client/petstore/java/.openapi-generator/FILES index af964663817..de22fa8674e 100644 --- a/samples/client/petstore/java/.openapi-generator/FILES +++ b/samples/client/petstore/java/.openapi-generator/FILES @@ -343,53 +343,51 @@ src/main/java/org/openapijsonschematools/paths/userusername/put/PathParameters.j src/main/java/org/openapijsonschematools/paths/userusername/put/requestbody/content/applicationjson/Schema.java src/main/java/org/openapijsonschematools/schemas/AnyTypeJsonSchema.java src/main/java/org/openapijsonschematools/schemas/BooleanJsonSchema.java -src/main/java/org/openapijsonschematools/schemas/CustomIsoparser.java src/main/java/org/openapijsonschematools/schemas/DateJsonSchema.java src/main/java/org/openapijsonschematools/schemas/DateTimeJsonSchema.java src/main/java/org/openapijsonschematools/schemas/DecimalJsonSchema.java src/main/java/org/openapijsonschematools/schemas/DoubleJsonSchema.java src/main/java/org/openapijsonschematools/schemas/FloatJsonSchema.java -src/main/java/org/openapijsonschematools/schemas/FrozenList.java -src/main/java/org/openapijsonschematools/schemas/FrozenMap.java src/main/java/org/openapijsonschematools/schemas/Int32JsonSchema.java src/main/java/org/openapijsonschematools/schemas/Int64JsonSchema.java src/main/java/org/openapijsonschematools/schemas/IntJsonSchema.java -src/main/java/org/openapijsonschematools/schemas/JsonSchema.java src/main/java/org/openapijsonschematools/schemas/ListJsonSchema.java src/main/java/org/openapijsonschematools/schemas/MapJsonSchema.java src/main/java/org/openapijsonschematools/schemas/NotAnyTypeJsonSchema.java src/main/java/org/openapijsonschematools/schemas/NullJsonSchema.java src/main/java/org/openapijsonschematools/schemas/NumberJsonSchema.java -src/main/java/org/openapijsonschematools/schemas/PathToSchemasMap.java -src/main/java/org/openapijsonschematools/schemas/PathToTypeMap.java -src/main/java/org/openapijsonschematools/schemas/SchemaValidator.java src/main/java/org/openapijsonschematools/schemas/StringJsonSchema.java -src/main/java/org/openapijsonschematools/schemas/UnsetAnyTypeJsonSchema.java src/main/java/org/openapijsonschematools/schemas/UuidJsonSchema.java -src/main/java/org/openapijsonschematools/schemas/ValidationMetadata.java -src/main/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/FakeValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/FormatValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/ItemsValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/KeywordValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/PropertiesValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/RequiredValidator.java -src/main/java/org/openapijsonschematools/schemas/validators/TypeValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/CustomIsoparser.java +src/main/java/org/openapijsonschematools/schemas/validation/FakeValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/FormatValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/FrozenList.java +src/main/java/org/openapijsonschematools/schemas/validation/FrozenMap.java +src/main/java/org/openapijsonschematools/schemas/validation/ItemsValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/JsonSchema.java +src/main/java/org/openapijsonschematools/schemas/validation/KeywordValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/PathToSchemasMap.java +src/main/java/org/openapijsonschematools/schemas/validation/PropertiesValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/RequiredValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/TypeValidator.java +src/main/java/org/openapijsonschematools/schemas/validation/UnsetAnyTypeJsonSchema.java +src/main/java/org/openapijsonschematools/schemas/validation/ValidationMetadata.java src/test/java/org/openapijsonschematools/configurations/JsonSchemaKeywordFlagsTest.java src/test/java/org/openapijsonschematools/schemas/AnyTypeSchemaTest.java src/test/java/org/openapijsonschematools/schemas/ArrayTypeSchemaTest.java src/test/java/org/openapijsonschematools/schemas/BooleanSchemaTest.java -src/test/java/org/openapijsonschematools/schemas/CustomIsoparserTest.java src/test/java/org/openapijsonschematools/schemas/ListSchemaTest.java src/test/java/org/openapijsonschematools/schemas/MapSchemaTest.java src/test/java/org/openapijsonschematools/schemas/NullSchemaTest.java src/test/java/org/openapijsonschematools/schemas/NumberSchemaTest.java src/test/java/org/openapijsonschematools/schemas/ObjectTypeSchemaTest.java src/test/java/org/openapijsonschematools/schemas/RefBooleanSchemaTest.java -src/test/java/org/openapijsonschematools/schemas/SchemaValidatorTest.java -src/test/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidatorTest.java -src/test/java/org/openapijsonschematools/schemas/validators/FormatValidatorTest.java -src/test/java/org/openapijsonschematools/schemas/validators/ItemsValidatorTest.java -src/test/java/org/openapijsonschematools/schemas/validators/PropertiesValidatorTest.java -src/test/java/org/openapijsonschematools/schemas/validators/RequiredValidatorTest.java -src/test/java/org/openapijsonschematools/schemas/validators/TypeValidatorTest.java +src/test/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidatorTest.java +src/test/java/org/openapijsonschematools/schemas/validation/CustomIsoparserTest.java +src/test/java/org/openapijsonschematools/schemas/validation/FormatValidatorTest.java +src/test/java/org/openapijsonschematools/schemas/validation/ItemsValidatorTest.java +src/test/java/org/openapijsonschematools/schemas/validation/JsonSchemaTest.java +src/test/java/org/openapijsonschematools/schemas/validation/PropertiesValidatorTest.java +src/test/java/org/openapijsonschematools/schemas/validation/RequiredValidatorTest.java +src/test/java/org/openapijsonschematools/schemas/validation/TypeValidatorTest.java diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/requestbodies/userarray/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/requestbodies/userarray/content/applicationjson/Schema.java index 1245ef57219..0817c57d0cd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/requestbodies/userarray/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/requestbodies/userarray/content/applicationjson/Schema.java @@ -4,19 +4,28 @@ import java.util.Set; import org.openapijsonschematools.components.schemas.User; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList extends FrozenList { + SchemaList(FrozenList m) { + super(m); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = User.User1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = User.User1.class; + protected static SchemaList getListOutputInstance(FrozenList arg) { + return new SchemaList(arg); + } + public static SchemaList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/headerswithnobody/Headers.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/headerswithnobody/Headers.java index d258891039b..b25ed601ac4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/headerswithnobody/Headers.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/headerswithnobody/Headers.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.components.responses.headerswithnobody.headers.location.LocationSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Headers { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class Headers1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeadersMap extends FrozenMap { + HeadersMap(FrozenMap m) { + super(m); + } + public static HeadersMap of(Map arg, SchemaConfiguration configuration) { + return Headers1.validate(arg, configuration); + } + } + + public class Headers1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("location", LocationSchema.LocationSchema1.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeadersMap getMapOutputInstance(FrozenMap arg) { + return new HeadersMap(arg); + } + public static HeadersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Headers1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationjson/Schema.java index ee9176dec38..c2d767aa38e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationjson/Schema.java @@ -5,19 +5,28 @@ import org.openapijsonschematools.components.schemas.Pet; import org.openapijsonschematools.components.schemas.RefPet; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList extends FrozenList { + SchemaList(FrozenList m) { + super(m); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = RefPet.RefPet1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = RefPet.RefPet1.class; + protected static SchemaList getListOutputInstance(FrozenList arg) { + return new SchemaList(arg); + } + public static SchemaList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationxml/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationxml/Schema.java index 91336cac1dc..dd611a01629 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationxml/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successfulxmlandjsonarrayofpet/content/applicationxml/Schema.java @@ -4,19 +4,28 @@ import java.util.Set; import org.openapijsonschematools.components.schemas.Pet; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList extends FrozenList { + SchemaList(FrozenList m) { + super(m); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Pet.Pet1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Pet.Pet1.class; + protected static SchemaList getListOutputInstance(FrozenList arg) { + return new SchemaList(arg); + } + public static SchemaList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/Headers.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/Headers.java index f17b9108e17..b3f4a5d7c0d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/Headers.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/Headers.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.components.responses.successinlinecontentandheader.headers.someheader.SomeHeaderSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Headers { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class Headers1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeadersMap extends FrozenMap { + HeadersMap(FrozenMap m) { + super(m); + } + public static HeadersMap of(Map arg, SchemaConfiguration configuration) { + return Headers1.validate(arg, configuration); + } + } + + public class Headers1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someHeader", SomeHeaderSchema.SomeHeaderSchema1.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeadersMap getMapOutputInstance(FrozenMap arg) { + return new HeadersMap(arg); + } + public static HeadersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Headers1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/content/applicationjson/Schema.java index a13ea71ca15..189fc2e23ed 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successinlinecontentandheader/content/applicationjson/Schema.java @@ -3,9 +3,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,24 @@ public class Schema { public class AdditionalProperties extends Int32JsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successwithjsonapiresponse/Headers.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successwithjsonapiresponse/Headers.java index dfe94829897..b37f4f7459b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successwithjsonapiresponse/Headers.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/responses/successwithjsonapiresponse/Headers.java @@ -10,9 +10,9 @@ import org.openapijsonschematools.components.schemas.StringWithValidation; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Headers { // nest classes so all schemas and input/output classes can be public @@ -22,25 +22,37 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class Headers1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeadersMap extends FrozenMap { + HeadersMap(FrozenMap m) { + super(m); + } + public static HeadersMap of(Map arg, SchemaConfiguration configuration) { + return Headers1.validate(arg, configuration); + } + } + + public class Headers1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("ref-schema-header", StringWithValidation.StringWithValidation1.class), new AbstractMap.SimpleEntry>("int32", Int32JsonContentTypeHeaderSchema.Int32JsonContentTypeHeaderSchema1.class), new AbstractMap.SimpleEntry>("ref-content-schema-header", StringWithValidation.StringWithValidation1.class), new AbstractMap.SimpleEntry>("stringHeader", StringHeaderSchema.StringHeaderSchema1.class), new AbstractMap.SimpleEntry>("numberHeader", NumberHeaderSchema.NumberHeaderSchema1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "int32", "ref-content-schema-header", "ref-schema-header", "stringHeader" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeadersMap getMapOutputInstance(FrozenMap arg) { + return new HeadersMap(arg); + } + public static HeadersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Headers1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AbstractStepMessage.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AbstractStepMessage.java index f64d98f1408..04c5a159346 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AbstractStepMessage.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AbstractStepMessage.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AbstractStepMessage { // nest classes so all schemas and input/output classes can be public @@ -16,7 +16,16 @@ public class AbstractStepMessage { public class Discriminator extends StringJsonSchema {} - public class AbstractStepMessage1 implements JsonSchema { + public static class AbstractStepMessageMap extends FrozenMap { + AbstractStepMessageMap(FrozenMap m) { + super(m); + } + public static AbstractStepMessageMap of(Map arg, SchemaConfiguration configuration) { + return AbstractStepMessage1.validate(arg, configuration); + } + } + + public class AbstractStepMessage1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -25,18 +34,21 @@ public class AbstractStepMessage1 implements JsonSchema { Abstract Step */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("discriminator", Discriminator.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "description", "discriminator", "sequenceNumber" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AbstractStepMessageMap getMapOutputInstance(FrozenMap arg) { + return new AbstractStepMessageMap(arg); + } + public static AbstractStepMessageMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AbstractStepMessage1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesClass.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesClass.java index 37e3e592595..71f66d598d0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesClass.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesClass.java @@ -6,11 +6,11 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.MapJsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AdditionalPropertiesClass { // nest classes so all schemas and input/output classes can be public @@ -19,12 +19,24 @@ public class AdditionalPropertiesClass { public class AdditionalProperties extends StringJsonSchema {} - public class MapProperty implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapPropertyMap extends FrozenMap { + MapPropertyMap(FrozenMap m) { + super(m); + } + public static MapPropertyMap of(Map arg, SchemaConfiguration configuration) { + return MapProperty.validate(arg, configuration); + } + } + + public class MapProperty extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapPropertyMap getMapOutputInstance(FrozenMap arg) { + return new MapPropertyMap(arg); + } + public static MapPropertyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapProperty.class, arg, configuration); } } @@ -33,23 +45,47 @@ public static T validate(Map arg, SchemaCo public class AdditionalProperties2 extends StringJsonSchema {} - public class AdditionalProperties1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class AdditionalPropertiesMap extends FrozenMap { + AdditionalPropertiesMap(FrozenMap m) { + super(m); + } + public static AdditionalPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return AdditionalProperties1.validate(arg, configuration); + } + } + + public class AdditionalProperties1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties2.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AdditionalPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new AdditionalPropertiesMap(arg); + } + public static AdditionalPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalProperties1.class, arg, configuration); } } - public class MapOfMapProperty implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapOfMapPropertyMap extends FrozenMap { + MapOfMapPropertyMap(FrozenMap m) { + super(m); + } + public static MapOfMapPropertyMap of(Map arg, SchemaConfiguration configuration) { + return MapOfMapProperty.validate(arg, configuration); + } + } + + public class MapOfMapProperty extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties1.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapOfMapPropertyMap getMapOutputInstance(FrozenMap arg) { + return new MapOfMapPropertyMap(arg); + } + public static MapOfMapPropertyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapOfMapProperty.class, arg, configuration); } } @@ -67,12 +103,24 @@ public class MapWithUndeclaredPropertiesAnytype2 extends MapJsonSchema {} public class AdditionalProperties3 extends AnyTypeJsonSchema {} - public class MapWithUndeclaredPropertiesAnytype3 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapWithUndeclaredPropertiesAnytype3Map extends FrozenMap { + MapWithUndeclaredPropertiesAnytype3Map(FrozenMap m) { + super(m); + } + public static MapWithUndeclaredPropertiesAnytype3Map of(Map arg, SchemaConfiguration configuration) { + return MapWithUndeclaredPropertiesAnytype3.validate(arg, configuration); + } + } + + public class MapWithUndeclaredPropertiesAnytype3 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties3.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapWithUndeclaredPropertiesAnytype3Map getMapOutputInstance(FrozenMap arg) { + return new MapWithUndeclaredPropertiesAnytype3Map(arg); + } + public static MapWithUndeclaredPropertiesAnytype3Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapWithUndeclaredPropertiesAnytype3.class, arg, configuration); } } @@ -82,12 +130,25 @@ public class AdditionalProperties4 extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class EmptyMap implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class EmptyMapMap extends FrozenMap { + EmptyMapMap(FrozenMap m) { + super(m); + } + // map with no key value pairs + public static EmptyMapMap of(Map arg, SchemaConfiguration configuration) { + return EmptyMap.validate(arg, configuration); + } + } + + public class EmptyMap extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties4.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static EmptyMapMap getMapOutputInstance(FrozenMap arg) { + return new EmptyMapMap(arg); + } + public static EmptyMapMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(EmptyMap.class, arg, configuration); } } @@ -96,28 +157,49 @@ public static T validate(Map arg, SchemaCo public class AdditionalProperties5 extends StringJsonSchema {} - public class MapWithUndeclaredPropertiesString implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapWithUndeclaredPropertiesStringMap extends FrozenMap { + MapWithUndeclaredPropertiesStringMap(FrozenMap m) { + super(m); + } + public static MapWithUndeclaredPropertiesStringMap of(Map arg, SchemaConfiguration configuration) { + return MapWithUndeclaredPropertiesString.validate(arg, configuration); + } + } + + public class MapWithUndeclaredPropertiesString extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties5.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapWithUndeclaredPropertiesStringMap getMapOutputInstance(FrozenMap arg) { + return new MapWithUndeclaredPropertiesStringMap(arg); + } + public static MapWithUndeclaredPropertiesStringMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapWithUndeclaredPropertiesString.class, arg, configuration); } } - public class AdditionalPropertiesClass1 implements JsonSchema { + public static class AdditionalPropertiesClassMap extends FrozenMap { + AdditionalPropertiesClassMap(FrozenMap m) { + super(m); + } + public static AdditionalPropertiesClassMap of(Map arg, SchemaConfiguration configuration) { + return AdditionalPropertiesClass1.validate(arg, configuration); + } + } + + public class AdditionalPropertiesClass1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("map_property", MapProperty.class), new AbstractMap.SimpleEntry>("map_of_map_property", MapOfMapProperty.class), new AbstractMap.SimpleEntry>("anytype_1", Anytype1.class), @@ -127,7 +209,10 @@ public class AdditionalPropertiesClass1 implements JsonSchema { new AbstractMap.SimpleEntry>("empty_map", EmptyMap.class), new AbstractMap.SimpleEntry>("map_with_undeclared_properties_string", MapWithUndeclaredPropertiesString.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AdditionalPropertiesClassMap getMapOutputInstance(FrozenMap arg) { + return new AdditionalPropertiesClassMap(arg); + } + public static AdditionalPropertiesClassMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalPropertiesClass1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesValidator.java index b648297c8d0..183bbbdf337 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesValidator.java @@ -8,9 +8,9 @@ import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AdditionalPropertiesValidator { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalPropertiesValidator { public class AdditionalProperties extends AnyTypeJsonSchema {} - public class Schema0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema0Map extends FrozenMap { + Schema0Map(FrozenMap m) { + super(m); + } + public static Schema0Map of(Map arg, SchemaConfiguration configuration) { + return Schema0.validate(arg, configuration); + } + } + + public class Schema0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema0Map getMapOutputInstance(FrozenMap arg) { + return new Schema0Map(arg); + } + public static Schema0Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema0.class, arg, configuration); } } - public class AdditionalProperties1 implements JsonSchema { + public class AdditionalProperties1 extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalProperties1.class, arg, configuration); } @@ -80,18 +92,30 @@ public static U validate(List arg, SchemaConfigur } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties1.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class AdditionalProperties2 implements JsonSchema { + public class AdditionalProperties2 extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalProperties2.class, arg, configuration); } @@ -141,25 +165,37 @@ public static U validate(List arg, SchemaConfigur } } - public class Schema2 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema2Map extends FrozenMap { + Schema2Map(FrozenMap m) { + super(m); + } + public static Schema2Map of(Map arg, SchemaConfiguration configuration) { + return Schema2.validate(arg, configuration); + } + } + + public class Schema2 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties2.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema2Map getMapOutputInstance(FrozenMap arg) { + return new Schema2Map(arg); + } + public static Schema2Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema2.class, arg, configuration); } } - public class AdditionalPropertiesValidator1 implements JsonSchema { + public class AdditionalPropertiesValidator1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); public static T validate(Map arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesWithArrayOfEnums.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesWithArrayOfEnums.java index 3467a75e2ae..504c500c0bb 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesWithArrayOfEnums.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AdditionalPropertiesWithArrayOfEnums.java @@ -4,36 +4,57 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AdditionalPropertiesWithArrayOfEnums { // nest classes so all schemas and input/output classes can be public - public class AdditionalProperties implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class AdditionalPropertiesList extends FrozenList { + AdditionalPropertiesList(FrozenList m) { + super(m); + } + } + + public class AdditionalProperties extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = EnumClass.EnumClass1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = EnumClass.EnumClass1.class; + protected static AdditionalPropertiesList getListOutputInstance(FrozenList arg) { + return new AdditionalPropertiesList(arg); + } + public static AdditionalPropertiesList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalProperties.class, arg, configuration); } } - public class AdditionalPropertiesWithArrayOfEnums1 implements JsonSchema { + public static class AdditionalPropertiesWithArrayOfEnumsMap extends FrozenMap { + AdditionalPropertiesWithArrayOfEnumsMap(FrozenMap m) { + super(m); + } + public static AdditionalPropertiesWithArrayOfEnumsMap of(Map arg, SchemaConfiguration configuration) { + return AdditionalPropertiesWithArrayOfEnums1.validate(arg, configuration); + } + } + + public class AdditionalPropertiesWithArrayOfEnums1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AdditionalPropertiesWithArrayOfEnumsMap getMapOutputInstance(FrozenMap arg) { + return new AdditionalPropertiesWithArrayOfEnumsMap(arg); + } + public static AdditionalPropertiesWithArrayOfEnumsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalPropertiesWithArrayOfEnums1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Address.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Address.java index e222fe1a233..1a3588ffde4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Address.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Address.java @@ -3,9 +3,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.IntJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Address { // nest classes so all schemas and input/output classes can be public @@ -14,18 +14,30 @@ public class Address { public class AdditionalProperties extends IntJsonSchema {} - public class Address1 implements JsonSchema { + public static class AddressMap extends FrozenMap { + AddressMap(FrozenMap m) { + super(m); + } + public static AddressMap of(Map arg, SchemaConfiguration configuration) { + return Address1.validate(arg, configuration); + } + } + + public class Address1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AddressMap getMapOutputInstance(FrozenMap arg) { + return new AddressMap(arg); + } + public static AddressMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Address1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Animal.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Animal.java index 1a3835274bf..6f2e074bc8d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Animal.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Animal.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Animal { // nest classes so all schemas and input/output classes can be public @@ -16,8 +16,8 @@ public class Animal { public class ClassName extends StringJsonSchema {} - public class Color implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Color extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -25,24 +25,36 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Animal1 implements JsonSchema { + public static class AnimalMap extends FrozenMap { + AnimalMap(FrozenMap m) { + super(m); + } + public static AnimalMap of(Map arg, SchemaConfiguration configuration) { + return Animal1.validate(arg, configuration); + } + } + + public class Animal1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("className", ClassName.class), new AbstractMap.SimpleEntry>("color", Color.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "className" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AnimalMap getMapOutputInstance(FrozenMap arg) { + return new AnimalMap(arg); + } + public static AnimalMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Animal1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnimalFarm.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnimalFarm.java index 6080f078ea1..f05bde7cdda 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnimalFarm.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnimalFarm.java @@ -3,25 +3,34 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AnimalFarm { // nest classes so all schemas and input/output classes can be public - public class AnimalFarm1 implements JsonSchema { + public static class AnimalFarmList extends FrozenList { + AnimalFarmList(FrozenList m) { + super(m); + } + } + + public class AnimalFarm1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Animal.Animal1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Animal.Animal1.class; + protected static AnimalFarmList getListOutputInstance(FrozenList arg) { + return new AnimalFarmList(arg); + } + public static AnimalFarmList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(AnimalFarm1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeAndFormat.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeAndFormat.java index 8c9a56b27fa..41821317116 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeAndFormat.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeAndFormat.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AnyTypeAndFormat { // nest classes so all schemas and input/output classes can be public - public class UuidSchema implements JsonSchema { - static final String format = "uuid"; + public class UuidSchema extends JsonSchema { + public static final String format = "uuid"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(UuidSchema.class, arg, configuration); } @@ -68,8 +68,8 @@ public static U validate(List arg, SchemaConfigur } } - public class Date implements JsonSchema { - static final String format = "date"; + public class Date extends JsonSchema { + public static final String format = "date"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Date.class, arg, configuration); } @@ -119,8 +119,8 @@ public static U validate(List arg, SchemaConfigur } } - public class Datetime implements JsonSchema { - static final String format = "date-time"; + public class Datetime extends JsonSchema { + public static final String format = "date-time"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Datetime.class, arg, configuration); } @@ -170,8 +170,8 @@ public static U validate(List arg, SchemaConfigur } } - public class NumberSchema implements JsonSchema { - static final String format = "number"; + public class NumberSchema extends JsonSchema { + public static final String format = "number"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(NumberSchema.class, arg, configuration); } @@ -221,8 +221,8 @@ public static U validate(List arg, SchemaConfigur } } - public class Binary implements JsonSchema { - static final String format = "binary"; + public class Binary extends JsonSchema { + public static final String format = "binary"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Binary.class, arg, configuration); } @@ -272,8 +272,8 @@ public static U validate(List arg, SchemaConfigur } } - public class Int32 implements JsonSchema { - static final String format = "int32"; + public class Int32 extends JsonSchema { + public static final String format = "int32"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Int32.class, arg, configuration); } @@ -323,8 +323,8 @@ public static U validate(List arg, SchemaConfigur } } - public class Int64 implements JsonSchema { - static final String format = "int64"; + public class Int64 extends JsonSchema { + public static final String format = "int64"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Int64.class, arg, configuration); } @@ -374,8 +374,8 @@ public static U validate(List arg, SchemaConfigur } } - public class DoubleSchema implements JsonSchema { - static final String format = "double"; + public class DoubleSchema extends JsonSchema { + public static final String format = "double"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(DoubleSchema.class, arg, configuration); } @@ -425,8 +425,8 @@ public static U validate(List arg, SchemaConfigur } } - public class FloatSchema implements JsonSchema { - static final String format = "float"; + public class FloatSchema extends JsonSchema { + public static final String format = "float"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(FloatSchema.class, arg, configuration); } @@ -476,17 +476,26 @@ public static U validate(List arg, SchemaConfigur } } - public class AnyTypeAndFormat1 implements JsonSchema { + public static class AnyTypeAndFormatMap extends FrozenMap { + AnyTypeAndFormatMap(FrozenMap m) { + super(m); + } + public static AnyTypeAndFormatMap of(Map arg, SchemaConfiguration configuration) { + return AnyTypeAndFormat1.validate(arg, configuration); + } + } + + public class AnyTypeAndFormat1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("uuid", UuidSchema.class), new AbstractMap.SimpleEntry>("date", Date.class), new AbstractMap.SimpleEntry>("date-time", Datetime.class), @@ -497,7 +506,10 @@ public class AnyTypeAndFormat1 implements JsonSchema { new AbstractMap.SimpleEntry>("double", DoubleSchema.class), new AbstractMap.SimpleEntry>("float", FloatSchema.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AnyTypeAndFormatMap getMapOutputInstance(FrozenMap arg) { + return new AnyTypeAndFormatMap(arg); + } + public static AnyTypeAndFormatMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AnyTypeAndFormat1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeNotString.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeNotString.java index 8493d596284..d8f5fd35321 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeNotString.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AnyTypeNotString.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AnyTypeNotString { // nest classes so all schemas and input/output classes can be public @@ -17,7 +17,7 @@ public class AnyTypeNotString { public class Not extends StringJsonSchema {} - public class AnyTypeNotString1 implements JsonSchema { + public class AnyTypeNotString1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ApiResponseSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ApiResponseSchema.java index f7306544b2b..b00c7194b8c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ApiResponseSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ApiResponseSchema.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ApiResponseSchema { // nest classes so all schemas and input/output classes can be public @@ -23,22 +23,34 @@ public class Type extends StringJsonSchema {} public class Message extends StringJsonSchema {} - public class ApiResponseSchema1 implements JsonSchema { + public static class ApiResponseMap extends FrozenMap { + ApiResponseMap(FrozenMap m) { + super(m); + } + public static ApiResponseMap of(Map arg, SchemaConfiguration configuration) { + return ApiResponseSchema1.validate(arg, configuration); + } + } + + public class ApiResponseSchema1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("code", Code.class), new AbstractMap.SimpleEntry>("type", Type.class), new AbstractMap.SimpleEntry>("message", Message.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ApiResponseMap getMapOutputInstance(FrozenMap arg) { + return new ApiResponseMap(arg); + } + public static ApiResponseMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ApiResponseSchema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Apple.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Apple.java index cd9c21f3df8..b8b5e33a600 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Apple.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Apple.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Apple { // nest classes so all schemas and input/output classes can be public - public class Cultivar implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Cultivar extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -21,8 +21,8 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Origin implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Origin extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -30,28 +30,37 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Apple1 implements JsonSchema { + public static class AppleMap extends FrozenMap { + AppleMap(FrozenMap m) { + super(m); + } + public static AppleMap of(Map arg, SchemaConfiguration configuration) { + return Apple1.validate(arg, configuration); + } + } + + public class Apple1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("cultivar", Cultivar.class), new AbstractMap.SimpleEntry>("origin", Origin.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "cultivar" )); public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Apple1.class, arg, configuration); } - public static T validate(Map arg, SchemaConfiguration configuration) { + public static AppleMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Apple1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AppleReq.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AppleReq.java index d6e2da71e16..193d8fd2774 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AppleReq.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/AppleReq.java @@ -7,10 +7,10 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; import org.openapijsonschematools.schemas.BooleanJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class AppleReq { // nest classes so all schemas and input/output classes can be public @@ -26,25 +26,37 @@ public class Cultivar extends StringJsonSchema {} public class Mealy extends BooleanJsonSchema {} - public class AppleReq1 implements JsonSchema { + public static class AppleReqMap extends FrozenMap { + AppleReqMap(FrozenMap m) { + super(m); + } + public static AppleReqMap of(Map arg, SchemaConfiguration configuration) { + return AppleReq1.validate(arg, configuration); + } + } + + public class AppleReq1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("cultivar", Cultivar.class), new AbstractMap.SimpleEntry>("mealy", Mealy.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "cultivar" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AppleReqMap getMapOutputInstance(FrozenMap arg) { + return new AppleReqMap(arg); + } + public static AppleReqMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AppleReq1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayHoldingAnyType.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayHoldingAnyType.java index 5af7c265cd2..41741aaf463 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayHoldingAnyType.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayHoldingAnyType.java @@ -4,8 +4,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ArrayHoldingAnyType { // nest classes so all schemas and input/output classes can be public @@ -14,18 +14,27 @@ public class ArrayHoldingAnyType { public class Items extends AnyTypeJsonSchema {} - public class ArrayHoldingAnyType1 implements JsonSchema { + public static class ArrayHoldingAnyTypeList extends FrozenList { + ArrayHoldingAnyTypeList(FrozenList m) { + super(m); + } + } + + public class ArrayHoldingAnyType1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayHoldingAnyTypeList getListOutputInstance(FrozenList arg) { + return new ArrayHoldingAnyTypeList(arg); + } + public static ArrayHoldingAnyTypeList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayHoldingAnyType1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfArrayOfNumberOnly.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfArrayOfNumberOnly.java index eedbb50c0d6..8bc013e145d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfArrayOfNumberOnly.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfArrayOfNumberOnly.java @@ -6,10 +6,10 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ArrayOfArrayOfNumberOnly { // nest classes so all schemas and input/output classes can be public @@ -18,40 +18,70 @@ public class ArrayOfArrayOfNumberOnly { public class Items1 extends NumberJsonSchema {} - public class Items implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ItemsList extends FrozenList { + ItemsList(FrozenList m) { + super(m); + } + } + + public class Items extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items1.class; + protected static ItemsList getListOutputInstance(FrozenList arg) { + return new ItemsList(arg); + } + public static ItemsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Items.class, arg, configuration); } } - public class ArrayArrayNumber implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayArrayNumberList extends FrozenList { + ArrayArrayNumberList(FrozenList m) { + super(m); + } + } + + public class ArrayArrayNumber extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayArrayNumberList getListOutputInstance(FrozenList arg) { + return new ArrayArrayNumberList(arg); + } + public static ArrayArrayNumberList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayArrayNumber.class, arg, configuration); } } - public class ArrayOfArrayOfNumberOnly1 implements JsonSchema { + public static class ArrayOfArrayOfNumberOnlyMap extends FrozenMap { + ArrayOfArrayOfNumberOnlyMap(FrozenMap m) { + super(m); + } + public static ArrayOfArrayOfNumberOnlyMap of(Map arg, SchemaConfiguration configuration) { + return ArrayOfArrayOfNumberOnly1.validate(arg, configuration); + } + } + + public class ArrayOfArrayOfNumberOnly1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("ArrayArrayNumber", ArrayArrayNumber.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ArrayOfArrayOfNumberOnlyMap getMapOutputInstance(FrozenMap arg) { + return new ArrayOfArrayOfNumberOnlyMap(arg); + } + public static ArrayOfArrayOfNumberOnlyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayOfArrayOfNumberOnly1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfEnums.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfEnums.java index d9ba5c570f0..ae27a1f24db 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfEnums.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfEnums.java @@ -3,25 +3,34 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ArrayOfEnums { // nest classes so all schemas and input/output classes can be public - public class ArrayOfEnums1 implements JsonSchema { + public static class ArrayOfEnumsList extends FrozenList { + ArrayOfEnumsList(FrozenList m) { + super(m); + } + } + + public class ArrayOfEnums1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = StringEnum.StringEnum1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = StringEnum.StringEnum1.class; + protected static ArrayOfEnumsList getListOutputInstance(FrozenList arg) { + return new ArrayOfEnumsList(arg); + } + public static ArrayOfEnumsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayOfEnums1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfNumberOnly.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfNumberOnly.java index e1235cb8247..20dbea6ebad 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfNumberOnly.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayOfNumberOnly.java @@ -6,10 +6,10 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ArrayOfNumberOnly { // nest classes so all schemas and input/output classes can be public @@ -18,30 +18,51 @@ public class ArrayOfNumberOnly { public class Items extends NumberJsonSchema {} - public class ArrayNumber implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayNumberList extends FrozenList { + ArrayNumberList(FrozenList m) { + super(m); + } + } + + public class ArrayNumber extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayNumberList getListOutputInstance(FrozenList arg) { + return new ArrayNumberList(arg); + } + public static ArrayNumberList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayNumber.class, arg, configuration); } } - public class ArrayOfNumberOnly1 implements JsonSchema { + public static class ArrayOfNumberOnlyMap extends FrozenMap { + ArrayOfNumberOnlyMap(FrozenMap m) { + super(m); + } + public static ArrayOfNumberOnlyMap of(Map arg, SchemaConfiguration configuration) { + return ArrayOfNumberOnly1.validate(arg, configuration); + } + } + + public class ArrayOfNumberOnly1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("ArrayNumber", ArrayNumber.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ArrayOfNumberOnlyMap getMapOutputInstance(FrozenMap arg) { + return new ArrayOfNumberOnlyMap(arg); + } + public static ArrayOfNumberOnlyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayOfNumberOnly1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayTest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayTest.java index ffe4cc391ca..3844ecb3ddf 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayTest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayTest.java @@ -6,11 +6,11 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ArrayTest { // nest classes so all schemas and input/output classes can be public @@ -19,12 +19,21 @@ public class ArrayTest { public class Items extends StringJsonSchema {} - public class ArrayOfString implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayOfStringList extends FrozenList { + ArrayOfStringList(FrozenList m) { + super(m); + } + } + + public class ArrayOfString extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayOfStringList getListOutputInstance(FrozenList arg) { + return new ArrayOfStringList(arg); + } + public static ArrayOfStringList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayOfString.class, arg, configuration); } } @@ -32,62 +41,110 @@ public static U validate(List arg, SchemaConfigur public class Items2 extends Int64JsonSchema {} - public class Items1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ItemsList extends FrozenList { + ItemsList(FrozenList m) { + super(m); + } + } + + public class Items1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items2.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items2.class; + protected static ItemsList getListOutputInstance(FrozenList arg) { + return new ItemsList(arg); + } + public static ItemsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Items1.class, arg, configuration); } } - public class ArrayArrayOfInteger implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayArrayOfIntegerList extends FrozenList { + ArrayArrayOfIntegerList(FrozenList m) { + super(m); + } + } + + public class ArrayArrayOfInteger extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items1.class; + protected static ArrayArrayOfIntegerList getListOutputInstance(FrozenList arg) { + return new ArrayArrayOfIntegerList(arg); + } + public static ArrayArrayOfIntegerList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayArrayOfInteger.class, arg, configuration); } } - public class Items3 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ItemsList1 extends FrozenList { + ItemsList1(FrozenList m) { + super(m); + } + } + + public class Items3 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = ReadOnlyFirst.ReadOnlyFirst1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = ReadOnlyFirst.ReadOnlyFirst1.class; + protected static ItemsList1 getListOutputInstance(FrozenList arg) { + return new ItemsList1(arg); + } + public static ItemsList1 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Items3.class, arg, configuration); } } - public class ArrayArrayOfModel implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayArrayOfModelList extends FrozenList { + ArrayArrayOfModelList(FrozenList m) { + super(m); + } + } + + public class ArrayArrayOfModel extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items3.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items3.class; + protected static ArrayArrayOfModelList getListOutputInstance(FrozenList arg) { + return new ArrayArrayOfModelList(arg); + } + public static ArrayArrayOfModelList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayArrayOfModel.class, arg, configuration); } } - public class ArrayTest1 implements JsonSchema { + public static class ArrayTestMap extends FrozenMap { + ArrayTestMap(FrozenMap m) { + super(m); + } + public static ArrayTestMap of(Map arg, SchemaConfiguration configuration) { + return ArrayTest1.validate(arg, configuration); + } + } + + public class ArrayTest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("array_of_string", ArrayOfString.class), new AbstractMap.SimpleEntry>("array_array_of_integer", ArrayArrayOfInteger.class), new AbstractMap.SimpleEntry>("array_array_of_model", ArrayArrayOfModel.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ArrayTestMap getMapOutputInstance(FrozenMap arg) { + return new ArrayTestMap(arg); + } + public static ArrayTestMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayTest1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayWithValidationsInItems.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayWithValidationsInItems.java index 49d690f17a9..6f5013a9986 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayWithValidationsInItems.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ArrayWithValidationsInItems.java @@ -3,21 +3,21 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ArrayWithValidationsInItems { // nest classes so all schemas and input/output classes can be public - public class Items implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int64"; + public static final String format = "int64"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(Items.class, Long.valueOf(arg), configuration); } @@ -35,18 +35,27 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { } } - public class ArrayWithValidationsInItems1 implements JsonSchema { + public static class ArrayWithValidationsInItemsList extends FrozenList { + ArrayWithValidationsInItemsList(FrozenList m) { + super(m); + } + } + + public class ArrayWithValidationsInItems1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayWithValidationsInItemsList getListOutputInstance(FrozenList arg) { + return new ArrayWithValidationsInItemsList(arg); + } + public static ArrayWithValidationsInItemsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayWithValidationsInItems1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Banana.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Banana.java index 6064e7e37a7..fad9bd91db5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Banana.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Banana.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Banana { // nest classes so all schemas and input/output classes can be public @@ -16,23 +16,35 @@ public class Banana { public class LengthCm extends NumberJsonSchema {} - public class Banana1 implements JsonSchema { + public static class BananaMap extends FrozenMap { + BananaMap(FrozenMap m) { + super(m); + } + public static BananaMap of(Map arg, SchemaConfiguration configuration) { + return Banana1.validate(arg, configuration); + } + } + + public class Banana1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("lengthCm", LengthCm.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "lengthCm" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static BananaMap getMapOutputInstance(FrozenMap arg) { + return new BananaMap(arg); + } + public static BananaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Banana1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BananaReq.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BananaReq.java index 011893e5237..3c2ff2cdaa0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BananaReq.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BananaReq.java @@ -7,10 +7,10 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; import org.openapijsonschematools.schemas.BooleanJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class BananaReq { // nest classes so all schemas and input/output classes can be public @@ -26,25 +26,37 @@ public class LengthCm extends NumberJsonSchema {} public class Sweet extends BooleanJsonSchema {} - public class BananaReq1 implements JsonSchema { + public static class BananaReqMap extends FrozenMap { + BananaReqMap(FrozenMap m) { + super(m); + } + public static BananaReqMap of(Map arg, SchemaConfiguration configuration) { + return BananaReq1.validate(arg, configuration); + } + } + + public class BananaReq1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("lengthCm", LengthCm.class), new AbstractMap.SimpleEntry>("sweet", Sweet.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "lengthCm" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static BananaReqMap getMapOutputInstance(FrozenMap arg) { + return new BananaReqMap(arg); + } + public static BananaReqMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(BananaReq1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Bar.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Bar.java index 96475e04d91..01c26b74350 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Bar.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Bar.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Bar { // nest classes so all schemas and input/output classes can be public - public class Bar1 implements JsonSchema { + public class Bar1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BasquePig.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BasquePig.java index 573505ec11e..ded1d9b85e8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BasquePig.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BasquePig.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class BasquePig { // nest classes so all schemas and input/output classes can be public - public class ClassName implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ClassName extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -21,23 +21,35 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class BasquePig1 implements JsonSchema { + public static class BasquePigMap extends FrozenMap { + BasquePigMap(FrozenMap m) { + super(m); + } + public static BasquePigMap of(Map arg, SchemaConfiguration configuration) { + return BasquePig1.validate(arg, configuration); + } + } + + public class BasquePig1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("className", ClassName.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "className" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static BasquePigMap getMapOutputInstance(FrozenMap arg) { + return new BasquePigMap(arg); + } + public static BasquePigMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(BasquePig1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BooleanEnum.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BooleanEnum.java index 00dcff338fb..a269f1fec4d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BooleanEnum.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/BooleanEnum.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class BooleanEnum { // nest classes so all schemas and input/output classes can be public - public class BooleanEnum1 implements JsonSchema { + public class BooleanEnum1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Boolean.class )); public static Boolean validate(Boolean arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Capitalization.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Capitalization.java index c59d2cf4dec..eb29e09a263 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Capitalization.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Capitalization.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Capitalization { // nest classes so all schemas and input/output classes can be public @@ -31,17 +31,26 @@ public class SCAETHFlowPoints extends StringJsonSchema {} public class ATTNAME extends StringJsonSchema {} - public class Capitalization1 implements JsonSchema { + public static class CapitalizationMap extends FrozenMap { + CapitalizationMap(FrozenMap m) { + super(m); + } + public static CapitalizationMap of(Map arg, SchemaConfiguration configuration) { + return Capitalization1.validate(arg, configuration); + } + } + + public class Capitalization1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("smallCamel", SmallCamel.class), new AbstractMap.SimpleEntry>("CapitalCamel", CapitalCamel.class), new AbstractMap.SimpleEntry>("small_Snake", SmallSnake.class), @@ -49,7 +58,10 @@ public class Capitalization1 implements JsonSchema { new AbstractMap.SimpleEntry>("SCA_ETH_Flow_Points", SCAETHFlowPoints.class), new AbstractMap.SimpleEntry>("ATT_NAME", ATTNAME.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static CapitalizationMap getMapOutputInstance(FrozenMap arg) { + return new CapitalizationMap(arg); + } + public static CapitalizationMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Capitalization1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Cat.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Cat.java index 6856411f153..f9bdea04199 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Cat.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Cat.java @@ -10,9 +10,9 @@ import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.BooleanJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Cat { // nest classes so all schemas and input/output classes can be public @@ -21,20 +21,32 @@ public class Cat { public class Declawed extends BooleanJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("declawed", Declawed.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class Cat1 implements JsonSchema { + public class Cat1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Category.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Category.java index d5e75cf0b86..1876d2d33c1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Category.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Category.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Category { // nest classes so all schemas and input/output classes can be public @@ -16,8 +16,8 @@ public class Category { public class Id extends Int64JsonSchema {} - public class Name implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Name extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -25,24 +25,36 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Category1 implements JsonSchema { + public static class CategoryMap extends FrozenMap { + CategoryMap(FrozenMap m) { + super(m); + } + public static CategoryMap of(Map arg, SchemaConfiguration configuration) { + return Category1.validate(arg, configuration); + } + } + + public class Category1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class), new AbstractMap.SimpleEntry>("name", Name.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "name" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static CategoryMap getMapOutputInstance(FrozenMap arg) { + return new CategoryMap(arg); + } + public static CategoryMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Category1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ChildCat.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ChildCat.java index 217ff7a492f..310ba0f72cc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ChildCat.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ChildCat.java @@ -9,10 +9,10 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ChildCat { // nest classes so all schemas and input/output classes can be public @@ -21,20 +21,32 @@ public class ChildCat { public class Name extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("name", Name.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class ChildCat1 implements JsonSchema { + public class ChildCat1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ClassModel.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ClassModel.java index 35265a977a3..65c335578f0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ClassModel.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ClassModel.java @@ -7,10 +7,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ClassModel { // nest classes so all schemas and input/output classes can be public @@ -19,7 +19,16 @@ public class ClassModel { public class ClassSchema extends StringJsonSchema {} - public class ClassModel1 implements JsonSchema { + public static class ClassModelMap extends FrozenMap { + ClassModelMap(FrozenMap m) { + super(m); + } + public static ClassModelMap of(Map arg, SchemaConfiguration configuration) { + return ClassModel1.validate(arg, configuration); + } + } + + public class ClassModel1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -28,7 +37,7 @@ public class ClassModel1 implements JsonSchema { Model for testing model with "_class" property */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("_class", ClassSchema.class) )); public static Void validate(Void arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Client.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Client.java index 15bfeae2847..c40282367d0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Client.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Client.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Client { // nest classes so all schemas and input/output classes can be public @@ -16,20 +16,32 @@ public class Client { public class Client2 extends StringJsonSchema {} - public class Client1 implements JsonSchema { + public static class ClientMap extends FrozenMap { + ClientMap(FrozenMap m) { + super(m); + } + public static ClientMap of(Map arg, SchemaConfiguration configuration) { + return Client1.validate(arg, configuration); + } + } + + public class Client1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("client", Client2.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ClientMap getMapOutputInstance(FrozenMap arg) { + return new ClientMap(arg); + } + public static ClientMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Client1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComplexQuadrilateral.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComplexQuadrilateral.java index 8850c1ed454..830989aa5dc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComplexQuadrilateral.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComplexQuadrilateral.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComplexQuadrilateral { // nest classes so all schemas and input/output classes can be public - public class QuadrilateralType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class QuadrilateralType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,20 +26,32 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("quadrilateralType", QuadrilateralType.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class ComplexQuadrilateral1 implements JsonSchema { + public class ComplexQuadrilateral1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedAnyOfDifferentTypesNoValidations.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedAnyOfDifferentTypesNoValidations.java index 3f2a9180454..6196160db8c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedAnyOfDifferentTypesNoValidations.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedAnyOfDifferentTypesNoValidations.java @@ -13,16 +13,16 @@ import org.openapijsonschematools.schemas.DateTimeJsonSchema; import org.openapijsonschematools.schemas.DoubleJsonSchema; import org.openapijsonschematools.schemas.FloatJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; import org.openapijsonschematools.schemas.Int64JsonSchema; import org.openapijsonschematools.schemas.IntJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.MapJsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedAnyOfDifferentTypesNoValidations { // nest classes so all schemas and input/output classes can be public @@ -37,7 +37,7 @@ public class Schema1 extends DateJsonSchema {} public class Schema2 extends DateTimeJsonSchema {} - public class Schema3 implements JsonSchema { + public class Schema3 extends JsonSchema { // BinarySchema } @@ -60,12 +60,21 @@ public class Schema8 extends NullJsonSchema {} public class Items extends AnyTypeJsonSchema {} - public class Schema9 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema9List extends FrozenList { + Schema9List(FrozenList m) { + super(m); + } + } + + public class Schema9 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static Schema9List getListOutputInstance(FrozenList arg) { + return new Schema9List(arg); + } + public static Schema9List validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema9.class, arg, configuration); } } @@ -88,7 +97,7 @@ public class Schema14 extends Int32JsonSchema {} public class Schema15 extends Int64JsonSchema {} - public class ComposedAnyOfDifferentTypesNoValidations1 implements JsonSchema { + public class ComposedAnyOfDifferentTypesNoValidations1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedArray.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedArray.java index c85b3e2e354..2789b564c22 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedArray.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedArray.java @@ -4,8 +4,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedArray { // nest classes so all schemas and input/output classes can be public @@ -14,18 +14,27 @@ public class ComposedArray { public class Items extends AnyTypeJsonSchema {} - public class ComposedArray1 implements JsonSchema { + public static class ComposedArrayList extends FrozenList { + ComposedArrayList(FrozenList m) { + super(m); + } + } + + public class ComposedArray1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ComposedArrayList getListOutputInstance(FrozenList arg) { + return new ComposedArrayList(arg); + } + public static ComposedArrayList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ComposedArray1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedBool.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedBool.java index 99ccf357c0f..cc4ef0a8741 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedBool.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedBool.java @@ -3,7 +3,7 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedBool { // nest classes so all schemas and input/output classes can be public @@ -12,14 +12,14 @@ public class ComposedBool { public class Schema0 extends AnyTypeJsonSchema {} - public class ComposedBool1 implements JsonSchema { + public class ComposedBool1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Boolean.class )); public static Boolean validate(Boolean arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNone.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNone.java index 6fc17f12d1c..e6b96637333 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNone.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNone.java @@ -3,7 +3,7 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedNone { // nest classes so all schemas and input/output classes can be public @@ -12,14 +12,14 @@ public class ComposedNone { public class Schema0 extends AnyTypeJsonSchema {} - public class ComposedNone1 implements JsonSchema { + public class ComposedNone1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class )); public static Void validate(Void arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNumber.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNumber.java index 04821c3a958..00eb3546423 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNumber.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedNumber.java @@ -3,7 +3,7 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedNumber { // nest classes so all schemas and input/output classes can be public @@ -12,14 +12,14 @@ public class ComposedNumber { public class Schema0 extends AnyTypeJsonSchema {} - public class ComposedNumber1 implements JsonSchema { + public class ComposedNumber1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedObject.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedObject.java index e5c49f7af62..3b814337035 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedObject.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedObject.java @@ -4,8 +4,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedObject { // nest classes so all schemas and input/output classes can be public @@ -14,14 +14,14 @@ public class ComposedObject { public class Schema0 extends AnyTypeJsonSchema {} - public class ComposedObject1 implements JsonSchema { + public class ComposedObject1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); public static T validate(Map arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedOneOfDifferentTypes.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedOneOfDifferentTypes.java index b870693ee07..35d2fe9d564 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedOneOfDifferentTypes.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedOneOfDifferentTypes.java @@ -9,10 +9,10 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; import org.openapijsonschematools.schemas.DateJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedOneOfDifferentTypes { // nest classes so all schemas and input/output classes can be public @@ -24,8 +24,8 @@ public class Schema2 extends NullJsonSchema {} public class Schema3 extends DateJsonSchema {} - public class Schema4 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema4 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); public static T validate(Map arg, SchemaConfiguration configuration) { @@ -37,27 +37,36 @@ public static T validate(Map arg, SchemaCo public class Items extends AnyTypeJsonSchema {} - public class Schema5 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema5List extends FrozenList { + Schema5List(FrozenList m) { + super(m); + } + } + + public class Schema5 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static Schema5List getListOutputInstance(FrozenList arg) { + return new Schema5List(arg); + } + public static Schema5List validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema5.class, arg, configuration); } } - public class Schema6 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema6 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "date-time"; + public static final String format = "date-time"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema6.class, arg, configuration); } } - public class ComposedOneOfDifferentTypes1 implements JsonSchema { + public class ComposedOneOfDifferentTypes1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedString.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedString.java index 697227e728c..44e10899ad3 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedString.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ComposedString.java @@ -3,7 +3,7 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ComposedString { // nest classes so all schemas and input/output classes can be public @@ -12,14 +12,14 @@ public class ComposedString { public class Schema0 extends AnyTypeJsonSchema {} - public class ComposedString1 implements JsonSchema { + public class ComposedString1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Currency.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Currency.java index 534e6ea6454..ab64c516c7b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Currency.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Currency.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Currency { // nest classes so all schemas and input/output classes can be public - public class Currency1 implements JsonSchema { + public class Currency1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DanishPig.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DanishPig.java index f0a04ffc24a..7f0a8973a9f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DanishPig.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DanishPig.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class DanishPig { // nest classes so all schemas and input/output classes can be public - public class ClassName implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ClassName extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -21,23 +21,35 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class DanishPig1 implements JsonSchema { + public static class DanishPigMap extends FrozenMap { + DanishPigMap(FrozenMap m) { + super(m); + } + public static DanishPigMap of(Map arg, SchemaConfiguration configuration) { + return DanishPig1.validate(arg, configuration); + } + } + + public class DanishPig1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("className", ClassName.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "className" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static DanishPigMap getMapOutputInstance(FrozenMap arg) { + return new DanishPigMap(arg); + } + public static DanishPigMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(DanishPig1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeTest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeTest.java index 4c3045af39e..51d279694f2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeTest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeTest.java @@ -3,23 +3,23 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class DateTimeTest { // nest classes so all schemas and input/output classes can be public - public class DateTimeTest1 implements JsonSchema { + public class DateTimeTest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "date-time"; + public static final String format = "date-time"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(DateTimeTest1.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeWithValidations.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeWithValidations.java index bbb9e784f3b..ae1661ca333 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeWithValidations.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateTimeWithValidations.java @@ -3,23 +3,23 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class DateTimeWithValidations { // nest classes so all schemas and input/output classes can be public - public class DateTimeWithValidations1 implements JsonSchema { + public class DateTimeWithValidations1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "date-time"; + public static final String format = "date-time"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(DateTimeWithValidations1.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateWithValidations.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateWithValidations.java index c8495a68938..bbdc622e15f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateWithValidations.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/DateWithValidations.java @@ -3,23 +3,23 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class DateWithValidations { // nest classes so all schemas and input/output classes can be public - public class DateWithValidations1 implements JsonSchema { + public class DateWithValidations1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "date"; + public static final String format = "date"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(DateWithValidations1.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Dog.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Dog.java index 54023ef9c9e..ee70236541d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Dog.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Dog.java @@ -9,10 +9,10 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Dog { // nest classes so all schemas and input/output classes can be public @@ -21,20 +21,32 @@ public class Dog { public class Breed extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("breed", Breed.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class Dog1 implements JsonSchema { + public class Dog1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Drawing.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Drawing.java index 8c81bad4408..b778cb63aa8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Drawing.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Drawing.java @@ -6,42 +6,63 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Drawing { // nest classes so all schemas and input/output classes can be public - public class Shapes implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ShapesList extends FrozenList { + ShapesList(FrozenList m) { + super(m); + } + } + + public class Shapes extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Shape.Shape1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Shape.Shape1.class; + protected static ShapesList getListOutputInstance(FrozenList arg) { + return new ShapesList(arg); + } + public static ShapesList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Shapes.class, arg, configuration); } } - public class Drawing1 implements JsonSchema { + public static class DrawingMap extends FrozenMap { + DrawingMap(FrozenMap m) { + super(m); + } + public static DrawingMap of(Map arg, SchemaConfiguration configuration) { + return Drawing1.validate(arg, configuration); + } + } + + public class Drawing1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("mainShape", Shape.Shape1.class), new AbstractMap.SimpleEntry>("shapeOrNull", ShapeOrNull.ShapeOrNull1.class), new AbstractMap.SimpleEntry>("nullableShape", NullableShape.NullableShape1.class), new AbstractMap.SimpleEntry>("shapes", Shapes.class) )); static final Class additionalProperties = Fruit.Fruit1.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static DrawingMap getMapOutputInstance(FrozenMap arg) { + return new DrawingMap(arg); + } + public static DrawingMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Drawing1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumArrays.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumArrays.java index 3f71c9743bb..7023f1d2687 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumArrays.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumArrays.java @@ -6,16 +6,16 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class EnumArrays { // nest classes so all schemas and input/output classes can be public - public class JustSymbol implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class JustSymbol extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -23,8 +23,8 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Items implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -32,31 +32,52 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class ArrayEnum implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayEnumList extends FrozenList { + ArrayEnumList(FrozenList m) { + super(m); + } + } + + public class ArrayEnum extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayEnumList getListOutputInstance(FrozenList arg) { + return new ArrayEnumList(arg); + } + public static ArrayEnumList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayEnum.class, arg, configuration); } } - public class EnumArrays1 implements JsonSchema { + public static class EnumArraysMap extends FrozenMap { + EnumArraysMap(FrozenMap m) { + super(m); + } + public static EnumArraysMap of(Map arg, SchemaConfiguration configuration) { + return EnumArrays1.validate(arg, configuration); + } + } + + public class EnumArrays1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("just_symbol", JustSymbol.class), new AbstractMap.SimpleEntry>("array_enum", ArrayEnum.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static EnumArraysMap getMapOutputInstance(FrozenMap arg) { + return new EnumArraysMap(arg); + } + public static EnumArraysMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(EnumArrays1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumClass.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumClass.java index ada2b9d4825..e904f029cb6 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumClass.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumClass.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class EnumClass { // nest classes so all schemas and input/output classes can be public - public class EnumClass1 implements JsonSchema { + public class EnumClass1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumTest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumTest.java index 48648244be0..9ed7338863d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumTest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EnumTest.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class EnumTest { // nest classes so all schemas and input/output classes can be public - public class EnumString implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class EnumString extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -21,8 +21,8 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class EnumStringRequired implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class EnumStringRequired extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -30,14 +30,14 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class EnumInteger implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class EnumInteger extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int32"; + public static final String format = "int32"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(EnumInteger.class, Long.valueOf(arg), configuration); } @@ -55,30 +55,39 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { } } - public class EnumNumber implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class EnumNumber extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "double"; + public static final String format = "double"; public static Double validate(Double arg, SchemaConfiguration configuration) { return JsonSchema.validate(EnumNumber.class, arg, configuration); } } - public class EnumTest1 implements JsonSchema { + public static class EnumTestMap extends FrozenMap { + EnumTestMap(FrozenMap m) { + super(m); + } + public static EnumTestMap of(Map arg, SchemaConfiguration configuration) { + return EnumTest1.validate(arg, configuration); + } + } + + public class EnumTest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("enum_string", EnumString.class), new AbstractMap.SimpleEntry>("enum_string_required", EnumStringRequired.class), new AbstractMap.SimpleEntry>("enum_integer", EnumInteger.class), @@ -89,10 +98,13 @@ public class EnumTest1 implements JsonSchema { new AbstractMap.SimpleEntry>("IntegerEnumWithDefaultValue", IntegerEnumWithDefaultValue.IntegerEnumWithDefaultValue1.class), new AbstractMap.SimpleEntry>("IntegerEnumOneValue", IntegerEnumOneValue.IntegerEnumOneValue1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "enum_string_required" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static EnumTestMap getMapOutputInstance(FrozenMap arg) { + return new EnumTestMap(arg); + } + public static EnumTestMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(EnumTest1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EquilateralTriangle.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EquilateralTriangle.java index fc304ea9f73..2a10dcbd9f2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EquilateralTriangle.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/EquilateralTriangle.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class EquilateralTriangle { // nest classes so all schemas and input/output classes can be public - public class TriangleType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class TriangleType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,20 +26,32 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("triangleType", TriangleType.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class EquilateralTriangle1 implements JsonSchema { + public class EquilateralTriangle1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/File.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/File.java index 4d36a631484..c0a9c66f2d3 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/File.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/File.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class File { // nest classes so all schemas and input/output classes can be public @@ -16,7 +16,16 @@ public class File { public class SourceURI extends StringJsonSchema {} - public class File1 implements JsonSchema { + public static class FileMap extends FrozenMap { + FileMap(FrozenMap m) { + super(m); + } + public static FileMap of(Map arg, SchemaConfiguration configuration) { + return File1.validate(arg, configuration); + } + } + + public class File1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -25,13 +34,16 @@ public class File1 implements JsonSchema { Must be named `File` for test. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("sourceURI", SourceURI.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static FileMap getMapOutputInstance(FrozenMap arg) { + return new FileMap(arg); + } + public static FileMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(File1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FileSchemaTestClass.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FileSchemaTestClass.java index 65a0de5fedd..9dbdd393d20 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FileSchemaTestClass.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FileSchemaTestClass.java @@ -6,39 +6,60 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class FileSchemaTestClass { // nest classes so all schemas and input/output classes can be public - public class Files implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class FilesList extends FrozenList { + FilesList(FrozenList m) { + super(m); + } + } + + public class Files extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = File.File1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = File.File1.class; + protected static FilesList getListOutputInstance(FrozenList arg) { + return new FilesList(arg); + } + public static FilesList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Files.class, arg, configuration); } } - public class FileSchemaTestClass1 implements JsonSchema { + public static class FileSchemaTestClassMap extends FrozenMap { + FileSchemaTestClassMap(FrozenMap m) { + super(m); + } + public static FileSchemaTestClassMap of(Map arg, SchemaConfiguration configuration) { + return FileSchemaTestClass1.validate(arg, configuration); + } + } + + public class FileSchemaTestClass1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("file", File.File1.class), new AbstractMap.SimpleEntry>("files", Files.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static FileSchemaTestClassMap getMapOutputInstance(FrozenMap arg) { + return new FileSchemaTestClassMap(arg); + } + public static FileSchemaTestClassMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(FileSchemaTestClass1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Foo.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Foo.java index b15bfec449a..73948a59d0f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Foo.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Foo.java @@ -5,27 +5,39 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Foo { // nest classes so all schemas and input/output classes can be public - public class Foo1 implements JsonSchema { + public static class FooMap extends FrozenMap { + FooMap(FrozenMap m) { + super(m); + } + public static FooMap of(Map arg, SchemaConfiguration configuration) { + return Foo1.validate(arg, configuration); + } + } + + public class Foo1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("bar", Bar.Bar1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static FooMap getMapOutputInstance(FrozenMap arg) { + return new FooMap(arg); + } + public static FooMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Foo1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FormatTest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FormatTest.java index a8b8116c3b9..d2538c141f5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FormatTest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FormatTest.java @@ -10,22 +10,22 @@ import org.openapijsonschematools.schemas.DateTimeJsonSchema; import org.openapijsonschematools.schemas.DoubleJsonSchema; import org.openapijsonschematools.schemas.FloatJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; import org.openapijsonschematools.schemas.UuidJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class FormatTest { // nest classes so all schemas and input/output classes can be public - public class IntegerSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class IntegerSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, @@ -51,14 +51,14 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { public class Int32 extends Int32JsonSchema {} - public class Int32withValidations implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Int32withValidations extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int32"; + public static final String format = "int32"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(Int32withValidations.class, Long.valueOf(arg), configuration); } @@ -79,8 +79,8 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { public class Int64 extends Int64JsonSchema {} - public class NumberSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class NumberSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, @@ -103,14 +103,14 @@ public static Number validate(Double arg, SchemaConfiguration configuration) { } } - public class FloatSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class FloatSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "float"; + public static final String format = "float"; public static Float validate(Float arg, SchemaConfiguration configuration) { return JsonSchema.validate(FloatSchema.class, arg, configuration); } @@ -119,14 +119,14 @@ public static Float validate(Float arg, SchemaConfiguration configuration) { public class Float32 extends FloatJsonSchema {} - public class DoubleSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class DoubleSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "double"; + public static final String format = "double"; public static Double validate(Double arg, SchemaConfiguration configuration) { return JsonSchema.validate(DoubleSchema.class, arg, configuration); } @@ -138,18 +138,27 @@ public class Float64 extends DoubleJsonSchema {} public class Items extends NumberJsonSchema {} - public class ArrayWithUniqueItems implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayWithUniqueItemsList extends FrozenList { + ArrayWithUniqueItemsList(FrozenList m) { + super(m); + } + } + + public class ArrayWithUniqueItems extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static ArrayWithUniqueItemsList getListOutputInstance(FrozenList arg) { + return new ArrayWithUniqueItemsList(arg); + } + public static ArrayWithUniqueItemsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayWithUniqueItems.class, arg, configuration); } } - public class StringSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class StringSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -160,7 +169,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class ByteSchema extends StringJsonSchema {} - public class Binary implements JsonSchema { + public class Binary extends JsonSchema { // BinarySchema } @@ -177,18 +186,18 @@ public class UuidSchema extends UuidJsonSchema {} public class UuidNoExample extends UuidJsonSchema {} - public class Password implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Password extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "password"; + public static final String format = "password"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(Password.class, arg, configuration); } } - public class PatternWithDigits implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class PatternWithDigits extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -196,8 +205,8 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class PatternWithDigitsAndDelimiter implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class PatternWithDigitsAndDelimiter extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -208,17 +217,26 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class NoneProp extends NullJsonSchema {} - public class FormatTest1 implements JsonSchema { + public static class FormatTestMap extends FrozenMap { + FormatTestMap(FrozenMap m) { + super(m); + } + public static FormatTestMap of(Map arg, SchemaConfiguration configuration) { + return FormatTest1.validate(arg, configuration); + } + } + + public class FormatTest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("integer", IntegerSchema.class), new AbstractMap.SimpleEntry>("int32", Int32.class), new AbstractMap.SimpleEntry>("int32withValidations", Int32withValidations.class), @@ -241,13 +259,16 @@ public class FormatTest1 implements JsonSchema { new AbstractMap.SimpleEntry>("pattern_with_digits_and_delimiter", PatternWithDigitsAndDelimiter.class), new AbstractMap.SimpleEntry>("noneProp", NoneProp.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "byte", "date", "number", "password" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static FormatTestMap getMapOutputInstance(FrozenMap arg) { + return new FormatTestMap(arg); + } + public static FormatTestMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(FormatTest1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FromSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FromSchema.java index 603fbd4e715..7db3a3c7f68 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FromSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FromSchema.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.IntJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class FromSchema { // nest classes so all schemas and input/output classes can be public @@ -20,21 +20,33 @@ public class Data extends StringJsonSchema {} public class Id extends IntJsonSchema {} - public class FromSchema1 implements JsonSchema { + public static class FromSchemaMap extends FrozenMap { + FromSchemaMap(FrozenMap m) { + super(m); + } + public static FromSchemaMap of(Map arg, SchemaConfiguration configuration) { + return FromSchema1.validate(arg, configuration); + } + } + + public class FromSchema1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("data", Data.class), new AbstractMap.SimpleEntry>("id", Id.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static FromSchemaMap getMapOutputInstance(FrozenMap arg) { + return new FromSchemaMap(arg); + } + public static FromSchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(FromSchema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Fruit.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Fruit.java index 5de08421f38..15b0dbae51c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Fruit.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Fruit.java @@ -7,10 +7,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Fruit { // nest classes so all schemas and input/output classes can be public @@ -19,14 +19,23 @@ public class Fruit { public class Color extends StringJsonSchema {} - public class Fruit1 implements JsonSchema { + public static class FruitMap extends FrozenMap { + FruitMap(FrozenMap m) { + super(m); + } + public static FruitMap of(Map arg, SchemaConfiguration configuration) { + return Fruit1.validate(arg, configuration); + } + } + + public class Fruit1 extends JsonSchema { /* 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. */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("color", Color.class) )); public static Void validate(Void arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FruitReq.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FruitReq.java index 161e9d0f13f..0ae6cfadf0f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FruitReq.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/FruitReq.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class FruitReq { // nest classes so all schemas and input/output classes can be public @@ -17,7 +17,7 @@ public class FruitReq { public class Schema0 extends NullJsonSchema {} - public class FruitReq1 implements JsonSchema { + public class FruitReq1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GmFruit.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GmFruit.java index c9fe93630a0..a09c1a0913b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GmFruit.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GmFruit.java @@ -7,10 +7,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class GmFruit { // nest classes so all schemas and input/output classes can be public @@ -19,14 +19,23 @@ public class GmFruit { public class Color extends StringJsonSchema {} - public class GmFruit1 implements JsonSchema { + public static class GmFruitMap extends FrozenMap { + GmFruitMap(FrozenMap m) { + super(m); + } + public static GmFruitMap of(Map arg, SchemaConfiguration configuration) { + return GmFruit1.validate(arg, configuration); + } + } + + public class GmFruit1 extends JsonSchema { /* 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. */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("color", Color.class) )); public static Void validate(Void arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GrandparentAnimal.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GrandparentAnimal.java index 14e1deca98d..bfa621296a1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GrandparentAnimal.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/GrandparentAnimal.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class GrandparentAnimal { // nest classes so all schemas and input/output classes can be public @@ -16,23 +16,35 @@ public class GrandparentAnimal { public class PetType extends StringJsonSchema {} - public class GrandparentAnimal1 implements JsonSchema { + public static class GrandparentAnimalMap extends FrozenMap { + GrandparentAnimalMap(FrozenMap m) { + super(m); + } + public static GrandparentAnimalMap of(Map arg, SchemaConfiguration configuration) { + return GrandparentAnimal1.validate(arg, configuration); + } + } + + public class GrandparentAnimal1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("pet_type", PetType.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "pet_type" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static GrandparentAnimalMap getMapOutputInstance(FrozenMap arg) { + return new GrandparentAnimalMap(arg); + } + public static GrandparentAnimalMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(GrandparentAnimal1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HasOnlyReadOnly.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HasOnlyReadOnly.java index bcfc46979a6..0297502c346 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HasOnlyReadOnly.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HasOnlyReadOnly.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HasOnlyReadOnly { // nest classes so all schemas and input/output classes can be public @@ -19,21 +19,33 @@ public class Bar extends StringJsonSchema {} public class Foo extends StringJsonSchema {} - public class HasOnlyReadOnly1 implements JsonSchema { + public static class HasOnlyReadOnlyMap extends FrozenMap { + HasOnlyReadOnlyMap(FrozenMap m) { + super(m); + } + public static HasOnlyReadOnlyMap of(Map arg, SchemaConfiguration configuration) { + return HasOnlyReadOnly1.validate(arg, configuration); + } + } + + public class HasOnlyReadOnly1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("bar", Bar.class), new AbstractMap.SimpleEntry>("foo", Foo.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HasOnlyReadOnlyMap getMapOutputInstance(FrozenMap arg) { + return new HasOnlyReadOnlyMap(arg); + } + public static HasOnlyReadOnlyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HasOnlyReadOnly1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HealthCheckResult.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HealthCheckResult.java index 5cb6d362943..0b04cc8d089 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HealthCheckResult.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/HealthCheckResult.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HealthCheckResult { // nest classes so all schemas and input/output classes can be public - public class NullableMessage implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class NullableMessage extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, String.class )); @@ -25,7 +25,16 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class HealthCheckResult1 implements JsonSchema { + public static class HealthCheckResultMap extends FrozenMap { + HealthCheckResultMap(FrozenMap m) { + super(m); + } + public static HealthCheckResultMap of(Map arg, SchemaConfiguration configuration) { + return HealthCheckResult1.validate(arg, configuration); + } + } + + public class HealthCheckResult1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -34,13 +43,16 @@ public class HealthCheckResult1 implements JsonSchema { Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("NullableMessage", NullableMessage.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HealthCheckResultMap getMapOutputInstance(FrozenMap arg) { + return new HealthCheckResultMap(arg); + } + public static HealthCheckResultMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HealthCheckResult1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnum.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnum.java index b0fddd3e742..85681bf1e00 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnum.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnum.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IntegerEnum { // nest classes so all schemas and input/output classes can be public - public class IntegerEnum1 implements JsonSchema { + public class IntegerEnum1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumBig.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumBig.java index ff40bffd396..8592981e83b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumBig.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumBig.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IntegerEnumBig { // nest classes so all schemas and input/output classes can be public - public class IntegerEnumBig1 implements JsonSchema { + public class IntegerEnumBig1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumOneValue.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumOneValue.java index ab9a2eeea88..142d98c6bc9 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumOneValue.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumOneValue.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IntegerEnumOneValue { // nest classes so all schemas and input/output classes can be public - public class IntegerEnumOneValue1 implements JsonSchema { + public class IntegerEnumOneValue1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumWithDefaultValue.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumWithDefaultValue.java index f16fba4e854..71b187b318f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumWithDefaultValue.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerEnumWithDefaultValue.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IntegerEnumWithDefaultValue { // nest classes so all schemas and input/output classes can be public - public class IntegerEnumWithDefaultValue1 implements JsonSchema { + public class IntegerEnumWithDefaultValue1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMax10.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMax10.java index 7ce17505f5b..4b187a9a0ef 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMax10.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMax10.java @@ -2,26 +2,26 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IntegerMax10 { // nest classes so all schemas and input/output classes can be public - public class IntegerMax101 implements JsonSchema { + public class IntegerMax101 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int64"; + public static final String format = "int64"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(IntegerMax101.class, Long.valueOf(arg), configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMin15.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMin15.java index 915af6ac10d..379dac1e8a2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMin15.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IntegerMin15.java @@ -2,26 +2,26 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IntegerMin15 { // nest classes so all schemas and input/output classes can be public - public class IntegerMin151 implements JsonSchema { + public class IntegerMin151 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int64"; + public static final String format = "int64"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(IntegerMin151.class, Long.valueOf(arg), configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IsoscelesTriangle.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IsoscelesTriangle.java index 6e3e998d223..62d80efb926 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IsoscelesTriangle.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/IsoscelesTriangle.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class IsoscelesTriangle { // nest classes so all schemas and input/output classes can be public - public class TriangleType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class TriangleType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,20 +26,32 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("triangleType", TriangleType.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class IsoscelesTriangle1 implements JsonSchema { + public class IsoscelesTriangle1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Items.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Items.java index 2b3300789d0..69721a53f2b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Items.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Items.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.MapJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Items { // nest classes so all schemas and input/output classes can be public @@ -14,7 +14,13 @@ public class Items { public class Items2 extends MapJsonSchema {} - public class Items1 implements JsonSchema { + public static class ItemsList extends FrozenList { + ItemsList(FrozenList m) { + super(m); + } + } + + public class Items1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -23,11 +29,14 @@ public class Items1 implements JsonSchema { component's name collides with the inner schema name */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items2.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items2.class; + protected static ItemsList getListOutputInstance(FrozenList arg) { + return new ItemsList(arg); + } + public static ItemsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Items1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequest.java index d3f7b85936b..3c4e0d8d705 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequest.java @@ -7,15 +7,15 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class JSONPatchRequest { // nest classes so all schemas and input/output classes can be public - public class Items implements JsonSchema { + public class Items extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Items.class, arg, configuration); } @@ -65,18 +65,27 @@ public static U validate(List arg, SchemaConfigur } } - public class JSONPatchRequest1 implements JsonSchema { + public static class JSONPatchRequestList extends FrozenList { + JSONPatchRequestList(FrozenList m) { + super(m); + } + } + + public class JSONPatchRequest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static JSONPatchRequestList getListOutputInstance(FrozenList arg) { + return new JSONPatchRequestList(arg); + } + public static JSONPatchRequestList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(JSONPatchRequest1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestAddReplaceTest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestAddReplaceTest.java index 6df66328776..7bcbeaff226 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestAddReplaceTest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestAddReplaceTest.java @@ -6,10 +6,10 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class JSONPatchRequestAddReplaceTest { // nest classes so all schemas and input/output classes can be public @@ -25,8 +25,8 @@ public class Path extends StringJsonSchema {} public class Value extends AnyTypeJsonSchema {} - public class Op implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Op extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -34,28 +34,40 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class JSONPatchRequestAddReplaceTest1 implements JsonSchema { + public static class JSONPatchRequestAddReplaceTestMap extends FrozenMap { + JSONPatchRequestAddReplaceTestMap(FrozenMap m) { + super(m); + } + public static JSONPatchRequestAddReplaceTestMap of(Map arg, SchemaConfiguration configuration) { + return JSONPatchRequestAddReplaceTest1.validate(arg, configuration); + } + } + + public class JSONPatchRequestAddReplaceTest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("path", Path.class), new AbstractMap.SimpleEntry>("value", Value.class), new AbstractMap.SimpleEntry>("op", Op.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "op", "path", "value" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static JSONPatchRequestAddReplaceTestMap getMapOutputInstance(FrozenMap arg) { + return new JSONPatchRequestAddReplaceTestMap(arg); + } + public static JSONPatchRequestAddReplaceTestMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(JSONPatchRequestAddReplaceTest1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestMoveCopy.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestMoveCopy.java index 40cbda6b2c3..bffdbdaaa23 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestMoveCopy.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestMoveCopy.java @@ -6,10 +6,10 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class JSONPatchRequestMoveCopy { // nest classes so all schemas and input/output classes can be public @@ -25,8 +25,8 @@ public class From extends StringJsonSchema {} public class Path extends StringJsonSchema {} - public class Op implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Op extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -34,28 +34,40 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class JSONPatchRequestMoveCopy1 implements JsonSchema { + public static class JSONPatchRequestMoveCopyMap extends FrozenMap { + JSONPatchRequestMoveCopyMap(FrozenMap m) { + super(m); + } + public static JSONPatchRequestMoveCopyMap of(Map arg, SchemaConfiguration configuration) { + return JSONPatchRequestMoveCopy1.validate(arg, configuration); + } + } + + public class JSONPatchRequestMoveCopy1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("from", From.class), new AbstractMap.SimpleEntry>("path", Path.class), new AbstractMap.SimpleEntry>("op", Op.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "from", "op", "path" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static JSONPatchRequestMoveCopyMap getMapOutputInstance(FrozenMap arg) { + return new JSONPatchRequestMoveCopyMap(arg); + } + public static JSONPatchRequestMoveCopyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(JSONPatchRequestMoveCopy1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestRemove.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestRemove.java index a2b18af2168..77b16c11fe9 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestRemove.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/JSONPatchRequestRemove.java @@ -6,10 +6,10 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class JSONPatchRequestRemove { // nest classes so all schemas and input/output classes can be public @@ -22,8 +22,8 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} public class Path extends StringJsonSchema {} - public class Op implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Op extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -31,26 +31,38 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class JSONPatchRequestRemove1 implements JsonSchema { + public static class JSONPatchRequestRemoveMap extends FrozenMap { + JSONPatchRequestRemoveMap(FrozenMap m) { + super(m); + } + public static JSONPatchRequestRemoveMap of(Map arg, SchemaConfiguration configuration) { + return JSONPatchRequestRemove1.validate(arg, configuration); + } + } + + public class JSONPatchRequestRemove1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("path", Path.class), new AbstractMap.SimpleEntry>("op", Op.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "op", "path" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static JSONPatchRequestRemoveMap getMapOutputInstance(FrozenMap arg) { + return new JSONPatchRequestRemoveMap(arg); + } + public static JSONPatchRequestRemoveMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(JSONPatchRequestRemove1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Mammal.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Mammal.java index 8f88bc48473..728c29f604f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Mammal.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Mammal.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Mammal { // nest classes so all schemas and input/output classes can be public - public class Mammal1 implements JsonSchema { + public class Mammal1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MapTest.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MapTest.java index bb3bb1627b9..cd881744269 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MapTest.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MapTest.java @@ -6,9 +6,9 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.BooleanJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class MapTest { // nest classes so all schemas and input/output classes can be public @@ -17,30 +17,54 @@ public class MapTest { public class AdditionalProperties1 extends StringJsonSchema {} - public class AdditionalProperties implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class AdditionalPropertiesMap extends FrozenMap { + AdditionalPropertiesMap(FrozenMap m) { + super(m); + } + public static AdditionalPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return AdditionalProperties.validate(arg, configuration); + } + } + + public class AdditionalProperties extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties1.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static AdditionalPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new AdditionalPropertiesMap(arg); + } + public static AdditionalPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(AdditionalProperties.class, arg, configuration); } } - public class MapMapOfString implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapMapOfStringMap extends FrozenMap { + MapMapOfStringMap(FrozenMap m) { + super(m); + } + public static MapMapOfStringMap of(Map arg, SchemaConfiguration configuration) { + return MapMapOfString.validate(arg, configuration); + } + } + + public class MapMapOfString extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapMapOfStringMap getMapOutputInstance(FrozenMap arg) { + return new MapMapOfStringMap(arg); + } + public static MapMapOfStringMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapMapOfString.class, arg, configuration); } } - public class AdditionalProperties2 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class AdditionalProperties2 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -48,12 +72,24 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class MapOfEnumString implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapOfEnumStringMap extends FrozenMap { + MapOfEnumStringMap(FrozenMap m) { + super(m); + } + public static MapOfEnumStringMap of(Map arg, SchemaConfiguration configuration) { + return MapOfEnumString.validate(arg, configuration); + } + } + + public class MapOfEnumString extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties2.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapOfEnumStringMap getMapOutputInstance(FrozenMap arg) { + return new MapOfEnumStringMap(arg); + } + public static MapOfEnumStringMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapOfEnumString.class, arg, configuration); } } @@ -62,34 +98,58 @@ public static T validate(Map arg, SchemaCo public class AdditionalProperties3 extends BooleanJsonSchema {} - public class DirectMap implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class DirectMapMap extends FrozenMap { + DirectMapMap(FrozenMap m) { + super(m); + } + public static DirectMapMap of(Map arg, SchemaConfiguration configuration) { + return DirectMap.validate(arg, configuration); + } + } + + public class DirectMap extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties3.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static DirectMapMap getMapOutputInstance(FrozenMap arg) { + return new DirectMapMap(arg); + } + public static DirectMapMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(DirectMap.class, arg, configuration); } } - public class MapTest1 implements JsonSchema { + public static class MapTestMap extends FrozenMap { + MapTestMap(FrozenMap m) { + super(m); + } + public static MapTestMap of(Map arg, SchemaConfiguration configuration) { + return MapTest1.validate(arg, configuration); + } + } + + public class MapTest1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("map_map_of_string", MapMapOfString.class), new AbstractMap.SimpleEntry>("map_of_enum_string", MapOfEnumString.class), new AbstractMap.SimpleEntry>("direct_map", DirectMap.class), new AbstractMap.SimpleEntry>("indirect_map", StringBooleanMap.StringBooleanMap1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapTestMap getMapOutputInstance(FrozenMap arg) { + return new MapTestMap(arg); + } + public static MapTestMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapTest1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MixedPropertiesAndAdditionalPropertiesClass.java index adf7cc3eef8..f2181192dc6 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MixedPropertiesAndAdditionalPropertiesClass.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MixedPropertiesAndAdditionalPropertiesClass.java @@ -6,9 +6,9 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.DateTimeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.UuidJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class MixedPropertiesAndAdditionalPropertiesClass { // nest classes so all schemas and input/output classes can be public @@ -20,33 +20,57 @@ public class UuidSchema extends UuidJsonSchema {} public class DateTime extends DateTimeJsonSchema {} - public class MapSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class MapMap extends FrozenMap { + MapMap(FrozenMap m) { + super(m); + } + public static MapMap of(Map arg, SchemaConfiguration configuration) { + return MapSchema.validate(arg, configuration); + } + } + + public class MapSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = Animal.Animal1.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MapMap getMapOutputInstance(FrozenMap arg) { + return new MapMap(arg); + } + public static MapMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MapSchema.class, arg, configuration); } } - public class MixedPropertiesAndAdditionalPropertiesClass1 implements JsonSchema { + public static class MixedPropertiesAndAdditionalPropertiesClassMap extends FrozenMap { + MixedPropertiesAndAdditionalPropertiesClassMap(FrozenMap m) { + super(m); + } + public static MixedPropertiesAndAdditionalPropertiesClassMap of(Map arg, SchemaConfiguration configuration) { + return MixedPropertiesAndAdditionalPropertiesClass1.validate(arg, configuration); + } + } + + public class MixedPropertiesAndAdditionalPropertiesClass1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("uuid", UuidSchema.class), new AbstractMap.SimpleEntry>("dateTime", DateTime.class), new AbstractMap.SimpleEntry>("map", MapSchema.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MixedPropertiesAndAdditionalPropertiesClassMap getMapOutputInstance(FrozenMap arg) { + return new MixedPropertiesAndAdditionalPropertiesClassMap(arg); + } + public static MixedPropertiesAndAdditionalPropertiesClassMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MixedPropertiesAndAdditionalPropertiesClass1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Money.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Money.java index 6a02b403685..d3275f673fd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Money.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Money.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; import org.openapijsonschematools.schemas.DecimalJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Money { // nest classes so all schemas and input/output classes can be public @@ -22,26 +22,38 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} public class Amount extends DecimalJsonSchema {} - public class Money1 implements JsonSchema { + public static class MoneyMap extends FrozenMap { + MoneyMap(FrozenMap m) { + super(m); + } + public static MoneyMap of(Map arg, SchemaConfiguration configuration) { + return Money1.validate(arg, configuration); + } + } + + public class Money1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("amount", Amount.class), new AbstractMap.SimpleEntry>("currency", Currency.Currency1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "amount", "currency" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MoneyMap getMapOutputInstance(FrozenMap arg) { + return new MoneyMap(arg); + } + public static MoneyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Money1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MyObjectDto.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MyObjectDto.java index 4498883dae7..e3380da6c9f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MyObjectDto.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/MyObjectDto.java @@ -6,10 +6,10 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.UuidJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class MyObjectDto { // nest classes so all schemas and input/output classes can be public @@ -22,21 +22,33 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} public class Id extends UuidJsonSchema {} - public class MyObjectDto1 implements JsonSchema { + public static class MyObjectDtoMap extends FrozenMap { + MyObjectDtoMap(FrozenMap m) { + super(m); + } + public static MyObjectDtoMap of(Map arg, SchemaConfiguration configuration) { + return MyObjectDto1.validate(arg, configuration); + } + } + + public class MyObjectDto1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static MyObjectDtoMap getMapOutputInstance(FrozenMap arg) { + return new MyObjectDtoMap(arg); + } + public static MyObjectDtoMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(MyObjectDto1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Name.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Name.java index a30306f0f39..a330db19a2d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Name.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Name.java @@ -9,11 +9,11 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Name { // nest classes so all schemas and input/output classes can be public @@ -28,7 +28,16 @@ public class SnakeCase extends Int32JsonSchema {} public class Property extends StringJsonSchema {} - public class Name1 implements JsonSchema { + public static class NameMap extends FrozenMap { + NameMap(FrozenMap m) { + super(m); + } + public static NameMap of(Map arg, SchemaConfiguration configuration) { + return Name1.validate(arg, configuration); + } + } + + public class Name1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -37,12 +46,12 @@ public class Name1 implements JsonSchema { Model for testing model name same as property name */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("name", Name2.class), new AbstractMap.SimpleEntry>("snake_case", SnakeCase.class), new AbstractMap.SimpleEntry>("property", Property.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "name" )); public static Void validate(Void arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NoAdditionalProperties.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NoAdditionalProperties.java index 329af335ce6..111569773fa 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NoAdditionalProperties.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NoAdditionalProperties.java @@ -6,10 +6,10 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NoAdditionalProperties { // nest classes so all schemas and input/output classes can be public @@ -25,25 +25,37 @@ public class Id extends Int64JsonSchema {} public class PetId extends Int64JsonSchema {} - public class NoAdditionalProperties1 implements JsonSchema { + public static class NoAdditionalPropertiesMap extends FrozenMap { + NoAdditionalPropertiesMap(FrozenMap m) { + super(m); + } + public static NoAdditionalPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return NoAdditionalProperties1.validate(arg, configuration); + } + } + + public class NoAdditionalProperties1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class), new AbstractMap.SimpleEntry>("petId", PetId.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "id" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static NoAdditionalPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new NoAdditionalPropertiesMap(arg); + } + public static NoAdditionalPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(NoAdditionalProperties1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableClass.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableClass.java index 924dd8fa7b2..7554fe68531 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableClass.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableClass.java @@ -8,17 +8,17 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.MapJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NullableClass { // nest classes so all schemas and input/output classes can be public - public class AdditionalProperties3 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class AdditionalProperties3 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -30,8 +30,8 @@ public static T validate(Map arg, SchemaCo } } - public class IntegerProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class IntegerProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, Integer.class, Long.class, @@ -58,8 +58,8 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { } } - public class NumberProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class NumberProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, Integer.class, Long.class, @@ -86,8 +86,8 @@ public static Number validate(Double arg, SchemaConfiguration configuration) { } } - public class BooleanProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class BooleanProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, Boolean.class )); @@ -99,8 +99,8 @@ public static Boolean validate(Boolean arg, SchemaConfiguration configuration) { } } - public class StringProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class StringProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, String.class )); @@ -112,12 +112,12 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class DateProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class DateProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, String.class )); - static final String format = "date"; + public static final String format = "date"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(DateProp.class, arg, configuration); } @@ -126,12 +126,12 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class DatetimeProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class DatetimeProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, String.class )); - static final String format = "date-time"; + public static final String format = "date-time"; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(DatetimeProp.class, arg, configuration); } @@ -143,22 +143,28 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class Items extends MapJsonSchema {} - public class ArrayNullableProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayNullablePropList extends FrozenList { + ArrayNullablePropList(FrozenList m) { + super(m); + } + } + + public class ArrayNullableProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenList.class )); - static final Class items = Items.class; + public static final Class items = Items.class; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayNullableProp.class, arg, configuration); } - public static U validate(List arg, SchemaConfiguration configuration) { + public static ArrayNullablePropList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayNullableProp.class, arg, configuration); } } - public class Items1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -170,22 +176,28 @@ public static T validate(Map arg, SchemaCo } } - public class ArrayAndItemsNullableProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayAndItemsNullablePropList extends FrozenList { + ArrayAndItemsNullablePropList(FrozenList m) { + super(m); + } + } + + public class ArrayAndItemsNullableProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenList.class )); - static final Class items = Items1.class; + public static final Class items = Items1.class; public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayAndItemsNullableProp.class, arg, configuration); } - public static U validate(List arg, SchemaConfiguration configuration) { + public static ArrayAndItemsNullablePropList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayAndItemsNullableProp.class, arg, configuration); } } - public class Items2 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items2 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -197,12 +209,21 @@ public static T validate(Map arg, SchemaCo } } - public class ArrayItemsNullable implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ArrayItemsNullableList extends FrozenList { + ArrayItemsNullableList(FrozenList m) { + super(m); + } + } + + public class ArrayItemsNullable extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items2.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items2.class; + protected static ArrayItemsNullableList getListOutputInstance(FrozenList arg) { + return new ArrayItemsNullableList(arg); + } + public static ArrayItemsNullableList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(ArrayItemsNullable.class, arg, configuration); } } @@ -210,8 +231,17 @@ public static U validate(List arg, SchemaConfigur public class AdditionalProperties extends MapJsonSchema {} - public class ObjectNullableProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ObjectNullablePropMap extends FrozenMap { + ObjectNullablePropMap(FrozenMap m) { + super(m); + } + public static ObjectNullablePropMap of(Map arg, SchemaConfiguration configuration) { + return ObjectNullableProp.validate(arg, configuration); + } + } + + public class ObjectNullableProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -219,13 +249,13 @@ public class ObjectNullableProp implements JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectNullableProp.class, arg, configuration); } - public static T validate(Map arg, SchemaConfiguration configuration) { + public static ObjectNullablePropMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectNullableProp.class, arg, configuration); } } - public class AdditionalProperties1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class AdditionalProperties1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -237,8 +267,17 @@ public static T validate(Map arg, SchemaCo } } - public class ObjectAndItemsNullableProp implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ObjectAndItemsNullablePropMap extends FrozenMap { + ObjectAndItemsNullablePropMap(FrozenMap m) { + super(m); + } + public static ObjectAndItemsNullablePropMap of(Map arg, SchemaConfiguration configuration) { + return ObjectAndItemsNullableProp.validate(arg, configuration); + } + } + + public class ObjectAndItemsNullableProp extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -246,13 +285,13 @@ public class ObjectAndItemsNullableProp implements JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectAndItemsNullableProp.class, arg, configuration); } - public static T validate(Map arg, SchemaConfiguration configuration) { + public static ObjectAndItemsNullablePropMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectAndItemsNullableProp.class, arg, configuration); } } - public class AdditionalProperties2 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class AdditionalProperties2 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -264,28 +303,49 @@ public static T validate(Map arg, SchemaCo } } - public class ObjectItemsNullable implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ObjectItemsNullableMap extends FrozenMap { + ObjectItemsNullableMap(FrozenMap m) { + super(m); + } + public static ObjectItemsNullableMap of(Map arg, SchemaConfiguration configuration) { + return ObjectItemsNullable.validate(arg, configuration); + } + } + + public class ObjectItemsNullable extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties2.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectItemsNullableMap getMapOutputInstance(FrozenMap arg) { + return new ObjectItemsNullableMap(arg); + } + public static ObjectItemsNullableMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectItemsNullable.class, arg, configuration); } } - public class NullableClass1 implements JsonSchema { + public static class NullableClassMap extends FrozenMap { + NullableClassMap(FrozenMap m) { + super(m); + } + public static NullableClassMap of(Map arg, SchemaConfiguration configuration) { + return NullableClass1.validate(arg, configuration); + } + } + + public class NullableClass1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("integer_prop", IntegerProp.class), new AbstractMap.SimpleEntry>("number_prop", NumberProp.class), new AbstractMap.SimpleEntry>("boolean_prop", BooleanProp.class), @@ -300,7 +360,10 @@ public class NullableClass1 implements JsonSchema { new AbstractMap.SimpleEntry>("object_items_nullable", ObjectItemsNullable.class) )); static final Class additionalProperties = AdditionalProperties3.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static NullableClassMap getMapOutputInstance(FrozenMap arg) { + return new NullableClassMap(arg); + } + public static NullableClassMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(NullableClass1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableShape.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableShape.java index 05145a3ba11..f10d5762f5b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableShape.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableShape.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NullableShape { // nest classes so all schemas and input/output classes can be public @@ -17,7 +17,7 @@ public class NullableShape { public class Schema2 extends NullJsonSchema {} - public class NullableShape1 implements JsonSchema { + public class NullableShape1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableString.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableString.java index 6aed26f1913..d62aad6ecd4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableString.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NullableString.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NullableString { // nest classes so all schemas and input/output classes can be public - public class NullableString1 implements JsonSchema { + public class NullableString1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, String.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberOnly.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberOnly.java index 101ae9d01b1..864e6b76cec 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberOnly.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberOnly.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NumberOnly { // nest classes so all schemas and input/output classes can be public @@ -16,20 +16,32 @@ public class NumberOnly { public class JustNumber extends NumberJsonSchema {} - public class NumberOnly1 implements JsonSchema { + public static class NumberOnlyMap extends FrozenMap { + NumberOnlyMap(FrozenMap m) { + super(m); + } + public static NumberOnlyMap of(Map arg, SchemaConfiguration configuration) { + return NumberOnly1.validate(arg, configuration); + } + } + + public class NumberOnly1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("JustNumber", JustNumber.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static NumberOnlyMap getMapOutputInstance(FrozenMap arg) { + return new NumberOnlyMap(arg); + } + public static NumberOnlyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(NumberOnly1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberWithValidations.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberWithValidations.java index c287285df68..a3e0a2fb7d3 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberWithValidations.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/NumberWithValidations.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NumberWithValidations { // nest classes so all schemas and input/output classes can be public - public class NumberWithValidations1 implements JsonSchema { + public class NumberWithValidations1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredProps.java index ea16ff3fc2b..866cb69b5a6 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredProps.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjWithRequiredProps { // nest classes so all schemas and input/output classes can be public @@ -16,23 +16,35 @@ public class ObjWithRequiredProps { public class A extends StringJsonSchema {} - public class ObjWithRequiredProps1 implements JsonSchema { + public static class ObjWithRequiredPropsMap extends FrozenMap { + ObjWithRequiredPropsMap(FrozenMap m) { + super(m); + } + public static ObjWithRequiredPropsMap of(Map arg, SchemaConfiguration configuration) { + return ObjWithRequiredProps1.validate(arg, configuration); + } + } + + public class ObjWithRequiredProps1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("a", A.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "a" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjWithRequiredPropsMap getMapOutputInstance(FrozenMap arg) { + return new ObjWithRequiredPropsMap(arg); + } + public static ObjWithRequiredPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjWithRequiredProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredPropsBase.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredPropsBase.java index 78a1efc8162..8a37e8f19bc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredPropsBase.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjWithRequiredPropsBase.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjWithRequiredPropsBase { // nest classes so all schemas and input/output classes can be public @@ -16,23 +16,35 @@ public class ObjWithRequiredPropsBase { public class B extends StringJsonSchema {} - public class ObjWithRequiredPropsBase1 implements JsonSchema { + public static class ObjWithRequiredPropsBaseMap extends FrozenMap { + ObjWithRequiredPropsBaseMap(FrozenMap m) { + super(m); + } + public static ObjWithRequiredPropsBaseMap of(Map arg, SchemaConfiguration configuration) { + return ObjWithRequiredPropsBase1.validate(arg, configuration); + } + } + + public class ObjWithRequiredPropsBase1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("b", B.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "b" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjWithRequiredPropsBaseMap getMapOutputInstance(FrozenMap arg) { + return new ObjWithRequiredPropsBaseMap(arg); + } + public static ObjWithRequiredPropsBaseMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjWithRequiredPropsBase1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithArgAndArgsProperties.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithArgAndArgsProperties.java index 1f708ef7f00..eabc1aef43c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithArgAndArgsProperties.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithArgAndArgsProperties.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectModelWithArgAndArgsProperties { // nest classes so all schemas and input/output classes can be public @@ -19,25 +19,37 @@ public class Arg extends StringJsonSchema {} public class Args extends StringJsonSchema {} - public class ObjectModelWithArgAndArgsProperties1 implements JsonSchema { + public static class ObjectModelWithArgAndArgsPropertiesMap extends FrozenMap { + ObjectModelWithArgAndArgsPropertiesMap(FrozenMap m) { + super(m); + } + public static ObjectModelWithArgAndArgsPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return ObjectModelWithArgAndArgsProperties1.validate(arg, configuration); + } + } + + public class ObjectModelWithArgAndArgsProperties1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("arg", Arg.class), new AbstractMap.SimpleEntry>("args", Args.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "arg", "args" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectModelWithArgAndArgsPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new ObjectModelWithArgAndArgsPropertiesMap(arg); + } + public static ObjectModelWithArgAndArgsPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectModelWithArgAndArgsProperties1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithRefProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithRefProps.java index af84b7940c5..3d3ed4d6922 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithRefProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectModelWithRefProps.java @@ -5,14 +5,23 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectModelWithRefProps { // nest classes so all schemas and input/output classes can be public - public class ObjectModelWithRefProps1 implements JsonSchema { + public static class ObjectModelWithRefPropsMap extends FrozenMap { + ObjectModelWithRefPropsMap(FrozenMap m) { + super(m); + } + public static ObjectModelWithRefPropsMap of(Map arg, SchemaConfiguration configuration) { + return ObjectModelWithRefProps1.validate(arg, configuration); + } + } + + public class ObjectModelWithRefProps1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -21,15 +30,18 @@ public class ObjectModelWithRefProps1 implements JsonSchema { a model that includes properties which should stay primitive (String + Boolean) and one which is defined as a class, NumberWithValidations */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("myNumber", NumberWithValidations.NumberWithValidations1.class), new AbstractMap.SimpleEntry>("myString", StringSchema.StringSchema1.class), new AbstractMap.SimpleEntry>("myBoolean", BooleanSchema.BooleanSchema1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectModelWithRefPropsMap getMapOutputInstance(FrozenMap arg) { + return new ObjectModelWithRefPropsMap(arg); + } + public static ObjectModelWithRefPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectModelWithRefProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithAllOfWithReqTestPropFromUnsetAddProp.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithAllOfWithReqTestPropFromUnsetAddProp.java index cab27320471..533d2520af1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithAllOfWithReqTestPropFromUnsetAddProp.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithAllOfWithReqTestPropFromUnsetAddProp.java @@ -9,10 +9,10 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithAllOfWithReqTestPropFromUnsetAddProp { // nest classes so all schemas and input/output classes can be public @@ -21,23 +21,35 @@ public class ObjectWithAllOfWithReqTestPropFromUnsetAddProp { public class Name extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("name", Name.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "test" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class ObjectWithAllOfWithReqTestPropFromUnsetAddProp1 implements JsonSchema { + public class ObjectWithAllOfWithReqTestPropFromUnsetAddProp1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithCollidingProperties.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithCollidingProperties.java index 922c4df4091..b3b4973d788 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithCollidingProperties.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithCollidingProperties.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.MapJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithCollidingProperties { // nest classes so all schemas and input/output classes can be public @@ -19,7 +19,16 @@ public class SomeProp extends MapJsonSchema {} public class Someprop extends MapJsonSchema {} - public class ObjectWithCollidingProperties1 implements JsonSchema { + public static class ObjectWithCollidingPropertiesMap extends FrozenMap { + ObjectWithCollidingPropertiesMap(FrozenMap m) { + super(m); + } + public static ObjectWithCollidingPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithCollidingProperties1.validate(arg, configuration); + } + } + + public class ObjectWithCollidingProperties1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -28,14 +37,17 @@ public class ObjectWithCollidingProperties1 implements JsonSchema { component with properties that have name collisions */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someProp", SomeProp.class), new AbstractMap.SimpleEntry>("someprop", Someprop.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithCollidingPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithCollidingPropertiesMap(arg); + } + public static ObjectWithCollidingPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithCollidingProperties1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDecimalProperties.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDecimalProperties.java index 9a93356bc88..a243ae17848 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDecimalProperties.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDecimalProperties.java @@ -6,8 +6,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.DecimalJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithDecimalProperties { // nest classes so all schemas and input/output classes can be public @@ -16,22 +16,34 @@ public class ObjectWithDecimalProperties { public class Width extends DecimalJsonSchema {} - public class ObjectWithDecimalProperties1 implements JsonSchema { + public static class ObjectWithDecimalPropertiesMap extends FrozenMap { + ObjectWithDecimalPropertiesMap(FrozenMap m) { + super(m); + } + public static ObjectWithDecimalPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithDecimalProperties1.validate(arg, configuration); + } + } + + public class ObjectWithDecimalProperties1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("length", DecimalPayload.DecimalPayload1.class), new AbstractMap.SimpleEntry>("width", Width.class), new AbstractMap.SimpleEntry>("cost", Money.Money1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithDecimalPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithDecimalPropertiesMap(arg); + } + public static ObjectWithDecimalPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithDecimalProperties1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDifficultlyNamedProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDifficultlyNamedProps.java index 96e5065218b..f3b057bd14f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDifficultlyNamedProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithDifficultlyNamedProps.java @@ -5,11 +5,11 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; import org.openapijsonschematools.schemas.IntJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithDifficultlyNamedProps { // nest classes so all schemas and input/output classes can be public @@ -24,7 +24,16 @@ public class Schema123list extends StringJsonSchema {} public class Schema123Number extends IntJsonSchema {} - public class ObjectWithDifficultlyNamedProps1 implements JsonSchema { + public static class ObjectWithDifficultlyNamedPropsMap extends FrozenMap { + ObjectWithDifficultlyNamedPropsMap(FrozenMap m) { + super(m); + } + public static ObjectWithDifficultlyNamedPropsMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithDifficultlyNamedProps1.validate(arg, configuration); + } + } + + public class ObjectWithDifficultlyNamedProps1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -33,18 +42,21 @@ public class ObjectWithDifficultlyNamedProps1 implements JsonSchema { model with properties that have invalid names for python */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("$special[property.name]", Specialpropertyname.class), new AbstractMap.SimpleEntry>("123-list", Schema123list.class), new AbstractMap.SimpleEntry>("123Number", Schema123Number.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "123-list" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithDifficultlyNamedPropsMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithDifficultlyNamedPropsMap(arg); + } + public static ObjectWithDifficultlyNamedPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithDifficultlyNamedProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInlineCompositionProperty.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInlineCompositionProperty.java index 836e38a2a6b..8643d7d053d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInlineCompositionProperty.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInlineCompositionProperty.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithInlineCompositionProperty { // nest classes so all schemas and input/output classes can be public - public class Schema0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,7 +26,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class SomeProp implements JsonSchema { + public class SomeProp extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(SomeProp.class, arg, configuration); } @@ -76,20 +76,32 @@ public static U validate(List arg, SchemaConfigur } } - public class ObjectWithInlineCompositionProperty1 implements JsonSchema { + public static class ObjectWithInlineCompositionPropertyMap extends FrozenMap { + ObjectWithInlineCompositionPropertyMap(FrozenMap m) { + super(m); + } + public static ObjectWithInlineCompositionPropertyMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithInlineCompositionProperty1.validate(arg, configuration); + } + } + + public class ObjectWithInlineCompositionProperty1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someProp", SomeProp.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithInlineCompositionPropertyMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithInlineCompositionPropertyMap(arg); + } + public static ObjectWithInlineCompositionPropertyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithInlineCompositionProperty1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInvalidNamedRefedProperties.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInvalidNamedRefedProperties.java index a13163684f6..7813706d367 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInvalidNamedRefedProperties.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithInvalidNamedRefedProperties.java @@ -5,32 +5,44 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithInvalidNamedRefedProperties { // nest classes so all schemas and input/output classes can be public - public class ObjectWithInvalidNamedRefedProperties1 implements JsonSchema { + public static class ObjectWithInvalidNamedRefedPropertiesMap extends FrozenMap { + ObjectWithInvalidNamedRefedPropertiesMap(FrozenMap m) { + super(m); + } + public static ObjectWithInvalidNamedRefedPropertiesMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithInvalidNamedRefedProperties1.validate(arg, configuration); + } + } + + public class ObjectWithInvalidNamedRefedProperties1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("from", FromSchema.FromSchema1.class), new AbstractMap.SimpleEntry>("!reference", ArrayWithValidationsInItems.ArrayWithValidationsInItems1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "!reference", "from" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithInvalidNamedRefedPropertiesMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithInvalidNamedRefedPropertiesMap(arg); + } + public static ObjectWithInvalidNamedRefedPropertiesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithInvalidNamedRefedProperties1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithNonIntersectingValues.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithNonIntersectingValues.java index b1570b23182..ef89e546da6 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithNonIntersectingValues.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithNonIntersectingValues.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithNonIntersectingValues { // nest classes so all schemas and input/output classes can be public @@ -20,21 +20,33 @@ public class AdditionalProperties extends StringJsonSchema {} public class A extends NumberJsonSchema {} - public class ObjectWithNonIntersectingValues1 implements JsonSchema { + public static class ObjectWithNonIntersectingValuesMap extends FrozenMap { + ObjectWithNonIntersectingValuesMap(FrozenMap m) { + super(m); + } + public static ObjectWithNonIntersectingValuesMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithNonIntersectingValues1.validate(arg, configuration); + } + } + + public class ObjectWithNonIntersectingValues1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("a", A.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithNonIntersectingValuesMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithNonIntersectingValuesMap(arg); + } + public static ObjectWithNonIntersectingValuesMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithNonIntersectingValues1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOnlyOptionalProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOnlyOptionalProps.java index 40c4a10a69f..0d1b701a39d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOnlyOptionalProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOnlyOptionalProps.java @@ -6,11 +6,11 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; import org.openapijsonschematools.schemas.NumberJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithOnlyOptionalProps { // nest classes so all schemas and input/output classes can be public @@ -26,22 +26,34 @@ public class A extends StringJsonSchema {} public class B extends NumberJsonSchema {} - public class ObjectWithOnlyOptionalProps1 implements JsonSchema { + public static class ObjectWithOnlyOptionalPropsMap extends FrozenMap { + ObjectWithOnlyOptionalPropsMap(FrozenMap m) { + super(m); + } + public static ObjectWithOnlyOptionalPropsMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithOnlyOptionalProps1.validate(arg, configuration); + } + } + + public class ObjectWithOnlyOptionalProps1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("a", A.class), new AbstractMap.SimpleEntry>("b", B.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithOnlyOptionalPropsMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithOnlyOptionalPropsMap(arg); + } + public static ObjectWithOnlyOptionalPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithOnlyOptionalProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOptionalTestProp.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOptionalTestProp.java index d032568e2dc..b9b7faca701 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOptionalTestProp.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithOptionalTestProp.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithOptionalTestProp { // nest classes so all schemas and input/output classes can be public @@ -16,20 +16,32 @@ public class ObjectWithOptionalTestProp { public class Test extends StringJsonSchema {} - public class ObjectWithOptionalTestProp1 implements JsonSchema { + public static class ObjectWithOptionalTestPropMap extends FrozenMap { + ObjectWithOptionalTestPropMap(FrozenMap m) { + super(m); + } + public static ObjectWithOptionalTestPropMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithOptionalTestProp1.validate(arg, configuration); + } + } + + public class ObjectWithOptionalTestProp1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("test", Test.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ObjectWithOptionalTestPropMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithOptionalTestPropMap(arg); + } + public static ObjectWithOptionalTestPropMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ObjectWithOptionalTestProp1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithValidations.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithValidations.java index 8669c0c4799..5e2b5ddc83e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithValidations.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ObjectWithValidations.java @@ -3,21 +3,21 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ObjectWithValidations { // nest classes so all schemas and input/output classes can be public - public class ObjectWithValidations1 implements JsonSchema { + public class ObjectWithValidations1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); public static T validate(Map arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Order.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Order.java index 41ca6803481..98fe5eaffe1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Order.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Order.java @@ -7,10 +7,10 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.BooleanJsonSchema; import org.openapijsonschematools.schemas.DateTimeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Order { // nest classes so all schemas and input/output classes can be public @@ -28,8 +28,8 @@ public class Quantity extends Int32JsonSchema {} public class ShipDate extends DateTimeJsonSchema {} - public class Status implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Status extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -40,17 +40,26 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class Complete extends BooleanJsonSchema {} - public class Order1 implements JsonSchema { + public static class OrderMap extends FrozenMap { + OrderMap(FrozenMap m) { + super(m); + } + public static OrderMap of(Map arg, SchemaConfiguration configuration) { + return Order1.validate(arg, configuration); + } + } + + public class Order1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class), new AbstractMap.SimpleEntry>("petId", PetId.class), new AbstractMap.SimpleEntry>("quantity", Quantity.class), @@ -58,7 +67,10 @@ public class Order1 implements JsonSchema { new AbstractMap.SimpleEntry>("status", Status.class), new AbstractMap.SimpleEntry>("complete", Complete.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static OrderMap getMapOutputInstance(FrozenMap arg) { + return new OrderMap(arg); + } + public static OrderMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Order1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PaginatedResultMyObjectDto.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PaginatedResultMyObjectDto.java index 6707fa00ae7..e818adc0f8a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PaginatedResultMyObjectDto.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PaginatedResultMyObjectDto.java @@ -7,11 +7,11 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.IntJsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PaginatedResultMyObjectDto { // nest classes so all schemas and input/output classes can be public @@ -24,36 +24,57 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} public class Count extends IntJsonSchema {} - public class Results implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class ResultsList extends FrozenList { + ResultsList(FrozenList m) { + super(m); + } + } + + public class Results extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = MyObjectDto.MyObjectDto1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = MyObjectDto.MyObjectDto1.class; + protected static ResultsList getListOutputInstance(FrozenList arg) { + return new ResultsList(arg); + } + public static ResultsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Results.class, arg, configuration); } } - public class PaginatedResultMyObjectDto1 implements JsonSchema { + public static class PaginatedResultMyObjectDtoMap extends FrozenMap { + PaginatedResultMyObjectDtoMap(FrozenMap m) { + super(m); + } + public static PaginatedResultMyObjectDtoMap of(Map arg, SchemaConfiguration configuration) { + return PaginatedResultMyObjectDto1.validate(arg, configuration); + } + } + + public class PaginatedResultMyObjectDto1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("count", Count.class), new AbstractMap.SimpleEntry>("results", Results.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "count", "results" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PaginatedResultMyObjectDtoMap getMapOutputInstance(FrozenMap arg) { + return new PaginatedResultMyObjectDtoMap(arg); + } + public static PaginatedResultMyObjectDtoMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PaginatedResultMyObjectDto1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ParentPet.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ParentPet.java index b345bf33bc0..4fb1ac72e21 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ParentPet.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ParentPet.java @@ -3,21 +3,21 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ParentPet { // nest classes so all schemas and input/output classes can be public - public class ParentPet1 implements JsonSchema { + public class ParentPet1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); public static T validate(Map arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pet.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pet.java index fc99725ce02..5e3139277e6 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pet.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pet.java @@ -6,11 +6,11 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Pet { // nest classes so all schemas and input/output classes can be public @@ -25,18 +25,27 @@ public class Name extends StringJsonSchema {} public class Items extends StringJsonSchema {} - public class PhotoUrls implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PhotoUrlsList extends FrozenList { + PhotoUrlsList(FrozenList m) { + super(m); + } + } + + public class PhotoUrls extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static PhotoUrlsList getListOutputInstance(FrozenList arg) { + return new PhotoUrlsList(arg); + } + public static PhotoUrlsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(PhotoUrls.class, arg, configuration); } } - public class Status implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Status extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -44,17 +53,35 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Tags implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class TagsList extends FrozenList { + TagsList(FrozenList m) { + super(m); + } + } + + public class Tags extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Tag.Tag1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Tag.Tag1.class; + protected static TagsList getListOutputInstance(FrozenList arg) { + return new TagsList(arg); + } + public static TagsList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Tags.class, arg, configuration); } } - public class Pet1 implements JsonSchema { + public static class PetMap extends FrozenMap { + PetMap(FrozenMap m) { + super(m); + } + public static PetMap of(Map arg, SchemaConfiguration configuration) { + return Pet1.validate(arg, configuration); + } + } + + public class Pet1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -63,10 +90,10 @@ public class Pet1 implements JsonSchema { Pet object that needs to be added to the store */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class), new AbstractMap.SimpleEntry>("category", Category.Category1.class), new AbstractMap.SimpleEntry>("name", Name.class), @@ -74,11 +101,14 @@ public class Pet1 implements JsonSchema { new AbstractMap.SimpleEntry>("tags", Tags.class), new AbstractMap.SimpleEntry>("status", Status.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "name", "photoUrls" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PetMap getMapOutputInstance(FrozenMap arg) { + return new PetMap(arg); + } + public static PetMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Pet1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pig.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pig.java index 039a94e9abc..d321bf4b5d2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pig.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Pig.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Pig { // nest classes so all schemas and input/output classes can be public - public class Pig1 implements JsonSchema { + public class Pig1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Player.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Player.java index 3830a6aee00..8ff1a4fbbb9 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Player.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Player.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Player { // nest classes so all schemas and input/output classes can be public @@ -16,7 +16,16 @@ public class Player { public class Name extends StringJsonSchema {} - public class Player1 implements JsonSchema { + public static class PlayerMap extends FrozenMap { + PlayerMap(FrozenMap m) { + super(m); + } + public static PlayerMap of(Map arg, SchemaConfiguration configuration) { + return Player1.validate(arg, configuration); + } + } + + public class Player1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -25,14 +34,17 @@ public class Player1 implements JsonSchema { a model that includes a self reference this forces properties and additionalProperties to be lazy loaded in python models because the Player class has not fully loaded when defining properties */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("name", Name.class), new AbstractMap.SimpleEntry>("enemyPlayer", Player1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PlayerMap getMapOutputInstance(FrozenMap arg) { + return new PlayerMap(arg); + } + public static PlayerMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Player1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PublicKey.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PublicKey.java index 45aad4b518b..5e18209db87 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PublicKey.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/PublicKey.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PublicKey { // nest classes so all schemas and input/output classes can be public @@ -16,7 +16,16 @@ public class PublicKey { public class Key extends StringJsonSchema {} - public class PublicKey1 implements JsonSchema { + public static class PublicKeyMap extends FrozenMap { + PublicKeyMap(FrozenMap m) { + super(m); + } + public static PublicKeyMap of(Map arg, SchemaConfiguration configuration) { + return PublicKey1.validate(arg, configuration); + } + } + + public class PublicKey1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -25,13 +34,16 @@ public class PublicKey1 implements JsonSchema { schema that contains a property named key */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("key", Key.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PublicKeyMap getMapOutputInstance(FrozenMap arg) { + return new PublicKeyMap(arg); + } + public static PublicKeyMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PublicKey1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Quadrilateral.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Quadrilateral.java index e33a60b2e7c..08be1dc1f4d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Quadrilateral.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Quadrilateral.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Quadrilateral { // nest classes so all schemas and input/output classes can be public - public class Quadrilateral1 implements JsonSchema { + public class Quadrilateral1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/QuadrilateralInterface.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/QuadrilateralInterface.java index b8b2a1de0fc..56a3cbcf713 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/QuadrilateralInterface.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/QuadrilateralInterface.java @@ -9,17 +9,17 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QuadrilateralInterface { // nest classes so all schemas and input/output classes can be public - public class ShapeType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ShapeType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -30,18 +30,27 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class QuadrilateralType extends StringJsonSchema {} - public class QuadrilateralInterface1 implements JsonSchema { + public static class QuadrilateralInterfaceMap extends FrozenMap { + QuadrilateralInterfaceMap(FrozenMap m) { + super(m); + } + public static QuadrilateralInterfaceMap of(Map arg, SchemaConfiguration configuration) { + return QuadrilateralInterface1.validate(arg, configuration); + } + } + + public class QuadrilateralInterface1 extends JsonSchema { /* 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. */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("shapeType", ShapeType.class), new AbstractMap.SimpleEntry>("quadrilateralType", QuadrilateralType.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "quadrilateralType", "shapeType" )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReadOnlyFirst.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReadOnlyFirst.java index 050f1e685bb..e87ece2746a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReadOnlyFirst.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReadOnlyFirst.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ReadOnlyFirst { // nest classes so all schemas and input/output classes can be public @@ -19,21 +19,33 @@ public class Bar extends StringJsonSchema {} public class Baz extends StringJsonSchema {} - public class ReadOnlyFirst1 implements JsonSchema { + public static class ReadOnlyFirstMap extends FrozenMap { + ReadOnlyFirstMap(FrozenMap m) { + super(m); + } + public static ReadOnlyFirstMap of(Map arg, SchemaConfiguration configuration) { + return ReadOnlyFirst1.validate(arg, configuration); + } + } + + public class ReadOnlyFirst1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("bar", Bar.class), new AbstractMap.SimpleEntry>("baz", Baz.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ReadOnlyFirstMap getMapOutputInstance(FrozenMap arg) { + return new ReadOnlyFirstMap(arg); + } + public static ReadOnlyFirstMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ReadOnlyFirst1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromExplicitAddProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromExplicitAddProps.java index 8dad7033375..37f77333ebd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromExplicitAddProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromExplicitAddProps.java @@ -3,9 +3,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ReqPropsFromExplicitAddProps { // nest classes so all schemas and input/output classes can be public @@ -14,22 +14,34 @@ public class ReqPropsFromExplicitAddProps { public class AdditionalProperties extends StringJsonSchema {} - public class ReqPropsFromExplicitAddProps1 implements JsonSchema { + public static class ReqPropsFromExplicitAddPropsMap extends FrozenMap { + ReqPropsFromExplicitAddPropsMap(FrozenMap m) { + super(m); + } + public static ReqPropsFromExplicitAddPropsMap of(Map arg, SchemaConfiguration configuration) { + return ReqPropsFromExplicitAddProps1.validate(arg, configuration); + } + } + + public class ReqPropsFromExplicitAddProps1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "invalid-name", "validName" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ReqPropsFromExplicitAddPropsMap getMapOutputInstance(FrozenMap arg) { + return new ReqPropsFromExplicitAddPropsMap(arg); + } + public static ReqPropsFromExplicitAddPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ReqPropsFromExplicitAddProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromTrueAddProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromTrueAddProps.java index 921c82a5be6..56b01f7eff2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromTrueAddProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromTrueAddProps.java @@ -4,8 +4,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ReqPropsFromTrueAddProps { // nest classes so all schemas and input/output classes can be public @@ -14,22 +14,34 @@ public class ReqPropsFromTrueAddProps { public class AdditionalProperties extends AnyTypeJsonSchema {} - public class ReqPropsFromTrueAddProps1 implements JsonSchema { + public static class ReqPropsFromTrueAddPropsMap extends FrozenMap { + ReqPropsFromTrueAddPropsMap(FrozenMap m) { + super(m); + } + public static ReqPropsFromTrueAddPropsMap of(Map arg, SchemaConfiguration configuration) { + return ReqPropsFromTrueAddProps1.validate(arg, configuration); + } + } + + public class ReqPropsFromTrueAddProps1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "invalid-name", "validName" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ReqPropsFromTrueAddPropsMap getMapOutputInstance(FrozenMap arg) { + return new ReqPropsFromTrueAddPropsMap(arg); + } + public static ReqPropsFromTrueAddPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ReqPropsFromTrueAddProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromUnsetAddProps.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromUnsetAddProps.java index 42c0aa53154..8896076aa75 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromUnsetAddProps.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReqPropsFromUnsetAddProps.java @@ -3,28 +3,40 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ReqPropsFromUnsetAddProps { // nest classes so all schemas and input/output classes can be public - public class ReqPropsFromUnsetAddProps1 implements JsonSchema { + public static class ReqPropsFromUnsetAddPropsMap extends FrozenMap { + ReqPropsFromUnsetAddPropsMap(FrozenMap m) { + super(m); + } + public static ReqPropsFromUnsetAddPropsMap of(Map arg, SchemaConfiguration configuration) { + return ReqPropsFromUnsetAddProps1.validate(arg, configuration); + } + } + + public class ReqPropsFromUnsetAddProps1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "invalid-name", "validName" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ReqPropsFromUnsetAddPropsMap getMapOutputInstance(FrozenMap arg) { + return new ReqPropsFromUnsetAddPropsMap(arg); + } + public static ReqPropsFromUnsetAddPropsMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(ReqPropsFromUnsetAddProps1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReturnSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReturnSchema.java index a0912189294..8a4289e9852 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReturnSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ReturnSchema.java @@ -7,10 +7,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ReturnSchema { // nest classes so all schemas and input/output classes can be public @@ -19,7 +19,16 @@ public class ReturnSchema { public class ReturnSchema2 extends Int32JsonSchema {} - public class ReturnSchema1 implements JsonSchema { + public static class ReturnMap extends FrozenMap { + ReturnMap(FrozenMap m) { + super(m); + } + public static ReturnMap of(Map arg, SchemaConfiguration configuration) { + return ReturnSchema1.validate(arg, configuration); + } + } + + public class ReturnSchema1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -28,7 +37,7 @@ public class ReturnSchema1 implements JsonSchema { Model for testing reserved words */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("return", ReturnSchema2.class) )); public static Void validate(Void arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ScaleneTriangle.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ScaleneTriangle.java index 0987d7604b5..af26930af1f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ScaleneTriangle.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ScaleneTriangle.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ScaleneTriangle { // nest classes so all schemas and input/output classes can be public - public class TriangleType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class TriangleType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,20 +26,32 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("triangleType", TriangleType.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class ScaleneTriangle1 implements JsonSchema { + public class ScaleneTriangle1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Schema200Response.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Schema200Response.java index df2247d1728..2f90e6823d0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Schema200Response.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Schema200Response.java @@ -7,11 +7,11 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema200Response { // nest classes so all schemas and input/output classes can be public @@ -23,7 +23,16 @@ public class Name extends Int32JsonSchema {} public class ClassSchema extends StringJsonSchema {} - public class Schema200Response1 implements JsonSchema { + public static class Schema200ResponseMap extends FrozenMap { + Schema200ResponseMap(FrozenMap m) { + super(m); + } + public static Schema200ResponseMap of(Map arg, SchemaConfiguration configuration) { + return Schema200Response1.validate(arg, configuration); + } + } + + public class Schema200Response1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -32,7 +41,7 @@ public class Schema200Response1 implements JsonSchema { model with an invalid class name for python, starts with a number */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("name", Name.class), new AbstractMap.SimpleEntry>("class", ClassSchema.class) )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingArrayModel.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingArrayModel.java index cc9dd17d366..ed4785fa4d1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingArrayModel.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingArrayModel.java @@ -3,25 +3,34 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class SelfReferencingArrayModel { // nest classes so all schemas and input/output classes can be public - public class SelfReferencingArrayModel1 implements JsonSchema { + public static class SelfReferencingArrayModelList extends FrozenList { + SelfReferencingArrayModelList(FrozenList m) { + super(m); + } + } + + public class SelfReferencingArrayModel1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = SelfReferencingArrayModel1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = SelfReferencingArrayModel1.class; + protected static SelfReferencingArrayModelList getListOutputInstance(FrozenList arg) { + return new SelfReferencingArrayModelList(arg); + } + public static SelfReferencingArrayModelList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(SelfReferencingArrayModel1.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingObjectModel.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingObjectModel.java index f5804ec4d08..5ff49df83e0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingObjectModel.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SelfReferencingObjectModel.java @@ -5,28 +5,40 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class SelfReferencingObjectModel { // nest classes so all schemas and input/output classes can be public - public class SelfReferencingObjectModel1 implements JsonSchema { + public static class SelfReferencingObjectModelMap extends FrozenMap { + SelfReferencingObjectModelMap(FrozenMap m) { + super(m); + } + public static SelfReferencingObjectModelMap of(Map arg, SchemaConfiguration configuration) { + return SelfReferencingObjectModel1.validate(arg, configuration); + } + } + + public class SelfReferencingObjectModel1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("selfRef", SelfReferencingObjectModel1.class) )); static final Class additionalProperties = SelfReferencingObjectModel1.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SelfReferencingObjectModelMap getMapOutputInstance(FrozenMap arg) { + return new SelfReferencingObjectModelMap(arg); + } + public static SelfReferencingObjectModelMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(SelfReferencingObjectModel1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Shape.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Shape.java index 34e83f1cf44..c64e063770f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Shape.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Shape.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Shape { // nest classes so all schemas and input/output classes can be public - public class Shape1 implements JsonSchema { + public class Shape1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ShapeOrNull.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ShapeOrNull.java index 200266b0d19..a91e498968e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ShapeOrNull.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/ShapeOrNull.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class ShapeOrNull { // nest classes so all schemas and input/output classes can be public @@ -17,7 +17,7 @@ public class ShapeOrNull { public class Schema0 extends NullJsonSchema {} - public class ShapeOrNull1 implements JsonSchema { + public class ShapeOrNull1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SimpleQuadrilateral.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SimpleQuadrilateral.java index c1fbcbe4ece..b6cdeed9ab2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SimpleQuadrilateral.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SimpleQuadrilateral.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class SimpleQuadrilateral { // nest classes so all schemas and input/output classes can be public - public class QuadrilateralType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class QuadrilateralType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,20 +26,32 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class Schema1Map extends FrozenMap { + Schema1Map(FrozenMap m) { + super(m); + } + public static Schema1Map of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("quadrilateralType", QuadrilateralType.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static Schema1Map getMapOutputInstance(FrozenMap arg) { + return new Schema1Map(arg); + } + public static Schema1Map validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } - public class SimpleQuadrilateral1 implements JsonSchema { + public class SimpleQuadrilateral1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SomeObject.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SomeObject.java index e5e69d36281..ee20add6068 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SomeObject.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SomeObject.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class SomeObject { // nest classes so all schemas and input/output classes can be public - public class SomeObject1 implements JsonSchema { + public class SomeObject1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SpecialModelname.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SpecialModelname.java index f9aa67839c7..872b24a835b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SpecialModelname.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/SpecialModelname.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class SpecialModelname { // nest classes so all schemas and input/output classes can be public @@ -16,7 +16,16 @@ public class SpecialModelname { public class A extends StringJsonSchema {} - public class SpecialModelname1 implements JsonSchema { + public static class SpecialModelnameMap extends FrozenMap { + SpecialModelnameMap(FrozenMap m) { + super(m); + } + public static SpecialModelnameMap of(Map arg, SchemaConfiguration configuration) { + return SpecialModelname1.validate(arg, configuration); + } + } + + public class SpecialModelname1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator @@ -25,13 +34,16 @@ public class SpecialModelname1 implements JsonSchema { model with an invalid class name for python */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("a", A.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SpecialModelnameMap getMapOutputInstance(FrozenMap arg) { + return new SpecialModelnameMap(arg); + } + public static SpecialModelnameMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(SpecialModelname1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringBooleanMap.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringBooleanMap.java index 982962912ad..22e15daff06 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringBooleanMap.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringBooleanMap.java @@ -4,8 +4,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.BooleanJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class StringBooleanMap { // nest classes so all schemas and input/output classes can be public @@ -14,18 +14,30 @@ public class StringBooleanMap { public class AdditionalProperties extends BooleanJsonSchema {} - public class StringBooleanMap1 implements JsonSchema { + public static class StringBooleanMapMap extends FrozenMap { + StringBooleanMapMap(FrozenMap m) { + super(m); + } + public static StringBooleanMapMap of(Map arg, SchemaConfiguration configuration) { + return StringBooleanMap1.validate(arg, configuration); + } + } + + public class StringBooleanMap1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static StringBooleanMapMap getMapOutputInstance(FrozenMap arg) { + return new StringBooleanMapMap(arg); + } + public static StringBooleanMapMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(StringBooleanMap1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnum.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnum.java index 7328048fa9a..dc9406bd25e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnum.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnum.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class StringEnum { // nest classes so all schemas and input/output classes can be public - public class StringEnum1 implements JsonSchema { + public class StringEnum1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, String.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnumWithDefaultValue.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnumWithDefaultValue.java index bd0b7a35eb9..e9f573137fd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnumWithDefaultValue.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringEnumWithDefaultValue.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class StringEnumWithDefaultValue { // nest classes so all schemas and input/output classes can be public - public class StringEnumWithDefaultValue1 implements JsonSchema { + public class StringEnumWithDefaultValue1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringWithValidation.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringWithValidation.java index e0b248ae616..d5c209cc332 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringWithValidation.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/StringWithValidation.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class StringWithValidation { // nest classes so all schemas and input/output classes can be public - public class StringWithValidation1 implements JsonSchema { + public class StringWithValidation1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Tag.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Tag.java index 5afa078ae5b..5f7b3c3e9e3 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Tag.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Tag.java @@ -5,10 +5,10 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Tag { // nest classes so all schemas and input/output classes can be public @@ -20,21 +20,33 @@ public class Id extends Int64JsonSchema {} public class Name extends StringJsonSchema {} - public class Tag1 implements JsonSchema { + public static class TagMap extends FrozenMap { + TagMap(FrozenMap m) { + super(m); + } + public static TagMap of(Map arg, SchemaConfiguration configuration) { + return Tag1.validate(arg, configuration); + } + } + + public class Tag1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class), new AbstractMap.SimpleEntry>("name", Name.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static TagMap getMapOutputInstance(FrozenMap arg) { + return new TagMap(arg); + } + public static TagMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Tag1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Triangle.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Triangle.java index 422bddd16bd..9b646da44c2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Triangle.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Triangle.java @@ -5,15 +5,15 @@ import java.util.Map; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Triangle { // nest classes so all schemas and input/output classes can be public - public class Triangle1 implements JsonSchema { + public class Triangle1 extends JsonSchema { /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/TriangleInterface.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/TriangleInterface.java index d082ed84d95..160015d76be 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/TriangleInterface.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/TriangleInterface.java @@ -9,17 +9,17 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class TriangleInterface { // nest classes so all schemas and input/output classes can be public - public class ShapeType implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ShapeType extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -30,18 +30,27 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class TriangleType extends StringJsonSchema {} - public class TriangleInterface1 implements JsonSchema { + public static class TriangleInterfaceMap extends FrozenMap { + TriangleInterfaceMap(FrozenMap m) { + super(m); + } + public static TriangleInterfaceMap of(Map arg, SchemaConfiguration configuration) { + return TriangleInterface1.validate(arg, configuration); + } + } + + public class TriangleInterface1 extends JsonSchema { /* 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. */ - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("shapeType", ShapeType.class), new AbstractMap.SimpleEntry>("triangleType", TriangleType.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "shapeType", "triangleType" )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/UUIDString.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/UUIDString.java index 23525d05155..04e810e4f67 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/UUIDString.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/UUIDString.java @@ -3,23 +3,23 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class UUIDString { // nest classes so all schemas and input/output classes can be public - public class UUIDString1 implements JsonSchema { + public class UUIDString1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "uuid"; + public static final String format = "uuid"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(UUIDString1.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/User.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/User.java index 6bb8d313698..3b54efbf150 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/User.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/User.java @@ -10,14 +10,14 @@ import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int32JsonSchema; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.MapJsonSchema; import org.openapijsonschematools.schemas.NullJsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class User { // nest classes so all schemas and input/output classes can be public @@ -50,8 +50,8 @@ public class UserStatus extends Int32JsonSchema {} public class ObjectWithNoDeclaredProps extends MapJsonSchema {} - public class ObjectWithNoDeclaredPropsNullable implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ObjectWithNoDeclaredPropsNullable extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class, FrozenMap.class )); @@ -69,7 +69,7 @@ public class AnyTypeProp extends AnyTypeJsonSchema {} public class Not extends NullJsonSchema {} - public class AnyTypeExceptNullProp implements JsonSchema { + public class AnyTypeExceptNullProp extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(AnyTypeExceptNullProp.class, arg, configuration); } @@ -122,17 +122,26 @@ public static U validate(List arg, SchemaConfigur public class AnyTypePropNullable extends AnyTypeJsonSchema {} - public class User1 implements JsonSchema { + public static class UserMap extends FrozenMap { + UserMap(FrozenMap m) { + super(m); + } + public static UserMap of(Map arg, SchemaConfiguration configuration) { + return User1.validate(arg, configuration); + } + } + + public class User1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Id.class), new AbstractMap.SimpleEntry>("username", Username.class), new AbstractMap.SimpleEntry>("firstName", FirstName.class), @@ -147,7 +156,10 @@ public class User1 implements JsonSchema { new AbstractMap.SimpleEntry>("anyTypeExceptNullProp", AnyTypeExceptNullProp.class), new AbstractMap.SimpleEntry>("anyTypePropNullable", AnyTypePropNullable.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static UserMap getMapOutputInstance(FrozenMap arg) { + return new UserMap(arg); + } + public static UserMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(User1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Whale.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Whale.java index a24d2481a7c..f62a50b5db8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Whale.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Whale.java @@ -6,8 +6,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.BooleanJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Whale { // nest classes so all schemas and input/output classes can be public @@ -19,8 +19,8 @@ public class HasBaleen extends BooleanJsonSchema {} public class HasTeeth extends BooleanJsonSchema {} - public class ClassName implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ClassName extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -28,25 +28,37 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Whale1 implements JsonSchema { + public static class WhaleMap extends FrozenMap { + WhaleMap(FrozenMap m) { + super(m); + } + public static WhaleMap of(Map arg, SchemaConfiguration configuration) { + return Whale1.validate(arg, configuration); + } + } + + public class Whale1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("hasBaleen", HasBaleen.class), new AbstractMap.SimpleEntry>("hasTeeth", HasTeeth.class), new AbstractMap.SimpleEntry>("className", ClassName.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "className" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static WhaleMap getMapOutputInstance(FrozenMap arg) { + return new WhaleMap(arg); + } + public static WhaleMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Whale1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Zebra.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Zebra.java index 04bac616609..7c484f210fc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Zebra.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/components/schemas/Zebra.java @@ -6,8 +6,8 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Zebra { // nest classes so all schemas and input/output classes can be public @@ -16,8 +16,8 @@ public class Zebra { public class AdditionalProperties extends AnyTypeJsonSchema {} - public class Type implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Type extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -25,8 +25,8 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class ClassName implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class ClassName extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -34,25 +34,37 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Zebra1 implements JsonSchema { + public static class ZebraMap extends FrozenMap { + ZebraMap(FrozenMap m) { + super(m); + } + public static ZebraMap of(Map arg, SchemaConfiguration configuration) { + return Zebra1.validate(arg, configuration); + } + } + + public class Zebra1 extends JsonSchema { /* 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. */ - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("type", Type.class), new AbstractMap.SimpleEntry>("className", ClassName.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "className" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static ZebraMap getMapOutputInstance(FrozenMap arg) { + return new ZebraMap(arg); + } + public static ZebraMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Zebra1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/HeaderParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/HeaderParameters.java index 0de422a5941..4ccce582dd2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/HeaderParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/HeaderParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.commonparamsubdir.delete.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HeaderParameters { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class HeaderParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeaderParametersMap extends FrozenMap { + HeaderParametersMap(FrozenMap m) { + super(m); + } + public static HeaderParametersMap of(Map arg, SchemaConfiguration configuration) { + return HeaderParameters1.validate(arg, configuration); + } + } + + public class HeaderParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someHeader", Schema0.Schema01.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeaderParametersMap getMapOutputInstance(FrozenMap arg) { + return new HeaderParametersMap(arg); + } + public static HeaderParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HeaderParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/PathParameters.java index a3bb2161aee..592b43bac19 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.commonparamsubdir.delete.parameters.parameter1.Schema1; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("subDir", Schema1.Schema11.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "subDir" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/parameters/parameter1/Schema1.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/parameters/parameter1/Schema1.java index 83cb4ac7ac1..03c538e9edd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/parameters/parameter1/Schema1.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/delete/parameters/parameter1/Schema1.java @@ -2,14 +2,14 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema1 { // nest classes so all schemas and input/output classes can be public - public class Schema11 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema11 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/PathParameters.java index bcb146e36f7..271f3e536aa 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.commonparamsubdir.parameters.parameter0.PathParamSchema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("subDir", PathParamSchema0.PathParamSchema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "subDir" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/QueryParameters.java index e2a1c6e7fa1..286d8fbbcae 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/get/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.commonparamsubdir.get.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("searchStr", Schema0.Schema01.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/parameters/parameter0/PathParamSchema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/parameters/parameter0/PathParamSchema0.java index 216ddd2a8d2..865512bccd5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/parameters/parameter0/PathParamSchema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/parameters/parameter0/PathParamSchema0.java @@ -2,14 +2,14 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParamSchema0 { // nest classes so all schemas and input/output classes can be public - public class PathParamSchema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class PathParamSchema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/HeaderParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/HeaderParameters.java index 39a2db11ccb..b42e91a6cf5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/HeaderParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/HeaderParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.commonparamsubdir.post.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HeaderParameters { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class HeaderParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeaderParametersMap extends FrozenMap { + HeaderParametersMap(FrozenMap m) { + super(m); + } + public static HeaderParametersMap of(Map arg, SchemaConfiguration configuration) { + return HeaderParameters1.validate(arg, configuration); + } + } + + public class HeaderParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someHeader", Schema0.Schema01.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeaderParametersMap getMapOutputInstance(FrozenMap arg) { + return new HeaderParametersMap(arg); + } + public static HeaderParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HeaderParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/PathParameters.java index a3d81459bc7..2912e24a047 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/commonparamsubdir/post/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.commonparamsubdir.parameters.parameter0.PathParamSchema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("subDir", PathParamSchema0.PathParamSchema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "subDir" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/HeaderParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/HeaderParameters.java index c617df271e0..429820e6b92 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/HeaderParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/HeaderParameters.java @@ -8,9 +8,9 @@ import org.openapijsonschematools.paths.fake.delete.parameters.parameter1.Schema1; import org.openapijsonschematools.paths.fake.delete.parameters.parameter4.Schema4; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HeaderParameters { // nest classes so all schemas and input/output classes can be public @@ -20,19 +20,31 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class HeaderParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeaderParametersMap extends FrozenMap { + HeaderParametersMap(FrozenMap m) { + super(m); + } + public static HeaderParametersMap of(Map arg, SchemaConfiguration configuration) { + return HeaderParameters1.validate(arg, configuration); + } + } + + public class HeaderParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("required_boolean_group", Schema1.Schema11.class), new AbstractMap.SimpleEntry>("boolean_group", Schema4.Schema41.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "required_boolean_group" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeaderParametersMap getMapOutputInstance(FrozenMap arg) { + return new HeaderParametersMap(arg); + } + public static HeaderParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HeaderParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/QueryParameters.java index d8a7caa18e0..1cfe32c188c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/QueryParameters.java @@ -10,9 +10,9 @@ import org.openapijsonschematools.paths.fake.delete.parameters.parameter3.Schema3; import org.openapijsonschematools.paths.fake.delete.parameters.parameter5.Schema5; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -22,22 +22,34 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("required_string_group", Schema0.Schema01.class), new AbstractMap.SimpleEntry>("int64_group", Schema5.Schema51.class), new AbstractMap.SimpleEntry>("string_group", Schema3.Schema31.class), new AbstractMap.SimpleEntry>("required_int64_group", Schema2.Schema21.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "required_int64_group", "required_string_group" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter1/Schema1.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter1/Schema1.java index 710e826fb92..2375ad55772 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter1/Schema1.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter1/Schema1.java @@ -2,14 +2,14 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema1 { // nest classes so all schemas and input/output classes can be public - public class Schema11 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema11 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter4/Schema4.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter4/Schema4.java index 0f111854b5f..71dd6954dfa 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter4/Schema4.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/delete/parameters/parameter4/Schema4.java @@ -2,14 +2,14 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema4 { // nest classes so all schemas and input/output classes can be public - public class Schema41 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema41 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/HeaderParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/HeaderParameters.java index db4641974ec..62219afc9d1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/HeaderParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/HeaderParameters.java @@ -8,9 +8,9 @@ import org.openapijsonschematools.paths.fake.get.parameters.parameter0.Schema0; import org.openapijsonschematools.paths.fake.get.parameters.parameter1.Schema1; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HeaderParameters { // nest classes so all schemas and input/output classes can be public @@ -20,16 +20,28 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class HeaderParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeaderParametersMap extends FrozenMap { + HeaderParametersMap(FrozenMap m) { + super(m); + } + public static HeaderParametersMap of(Map arg, SchemaConfiguration configuration) { + return HeaderParameters1.validate(arg, configuration); + } + } + + public class HeaderParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("enum_header_string", Schema1.Schema11.class), new AbstractMap.SimpleEntry>("enum_header_string_array", Schema0.Schema01.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeaderParametersMap getMapOutputInstance(FrozenMap arg) { + return new HeaderParametersMap(arg); + } + public static HeaderParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HeaderParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/QueryParameters.java index 1a4cfc7c570..83c245a4072 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/QueryParameters.java @@ -10,9 +10,9 @@ import org.openapijsonschematools.paths.fake.get.parameters.parameter4.Schema4; import org.openapijsonschematools.paths.fake.get.parameters.parameter5.Schema5; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -22,18 +22,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("enum_query_double", Schema5.Schema51.class), new AbstractMap.SimpleEntry>("enum_query_string", Schema3.Schema31.class), new AbstractMap.SimpleEntry>("enum_query_integer", Schema4.Schema41.class), new AbstractMap.SimpleEntry>("enum_query_string_array", Schema2.Schema21.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter0/Schema0.java index 016fa5f9f8e..5db013a56a8 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter0/Schema0.java @@ -3,15 +3,15 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public - public class Items0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -19,12 +19,21 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList0 extends FrozenList { + SchemaList0(FrozenList m) { + super(m); + } + } + + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items0.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items0.class; + protected static SchemaList0 getListOutputInstance(FrozenList arg) { + return new SchemaList0(arg); + } + public static SchemaList0 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter1/Schema1.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter1/Schema1.java index 561205d1994..2defe740bde 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter1/Schema1.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter1/Schema1.java @@ -2,14 +2,14 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema1 { // nest classes so all schemas and input/output classes can be public - public class Schema11 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema11 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter2/Schema2.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter2/Schema2.java index 5877e766c5e..00cfa65dafb 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter2/Schema2.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter2/Schema2.java @@ -3,15 +3,15 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema2 { // nest classes so all schemas and input/output classes can be public - public class Items2 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items2 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -19,12 +19,21 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema21 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList2 extends FrozenList { + SchemaList2(FrozenList m) { + super(m); + } + } + + public class Schema21 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items2.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items2.class; + protected static SchemaList2 getListOutputInstance(FrozenList arg) { + return new SchemaList2(arg); + } + public static SchemaList2 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema21.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter3/Schema3.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter3/Schema3.java index 659177d4211..b2a9df8e57a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter3/Schema3.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter3/Schema3.java @@ -2,14 +2,14 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema3 { // nest classes so all schemas and input/output classes can be public - public class Schema31 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema31 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter4/Schema4.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter4/Schema4.java index 1b0ada867db..12073ee77e0 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter4/Schema4.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter4/Schema4.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema4 { // nest classes so all schemas and input/output classes can be public - public class Schema41 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema41 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int32"; + public static final String format = "int32"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema41.class, Long.valueOf(arg), configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter5/Schema5.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter5/Schema5.java index f22f85161bd..a1f044efa62 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter5/Schema5.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/parameters/parameter5/Schema5.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema5 { // nest classes so all schemas and input/output classes can be public - public class Schema51 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema51 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "double"; + public static final String format = "double"; public static Double validate(Double arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema51.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/requestbody/content/applicationxwwwformurlencoded/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/requestbody/content/applicationxwwwformurlencoded/Schema.java index fce142ca4c3..737a9cd657a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/requestbody/content/applicationxwwwformurlencoded/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/get/requestbody/content/applicationxwwwformurlencoded/Schema.java @@ -6,16 +6,16 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Items implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -23,18 +23,27 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class EnumFormStringArray implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class EnumFormStringArrayList extends FrozenList { + EnumFormStringArrayList(FrozenList m) { + super(m); + } + } + + public class EnumFormStringArray extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static EnumFormStringArrayList getListOutputInstance(FrozenList arg) { + return new EnumFormStringArrayList(arg); + } + public static EnumFormStringArrayList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(EnumFormStringArray.class, arg, configuration); } } - public class EnumFormString implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class EnumFormString extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -42,15 +51,27 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("enum_form_string_array", EnumFormStringArray.class), new AbstractMap.SimpleEntry>("enum_form_string", EnumFormString.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/post/requestbody/content/applicationxwwwformurlencoded/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/post/requestbody/content/applicationxwwwformurlencoded/Schema.java index 8b1e377e3f0..af55d6a5e4a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/post/requestbody/content/applicationxwwwformurlencoded/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fake/post/requestbody/content/applicationxwwwformurlencoded/Schema.java @@ -7,17 +7,17 @@ import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.DateJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; import org.openapijsonschematools.schemas.Int64JsonSchema; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class IntegerSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class IntegerSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, @@ -40,14 +40,14 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { } } - public class Int32 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Int32 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int32"; + public static final String format = "int32"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(Int32.class, Long.valueOf(arg), configuration); } @@ -68,8 +68,8 @@ public static Long validate(Double arg, SchemaConfiguration configuration) { public class Int64 extends Int64JsonSchema {} - public class NumberSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class NumberSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, @@ -92,34 +92,34 @@ public static Number validate(Double arg, SchemaConfiguration configuration) { } } - public class FloatSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class FloatSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "float"; + public static final String format = "float"; public static Float validate(Float arg, SchemaConfiguration configuration) { return JsonSchema.validate(FloatSchema.class, arg, configuration); } } - public class DoubleSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class DoubleSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "double"; + public static final String format = "double"; public static Double validate(Double arg, SchemaConfiguration configuration) { return JsonSchema.validate(DoubleSchema.class, arg, configuration); } } - public class StringSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class StringSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -127,8 +127,8 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class PatternWithoutDelimiter implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class PatternWithoutDelimiter extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -139,7 +139,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class ByteSchema extends StringJsonSchema {} - public class Binary implements JsonSchema { + public class Binary extends JsonSchema { // BinarySchema } @@ -147,21 +147,21 @@ public class Binary implements JsonSchema { public class Date extends DateJsonSchema {} - public class DateTime implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class DateTime extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "date-time"; + public static final String format = "date-time"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(DateTime.class, arg, configuration); } } - public class Password implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Password extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "password"; + public static final String format = "password"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(Password.class, arg, configuration); } @@ -170,11 +170,20 @@ public static String validate(String arg, SchemaConfiguration configuration) { public class Callback extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("integer", IntegerSchema.class), new AbstractMap.SimpleEntry>("int32", Int32.class), new AbstractMap.SimpleEntry>("int64", Int64.class), @@ -190,13 +199,16 @@ public class Schema1 implements JsonSchema { new AbstractMap.SimpleEntry>("password", Password.class), new AbstractMap.SimpleEntry>("callback", Callback.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "byte", "double", "number", "pattern_without_delimiter" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakebodywithqueryparams/put/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakebodywithqueryparams/put/QueryParameters.java index 6a5970cbaf1..5bb2eff4351 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakebodywithqueryparams/put/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakebodywithqueryparams/put/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.fakebodywithqueryparams.put.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("query", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "query" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakecasesensitiveparams/put/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakecasesensitiveparams/put/QueryParameters.java index d42dd9f5e7c..45e9b37b72c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakecasesensitiveparams/put/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakecasesensitiveparams/put/QueryParameters.java @@ -9,9 +9,9 @@ import org.openapijsonschematools.paths.fakecasesensitiveparams.put.parameters.parameter1.Schema1; import org.openapijsonschematools.paths.fakecasesensitiveparams.put.parameters.parameter2.Schema2; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -21,22 +21,34 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someVar", Schema0.Schema01.class), new AbstractMap.SimpleEntry>("some_var", Schema2.Schema21.class), new AbstractMap.SimpleEntry>("SomeVar", Schema1.Schema11.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "SomeVar", "someVar", "some_var" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakedeletecoffeeid/delete/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakedeletecoffeeid/delete/PathParameters.java index 636061a20ad..f4e918d6fd1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakedeletecoffeeid/delete/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakedeletecoffeeid/delete/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.fakedeletecoffeeid.delete.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("id", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "id" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlineadditionalproperties/post/requestbody/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlineadditionalproperties/post/requestbody/content/applicationjson/Schema.java index bb5f11f518f..4d520d4c209 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlineadditionalproperties/post/requestbody/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlineadditionalproperties/post/requestbody/content/applicationjson/Schema.java @@ -3,9 +3,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,24 @@ public class Schema { public class AdditionalProperties extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/QueryParameters.java index 2a37f013324..1997310202c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/QueryParameters.java @@ -8,9 +8,9 @@ import org.openapijsonschematools.paths.fakeinlinecomposition.post.parameters.parameter0.Schema0; import org.openapijsonschematools.paths.fakeinlinecomposition.post.parameters.parameter1.Schema1; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -20,16 +20,28 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("compositionAtRoot", Schema0.Schema01.class), new AbstractMap.SimpleEntry>("compositionInProperty", Schema1.Schema11.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter0/Schema0.java index 432843936ec..642a1dc23a9 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter0/Schema0.java @@ -7,16 +7,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public - public class Schema00 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema00 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -24,7 +24,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema01 implements JsonSchema { + public class Schema01 extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter1/Schema1.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter1/Schema1.java index 4b78f8e42be..064c9899187 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter1/Schema1.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/parameters/parameter1/Schema1.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema1 { // nest classes so all schemas and input/output classes can be public - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,7 +26,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class SomeProp1 implements JsonSchema { + public class SomeProp1 extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(SomeProp1.class, arg, configuration); } @@ -76,14 +76,26 @@ public static U validate(List arg, SchemaConfigur } } - public class Schema11 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap1 extends FrozenMap { + SchemaMap1(FrozenMap m) { + super(m); + } + public static SchemaMap1 of(Map arg, SchemaConfiguration configuration) { + return Schema11.validate(arg, configuration); + } + } + + public class Schema11 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someProp", SomeProp1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap1 getMapOutputInstance(FrozenMap arg) { + return new SchemaMap1(arg); + } + public static SchemaMap1 validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema11.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/applicationjson/Schema.java index 6b30ba64013..53d032461ef 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/applicationjson/Schema.java @@ -7,16 +7,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -24,7 +24,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { + public class Schema1 extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/multipartformdata/Schema.java index 3de93bbf15d..9e47d780052 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/requestbody/content/multipartformdata/Schema.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,7 +26,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class SomeProp implements JsonSchema { + public class SomeProp extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(SomeProp.class, arg, configuration); } @@ -76,14 +76,26 @@ public static U validate(List arg, SchemaConfigur } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someProp", SomeProp.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/applicationjson/Schema.java index 1ce9290318a..bc6965f002a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/applicationjson/Schema.java @@ -7,16 +7,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -24,7 +24,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema1 implements JsonSchema { + public class Schema1 extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/multipartformdata/Schema.java index c92f0a34232..e7098ca00c9 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeinlinecomposition/post/responses/response200/content/multipartformdata/Schema.java @@ -9,16 +9,16 @@ import java.util.Set; import java.util.UUID; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -26,7 +26,7 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class SomeProp implements JsonSchema { + public class SomeProp extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(SomeProp.class, arg, configuration); } @@ -76,14 +76,26 @@ public static U validate(List arg, SchemaConfigur } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someProp", SomeProp.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakejsonformdata/get/requestbody/content/applicationxwwwformurlencoded/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakejsonformdata/get/requestbody/content/applicationxwwwformurlencoded/Schema.java index 064b715d892..8fed7b5d3fb 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakejsonformdata/get/requestbody/content/applicationxwwwformurlencoded/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakejsonformdata/get/requestbody/content/applicationxwwwformurlencoded/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -19,19 +19,31 @@ public class Param extends StringJsonSchema {} public class Param2 extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("param", Param.class), new AbstractMap.SimpleEntry>("param2", Param2.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "param", "param2" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/applicationjson/Schema.java index a561f7b5019..00cafec01e4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/applicationjson/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -16,14 +16,26 @@ public class Schema { public class A extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("a", A.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/multipartformdata/Schema.java index d3e8be6eb24..66a25c76ba5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakemultiplerequestbodycontenttypes/post/requestbody/content/multipartformdata/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -16,14 +16,26 @@ public class Schema { public class B extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("b", B.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/QueryParameters.java index ead2819509e..af0996f3638 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.fakeobjinquery.get.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("mapBean", Schema0.Schema01.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/parameters/parameter0/Schema0.java index 3b1d220b1eb..146ede8f79d 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeobjinquery/get/parameters/parameter0/Schema0.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public @@ -16,14 +16,26 @@ public class Schema0 { public class Keyword0 extends StringJsonSchema {} - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap0 extends FrozenMap { + SchemaMap0(FrozenMap m) { + super(m); + } + public static SchemaMap0 of(Map arg, SchemaConfiguration configuration) { + return Schema01.validate(arg, configuration); + } + } + + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("keyword", Keyword0.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap0 getMapOutputInstance(FrozenMap arg) { + return new SchemaMap0(arg); + } + public static SchemaMap0 validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/CookieParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/CookieParameters.java index f4ecf2a03ab..741f93f6a1e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/CookieParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/CookieParameters.java @@ -11,9 +11,9 @@ import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter17.Schema17; import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter18.Schema18; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class CookieParameters { // nest classes so all schemas and input/output classes can be public @@ -23,11 +23,20 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class CookieParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class CookieParametersMap extends FrozenMap { + CookieParametersMap(FrozenMap m) { + super(m); + } + public static CookieParametersMap of(Map arg, SchemaConfiguration configuration) { + return CookieParameters1.validate(arg, configuration); + } + } + + public class CookieParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("1", Schema14.Schema141.class), new AbstractMap.SimpleEntry>("aB", Schema15.Schema151.class), new AbstractMap.SimpleEntry>("Ab", Schema16.Schema161.class), @@ -35,7 +44,10 @@ public class CookieParameters1 implements JsonSchema { new AbstractMap.SimpleEntry>("self", Schema17.Schema171.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static CookieParametersMap getMapOutputInstance(FrozenMap arg) { + return new CookieParametersMap(arg); + } + public static CookieParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(CookieParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/HeaderParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/HeaderParameters.java index f809d0b1725..d6e48658278 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/HeaderParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/HeaderParameters.java @@ -10,9 +10,9 @@ import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter7.Schema7; import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter8.Schema8; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HeaderParameters { // nest classes so all schemas and input/output classes can be public @@ -22,18 +22,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class HeaderParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeaderParametersMap extends FrozenMap { + HeaderParametersMap(FrozenMap m) { + super(m); + } + public static HeaderParametersMap of(Map arg, SchemaConfiguration configuration) { + return HeaderParameters1.validate(arg, configuration); + } + } + + public class HeaderParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("1", Schema5.Schema51.class), new AbstractMap.SimpleEntry>("aB", Schema6.Schema61.class), new AbstractMap.SimpleEntry>("A-B", Schema8.Schema81.class), new AbstractMap.SimpleEntry>("self", Schema7.Schema71.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeaderParametersMap getMapOutputInstance(FrozenMap arg) { + return new HeaderParametersMap(arg); + } + public static HeaderParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HeaderParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/PathParameters.java index e6885b3eb79..17680b1a1fe 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/PathParameters.java @@ -11,9 +11,9 @@ import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter13.Schema13; import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter9.Schema9; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -23,18 +23,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("1", Schema9.Schema91.class), new AbstractMap.SimpleEntry>("aB", Schema10.Schema101.class), new AbstractMap.SimpleEntry>("Ab", Schema11.Schema111.class), new AbstractMap.SimpleEntry>("A-B", Schema13.Schema131.class), new AbstractMap.SimpleEntry>("self", Schema12.Schema121.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "1", "A-B", "Ab", @@ -42,7 +51,10 @@ public class PathParameters1 implements JsonSchema { "self" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/QueryParameters.java index 1c106105153..4c492dfbf84 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeparametercollisions1ababselfab/post/QueryParameters.java @@ -11,9 +11,9 @@ import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter3.Schema3; import org.openapijsonschematools.paths.fakeparametercollisions1ababselfab.post.parameters.parameter4.Schema4; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -23,11 +23,20 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("1", Schema0.Schema01.class), new AbstractMap.SimpleEntry>("aB", Schema1.Schema11.class), new AbstractMap.SimpleEntry>("Ab", Schema2.Schema21.class), @@ -35,7 +44,10 @@ public class QueryParameters1 implements JsonSchema { new AbstractMap.SimpleEntry>("self", Schema3.Schema31.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/PathParameters.java index cc94f8727ed..c7d7fc26f60 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.fakepetiduploadimagewithrequiredfile.post.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("petId", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "petId" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/requestbody/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/requestbody/content/multipartformdata/Schema.java index 45a3b1e1b82..8ea5097b84e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/requestbody/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakepetiduploadimagewithrequiredfile/post/requestbody/content/multipartformdata/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -16,23 +16,35 @@ public class Schema { public class AdditionalMetadata extends StringJsonSchema {} - public class RequiredFile implements JsonSchema { + public class RequiredFile extends JsonSchema { // BinarySchema } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("additionalMetadata", AdditionalMetadata.class), new AbstractMap.SimpleEntry>("requiredFile", RequiredFile.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "requiredFile" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakequeryparamwithjsoncontenttype/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakequeryparamwithjsoncontenttype/get/QueryParameters.java index 6f1a212309d..4a40126ab7a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakequeryparamwithjsoncontenttype/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakequeryparamwithjsoncontenttype/get/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.fakequeryparamwithjsoncontenttype.get.parameters.parameter0.content.applicationjson.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("someParam", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "someParam" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakerefobjinquery/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakerefobjinquery/get/QueryParameters.java index 1bdd3fcc021..0d6246818aa 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakerefobjinquery/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakerefobjinquery/get/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.components.schemas.Foo; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("mapBean", Foo.Foo1.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/QueryParameters.java index 228fad9536a..4d96a148396 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/QueryParameters.java @@ -12,9 +12,9 @@ import org.openapijsonschematools.paths.faketestqueryparamters.put.parameters.parameter3.Schema3; import org.openapijsonschematools.paths.faketestqueryparamters.put.parameters.parameter4.Schema4; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -24,11 +24,20 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("refParam", StringWithValidation.StringWithValidation1.class), new AbstractMap.SimpleEntry>("ioutil", Schema1.Schema11.class), new AbstractMap.SimpleEntry>("context", Schema4.Schema41.class), @@ -36,7 +45,7 @@ public class QueryParameters1 implements JsonSchema { new AbstractMap.SimpleEntry>("pipe", Schema0.Schema01.class), new AbstractMap.SimpleEntry>("url", Schema3.Schema31.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "context", "http", "ioutil", @@ -45,7 +54,10 @@ public class QueryParameters1 implements JsonSchema { "url" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter0/Schema0.java index db1e281a96f..9a6d818c65b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter0/Schema0.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,21 @@ public class Schema0 { public class Items0 extends StringJsonSchema {} - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList0 extends FrozenList { + SchemaList0(FrozenList m) { + super(m); + } + } + + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items0.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items0.class; + protected static SchemaList0 getListOutputInstance(FrozenList arg) { + return new SchemaList0(arg); + } + public static SchemaList0 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter1/Schema1.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter1/Schema1.java index 643abbcb5f3..e0f12b760f3 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter1/Schema1.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter1/Schema1.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema1 { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,21 @@ public class Schema1 { public class Items1 extends StringJsonSchema {} - public class Schema11 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList1 extends FrozenList { + SchemaList1(FrozenList m) { + super(m); + } + } + + public class Schema11 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items1.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items1.class; + protected static SchemaList1 getListOutputInstance(FrozenList arg) { + return new SchemaList1(arg); + } + public static SchemaList1 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema11.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter2/Schema2.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter2/Schema2.java index a1c93217aa8..d0cca651db3 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter2/Schema2.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter2/Schema2.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema2 { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,21 @@ public class Schema2 { public class Items2 extends StringJsonSchema {} - public class Schema21 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList2 extends FrozenList { + SchemaList2(FrozenList m) { + super(m); + } + } + + public class Schema21 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items2.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items2.class; + protected static SchemaList2 getListOutputInstance(FrozenList arg) { + return new SchemaList2(arg); + } + public static SchemaList2 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema21.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter3/Schema3.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter3/Schema3.java index 8e1584fa523..5eef62bdafc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter3/Schema3.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter3/Schema3.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema3 { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,21 @@ public class Schema3 { public class Items3 extends StringJsonSchema {} - public class Schema31 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList3 extends FrozenList { + SchemaList3(FrozenList m) { + super(m); + } + } + + public class Schema31 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items3.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items3.class; + protected static SchemaList3 getListOutputInstance(FrozenList arg) { + return new SchemaList3(arg); + } + public static SchemaList3 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema31.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter4/Schema4.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter4/Schema4.java index 4540361150b..a2237a0c1ed 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter4/Schema4.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/faketestqueryparamters/put/parameters/parameter4/Schema4.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema4 { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,21 @@ public class Schema4 { public class Items4 extends StringJsonSchema {} - public class Schema41 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList4 extends FrozenList { + SchemaList4(FrozenList m) { + super(m); + } + } + + public class Schema41 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items4.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items4.class; + protected static SchemaList4 getListOutputInstance(FrozenList arg) { + return new SchemaList4(arg); + } + public static SchemaList4 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema41.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/requestbody/content/applicationoctetstream/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/requestbody/content/applicationoctetstream/Schema.java index 1ca917b6c4b..e68477a7e2f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/requestbody/content/applicationoctetstream/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/requestbody/content/applicationoctetstream/Schema.java @@ -1,11 +1,11 @@ package org.openapijsonschematools.paths.fakeuploaddownloadfile.post.requestbody.content.applicationoctetstream; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema1 implements JsonSchema { + public class Schema1 extends JsonSchema { // BinarySchema } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/responses/response200/content/applicationoctetstream/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/responses/response200/content/applicationoctetstream/Schema.java index 6e8517fc24c..e279a647c96 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/responses/response200/content/applicationoctetstream/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploaddownloadfile/post/responses/response200/content/applicationoctetstream/Schema.java @@ -1,11 +1,11 @@ package org.openapijsonschematools.paths.fakeuploaddownloadfile.post.responses.response200.content.applicationoctetstream; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema1 implements JsonSchema { + public class Schema1 extends JsonSchema { // BinarySchema } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfile/post/requestbody/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfile/post/requestbody/content/multipartformdata/Schema.java index 7229dcba718..a5dd54f177a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfile/post/requestbody/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfile/post/requestbody/content/multipartformdata/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -16,23 +16,35 @@ public class Schema { public class AdditionalMetadata extends StringJsonSchema {} - public class File implements JsonSchema { + public class File extends JsonSchema { // BinarySchema } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("additionalMetadata", AdditionalMetadata.class), new AbstractMap.SimpleEntry>("file", File.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "file" )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfiles/post/requestbody/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfiles/post/requestbody/content/multipartformdata/Schema.java index 9052d4978a5..bac0ac517a1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfiles/post/requestbody/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/fakeuploadfiles/post/requestbody/content/multipartformdata/Schema.java @@ -6,37 +6,58 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Items implements JsonSchema { + public class Items extends JsonSchema { // BinarySchema } - public class Files implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class FilesList extends FrozenList { + FilesList(FrozenList m) { + super(m); + } + } + + public class Files extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items.class; + protected static FilesList getListOutputInstance(FrozenList arg) { + return new FilesList(arg); + } + public static FilesList validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Files.class, arg, configuration); } } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("files", Files.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/foo/get/responses/responsedefault/content/applicationjson/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/foo/get/responses/responsedefault/content/applicationjson/Schema.java index 9a6907b020b..fca96d63d4a 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/foo/get/responses/responsedefault/content/applicationjson/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/foo/get/responses/responsedefault/content/applicationjson/Schema.java @@ -6,21 +6,33 @@ import java.util.Set; import org.openapijsonschematools.components.schemas.Foo; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("string", Foo.Foo1.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/QueryParameters.java index c0c5a38019e..4946a3737bc 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petfindbystatus.get.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("status", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "status" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/parameters/parameter0/Schema0.java index 9aba7e764b7..6bd908cb845 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbystatus/get/parameters/parameter0/Schema0.java @@ -3,15 +3,15 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public - public class Items0 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Items0 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); public static String validate(String arg, SchemaConfiguration configuration) { @@ -19,12 +19,21 @@ public static String validate(String arg, SchemaConfiguration configuration) { } } - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList0 extends FrozenList { + SchemaList0(FrozenList m) { + super(m); + } + } + + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items0.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items0.class; + protected static SchemaList0 getListOutputInstance(FrozenList arg) { + return new SchemaList0(arg); + } + public static SchemaList0 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/QueryParameters.java index 485626dea92..4deb5b26b6e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/QueryParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petfindbytags.get.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("tags", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "tags" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/parameters/parameter0/Schema0.java index b9256a0b08b..58ae1f40369 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petfindbytags/get/parameters/parameter0/Schema0.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public @@ -14,12 +14,21 @@ public class Schema0 { public class Items0 extends StringJsonSchema {} - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaList0 extends FrozenList { + SchemaList0(FrozenList m) { + super(m); + } + } + + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); - static final Class items = Items0.class; - public static U validate(List arg, SchemaConfiguration configuration) { + public static final Class items = Items0.class; + protected static SchemaList0 getListOutputInstance(FrozenList arg) { + return new SchemaList0(arg); + } + public static SchemaList0 validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, arg, configuration); } }} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/HeaderParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/HeaderParameters.java index e2696fec901..6ab13e5ee31 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/HeaderParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/HeaderParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petpetid.delete.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class HeaderParameters { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class HeaderParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeaderParametersMap extends FrozenMap { + HeaderParametersMap(FrozenMap m) { + super(m); + } + public static HeaderParametersMap of(Map arg, SchemaConfiguration configuration) { + return HeaderParameters1.validate(arg, configuration); + } + } + + public class HeaderParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("api_key", Schema0.Schema01.class) )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeaderParametersMap getMapOutputInstance(FrozenMap arg) { + return new HeaderParametersMap(arg); + } + public static HeaderParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(HeaderParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/PathParameters.java index 2e6ff1a3ab9..a0ecd9a60ab 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/delete/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petpetid.delete.parameters.parameter1.Schema1; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("petId", Schema1.Schema11.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "petId" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/get/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/get/PathParameters.java index f9152ac557b..a9c1599b976 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/get/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/get/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petpetid.get.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("petId", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "petId" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/PathParameters.java index 9d6aacb1d64..619a212be61 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petpetid.post.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("petId", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "petId" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/requestbody/content/applicationxwwwformurlencoded/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/requestbody/content/applicationxwwwformurlencoded/Schema.java index 74c47e97c77..1c776a04f40 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/requestbody/content/applicationxwwwformurlencoded/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetid/post/requestbody/content/applicationxwwwformurlencoded/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -19,15 +19,27 @@ public class Name extends StringJsonSchema {} public class Status extends StringJsonSchema {} - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("name", Name.class), new AbstractMap.SimpleEntry>("status", Status.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/PathParameters.java index c14c8f523a5..3dae1a22057 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.petpetiduploadimage.post.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("petId", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "petId" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/requestbody/content/multipartformdata/Schema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/requestbody/content/multipartformdata/Schema.java index 383f0c74cc5..075452db6d9 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/requestbody/content/multipartformdata/Schema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/petpetiduploadimage/post/requestbody/content/multipartformdata/Schema.java @@ -5,9 +5,9 @@ import java.util.Map; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.StringJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema { // nest classes so all schemas and input/output classes can be public @@ -16,20 +16,32 @@ public class Schema { public class AdditionalMetadata extends StringJsonSchema {} - public class File implements JsonSchema { + public class File extends JsonSchema { // BinarySchema } - public class Schema1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class SchemaMap extends FrozenMap { + SchemaMap(FrozenMap m) { + super(m); + } + public static SchemaMap of(Map arg, SchemaConfiguration configuration) { + return Schema1.validate(arg, configuration); + } + } + + public class Schema1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("additionalMetadata", AdditionalMetadata.class), new AbstractMap.SimpleEntry>("file", File.class) )); - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static SchemaMap getMapOutputInstance(FrozenMap arg) { + return new SchemaMap(arg); + } + public static SchemaMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/delete/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/delete/PathParameters.java index 0ca85011729..8ffb00de97b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/delete/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/delete/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.storeorderorderid.delete.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("order_id", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "order_id" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/PathParameters.java index 2dbbc3664b4..6bc48c34ade 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.paths.storeorderorderid.get.parameters.parameter0.Schema0; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("order_id", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "order_id" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/parameters/parameter0/Schema0.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/parameters/parameter0/Schema0.java index ab65c1784e8..98f2fd66838 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/parameters/parameter0/Schema0.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/storeorderorderid/get/parameters/parameter0/Schema0.java @@ -2,20 +2,20 @@ import java.util.LinkedHashSet; import java.util.Set; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.JsonSchema; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Schema0 { // nest classes so all schemas and input/output classes can be public - public class Schema01 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public class Schema01 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, Double.class )); - static final String format = "int64"; + public static final String format = "int64"; public static Long validate(Integer arg, SchemaConfiguration configuration) { return JsonSchema.validate(Schema01.class, Long.valueOf(arg), configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/QueryParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/QueryParameters.java index 7783426a47f..8f762b434e2 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/QueryParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/QueryParameters.java @@ -8,9 +8,9 @@ import org.openapijsonschematools.paths.userlogin.get.parameters.parameter0.Schema0; import org.openapijsonschematools.paths.userlogin.get.parameters.parameter1.Schema1; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class QueryParameters { // nest classes so all schemas and input/output classes can be public @@ -20,20 +20,32 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class QueryParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class QueryParametersMap extends FrozenMap { + QueryParametersMap(FrozenMap m) { + super(m); + } + public static QueryParametersMap of(Map arg, SchemaConfiguration configuration) { + return QueryParameters1.validate(arg, configuration); + } + } + + public class QueryParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("password", Schema1.Schema11.class), new AbstractMap.SimpleEntry>("username", Schema0.Schema01.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "password", "username" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static QueryParametersMap getMapOutputInstance(FrozenMap arg) { + return new QueryParametersMap(arg); + } + public static QueryParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(QueryParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/responses/response200/Headers.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/responses/response200/Headers.java index 8383ed5411e..bcab32a7fab 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/responses/response200/Headers.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userlogin/get/responses/response200/Headers.java @@ -11,9 +11,9 @@ import org.openapijsonschematools.paths.userlogin.get.responses.response200.headers.xexpiresafter.XExpiresAfterSchema; import org.openapijsonschematools.paths.userlogin.get.responses.response200.headers.xratelimit.content.applicationjson.XRateLimitSchema; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class Headers { // nest classes so all schemas and input/output classes can be public @@ -23,24 +23,36 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class Headers1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class HeadersMap extends FrozenMap { + HeadersMap(FrozenMap m) { + super(m); + } + public static HeadersMap of(Map arg, SchemaConfiguration configuration) { + return Headers1.validate(arg, configuration); + } + } + + public class Headers1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("X-Rate-Limit", XRateLimitSchema.XRateLimitSchema1.class), new AbstractMap.SimpleEntry>("int32", Int32JsonContentTypeHeaderSchema.Int32JsonContentTypeHeaderSchema1.class), new AbstractMap.SimpleEntry>("X-Expires-After", XExpiresAfterSchema.XExpiresAfterSchema1.class), new AbstractMap.SimpleEntry>("ref-content-schema-header", StringWithValidation.StringWithValidation1.class), new AbstractMap.SimpleEntry>("numberHeader", NumberHeaderSchema.NumberHeaderSchema1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "X-Rate-Limit", "int32", "ref-content-schema-header" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static HeadersMap getMapOutputInstance(FrozenMap arg) { + return new HeadersMap(arg); + } + public static HeadersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(Headers1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/delete/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/delete/PathParameters.java index 1696bb6077d..64211c8a991 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/delete/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/delete/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.components.parameters.pathusername.Schema; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("username", Schema.Schema1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "username" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/get/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/get/PathParameters.java index a9ed723e411..c06c706e15e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/get/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/get/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.components.parameters.pathusername.Schema; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("username", Schema.Schema1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "username" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/put/PathParameters.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/put/PathParameters.java index 95f7a900260..d13a69e54f1 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/put/PathParameters.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/paths/userusername/put/PathParameters.java @@ -7,9 +7,9 @@ import org.openapijsonschematools.components.parameters.pathusername.Schema; import org.openapijsonschematools.configurations.SchemaConfiguration; import org.openapijsonschematools.schemas.AnyTypeJsonSchema; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.JsonSchema; import org.openapijsonschematools.schemas.NotAnyTypeJsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class PathParameters { // nest classes so all schemas and input/output classes can be public @@ -19,18 +19,30 @@ public class AdditionalProperties extends NotAnyTypeJsonSchema {} // NotAnyTypeSchema - public class PathParameters1 implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + public static class PathParametersMap extends FrozenMap { + PathParametersMap(FrozenMap m) { + super(m); + } + public static PathParametersMap of(Map arg, SchemaConfiguration configuration) { + return PathParameters1.validate(arg, configuration); + } + } + + public class PathParameters1 extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( new AbstractMap.SimpleEntry>("username", Schema.Schema1.class) )); - static final Set required = new LinkedHashSet<>(Set.of( + public static final Set required = new LinkedHashSet<>(Set.of( "username" )); static final Class additionalProperties = AdditionalProperties.class; - public static T validate(Map arg, SchemaConfiguration configuration) { + protected static PathParametersMap getMapOutputInstance(FrozenMap arg) { + return new PathParametersMap(arg); + } + public static PathParametersMap validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate(PathParameters1.class, arg, configuration); } } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/AnyTypeJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/AnyTypeJsonSchema.java index 2a4056fbd9f..a80bc88eebd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/AnyTypeJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/AnyTypeJsonSchema.java @@ -1,5 +1,8 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.FrozenList; import org.openapijsonschematools.configurations.SchemaConfiguration; import java.time.LocalDate; @@ -9,7 +12,7 @@ import java.util.UUID; -public class AnyTypeJsonSchema implements JsonSchema { +public class AnyTypeJsonSchema extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(AnyTypeJsonSchema.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/BooleanJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/BooleanJsonSchema.java index 6883d55bd6a..fff76397265 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/BooleanJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/BooleanJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class BooleanJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class BooleanJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Boolean.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateJsonSchema.java index 934ab7eeece..04ce824c1dd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateJsonSchema.java @@ -1,18 +1,15 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DateJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DateJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); static final String format = "date"; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateTimeJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateTimeJsonSchema.java index fb3379701cb..86cfabf49c4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateTimeJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DateTimeJsonSchema.java @@ -1,18 +1,15 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DateTimeJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DateTimeJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); static final String format = "date-time"; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DecimalJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DecimalJsonSchema.java index bfd46e52498..2eb9ad6d540 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DecimalJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DecimalJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DecimalJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DecimalJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); static final String format = "number"; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DoubleJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DoubleJsonSchema.java index 0c68c0162f6..da0a5778d38 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DoubleJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/DoubleJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DoubleJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DoubleJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Double.class )); static final String format = "double"; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FloatJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FloatJsonSchema.java index 6d1b12f12b7..36238eff721 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FloatJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FloatJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class FloatJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class FloatJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Float.class )); static final String format = "float"; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int32JsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int32JsonSchema.java index 61bb171c5cf..a2ecbe64a58 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int32JsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int32JsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class Int32JsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class Int32JsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Float.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int64JsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int64JsonSchema.java index 430f47b0f0f..69ab43c866f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int64JsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/Int64JsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class Int64JsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class Int64JsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/IntJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/IntJsonSchema.java index 91774856f15..375e62c7947 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/IntJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/IntJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class IntJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class IntJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Long.class )); static final String format = "int"; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/JsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/JsonSchema.java deleted file mode 100644 index 7955562a2d1..00000000000 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/JsonSchema.java +++ /dev/null @@ -1,237 +0,0 @@ -package org.openapijsonschematools.schemas; - -import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; -import org.openapijsonschematools.configurations.SchemaConfiguration; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -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; - -public interface JsonSchema extends SchemaValidator { - private static Object castToAllowedTypes(Object arg, List pathToItem, PathToTypeMap pathToType) { - if (arg == null) { - pathToType.put(pathToItem, Void.class); - return null; - } else if (arg instanceof String) { - pathToType.put(pathToItem, String.class); - return arg; - } else if (arg instanceof Map) { - pathToType.put(pathToItem, Map.class); - LinkedHashMap argFixed = new LinkedHashMap<>(); - for (Map.Entry entry: ((Map) arg).entrySet()) { - String key = (String) entry.getKey(); - Object val = entry.getValue(); - List newPathToItem = new ArrayList<>(pathToItem); - newPathToItem.add(key); - Object fixedVal = castToAllowedTypes(val, newPathToItem, pathToType); - argFixed.put(key, fixedVal); - } - return new FrozenMap<>(argFixed); - } else if (arg instanceof Boolean) { - pathToType.put(pathToItem, Boolean.class); - return arg; - } else if (arg instanceof Integer) { - pathToType.put(pathToItem, Integer.class); - return arg; - } else if (arg instanceof Long) { - pathToType.put(pathToItem, Long.class); - return arg; - } else if (arg instanceof Float) { - pathToType.put(pathToItem, Float.class); - return arg; - } else if (arg instanceof Double) { - pathToType.put(pathToItem, Double.class); - return arg; - } else if (arg instanceof List) { - pathToType.put(pathToItem, FrozenList.class); - List argFixed = new ArrayList<>(); - int i =0; - for (Object item: ((List) arg).toArray()) { - List newPathToItem = new ArrayList<>(pathToItem); - newPathToItem.add(i); - Object fixedVal = castToAllowedTypes(item, newPathToItem, pathToType); - argFixed.add(fixedVal); - i += 1; - } - return new FrozenList<>(argFixed); - } else if (arg instanceof ZonedDateTime) { - pathToType.put(pathToItem, String.class); - return arg.toString(); - } else if (arg instanceof LocalDate) { - pathToType.put(pathToItem, String.class); - return arg.toString(); - } else if (arg instanceof UUID) { - pathToType.put(pathToItem, String.class); - return arg.toString(); - } else { - Class argClass = arg.getClass(); - throw new RuntimeException("Invalid type passed in got input="+arg+" type="+argClass); - } - } - - private static PathToSchemasMap getPathToSchemas(Class cls, Object arg, ValidationMetadata validationMetadata, PathToTypeMap pathToType) { - PathToSchemasMap pathToSchemasMap = new PathToSchemasMap(); - if (validationMetadata.validationRanEarlier(cls)) { - // todo add deeper validated schemas - } else { - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(cls, arg, validationMetadata); - pathToSchemasMap.update(otherPathToSchemas); - for (LinkedHashMap, Void> schemas: pathToSchemasMap.values()) { - Class firstSchema = schemas.entrySet().iterator().next().getKey(); - schemas.clear(); - schemas.put(firstSchema, null); - } - Set> missingPaths = new HashSet<>(pathToType.keySet()); - missingPaths.removeAll(pathToSchemasMap.keySet()); - if (!missingPaths.isEmpty()) { - LinkedHashMap, Void> unsetAnyTypeSchema = new LinkedHashMap<>(); - unsetAnyTypeSchema.put(UnsetAnyTypeJsonSchema.class, null); - for (List pathToItem: missingPaths) { - pathToSchemasMap.put(pathToItem, unsetAnyTypeSchema); - } - } - } - return pathToSchemasMap; - } - - private static FrozenMap getProperties(Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { - LinkedHashMap properties = new LinkedHashMap<>(); - Map castArg = (Map) arg; - for(Map.Entry entry: castArg.entrySet()) { - String propertyName = entry.getKey(); - List propertyPathToItem = new ArrayList<>(pathToItem); - propertyPathToItem.add(propertyName); - Class propertyClass = (Class) pathToSchemas.get(propertyPathToItem).entrySet().iterator().next().getKey(); - Object value = entry.getValue(); - Object castValue = getNewInstance(propertyClass, value, propertyPathToItem, pathToSchemas); - properties.put(propertyName, castValue); - } - return new FrozenMap<>(properties); - } - - private static FrozenList getItems(Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { - ArrayList items = new ArrayList<>(); - List castItems = (List) arg; - int i = 0; - for (Object item: castItems) { - List itemPathToItem = new ArrayList<>(pathToItem); - itemPathToItem.add(i); - Class itemClass = (Class) pathToSchemas.get(itemPathToItem).entrySet().iterator().next().getKey(); - Object castItem = getNewInstance(itemClass, item, itemPathToItem, pathToSchemas); - items.add(castItem); - i += 1; - } - return new FrozenList<>(items); - } - - private static Object getNewInstance(Class cls, Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { - if (!(arg instanceof Map || arg instanceof List)) { - // str, int, float, boolean, null, FileIO, bytes - return arg; - } - if (arg instanceof Map) { - FrozenMap usedArg = getProperties(arg, pathToItem, pathToSchemas); - try { - Method method = cls.getMethod("getMapOutputInstance", FrozenMap.class); - return method.invoke(null, usedArg); - } catch (NoSuchMethodException e) { - return usedArg; - } catch (InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } else if (arg instanceof List) { - FrozenList usedArg = getItems(arg, pathToItem, pathToSchemas); - try { - Method method = cls.getMethod("getListOutputInstance", FrozenList.class); - return method.invoke(null, usedArg); - } catch (NoSuchMethodException e) { - return usedArg; - } catch (InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return null; - } - - static Void validate(Class cls, Void arg, SchemaConfiguration configuration) { - return (Void) validateObject(cls, arg, configuration); - } - - static Boolean validate(Class cls, Boolean arg, SchemaConfiguration configuration) { - return (Boolean) validateObject(cls, arg, configuration); - } - - static Integer validate(Class cls, Integer arg, SchemaConfiguration configuration) { - return (Integer) validateObject(cls, arg, configuration); - } - - static Long validate(Class cls, Long arg, SchemaConfiguration configuration) { - return (Long) validateObject(cls, arg, configuration); - } - - static Float validate(Class cls, Float arg, SchemaConfiguration configuration) { - return (Float) validateObject(cls, arg, configuration); - } - - static Double validate(Class cls, Double arg, SchemaConfiguration configuration) { - return (Double) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, String arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, ZonedDateTime arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, LocalDate arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, UUID arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static T validate(Class cls, Map arg, SchemaConfiguration configuration) { - return (T) validateObject(cls, arg, configuration); - } - - static U validate(Class cls, List arg, SchemaConfiguration configuration) { - return (U) validateObject(cls, arg, configuration); - } - - // todo add bytes and FileIO - - private static Object validateObject(Class cls, Object arg, SchemaConfiguration configuration) { - Class castCls = (Class) cls; - if (arg instanceof Map || arg instanceof List) { - // todo don't run validation if the instance is one of the class generic types - } - PathToTypeMap pathToType = new PathToTypeMap(); - List pathToItem = new ArrayList<>(); - pathToItem.add("args[0]"); - Object castArg = castToAllowedTypes(arg, pathToItem, pathToType); - 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(castCls, castArg, validationMetadata, pathToType); - return getNewInstance(castCls, castArg, validationMetadata.pathToItem(), pathToSchemasMap); - } - -} \ No newline at end of file diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/JsonSchemas.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/JsonSchemas.java deleted file mode 100644 index 9d49ced698d..00000000000 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/JsonSchemas.java +++ /dev/null @@ -1,320 +0,0 @@ -package org.openapijsonschematools.schemas; - -import org.openapijsonschematools.configurations.SchemaConfiguration; - -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -public class JsonSchemas { - // holds all standard json schema types - - public class AnyTypeSchema implements JsonSchema { - public static Void validate(Void arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static Boolean validate(Boolean arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static Integer validate(Integer arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static Long validate(Long arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static Float validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static Double validate(Double arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static String validate(ZonedDateTime arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static String validate(LocalDate arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static T validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - - public static U validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(AnyTypeSchema.class, arg, configuration); - } - } - public class BooleanSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Boolean.class - )); - - public static Boolean validate(Boolean arg, SchemaConfiguration configuration) { - return JsonSchema.validate(BooleanSchema.class, arg, configuration); - } - } - public class DateSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - String.class - )); - static final String format = "date"; - - public static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(DateSchema.class, arg, configuration); - } - - public static String validate(LocalDate arg, SchemaConfiguration configuration) { - return JsonSchema.validate(DateSchema.class, arg, configuration); - } - } - public class DateTimeSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - String.class - )); - static final String format = "date-time"; - - public static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(DateTimeSchema.class, arg, configuration); - } - - public static String validate(ZonedDateTime arg, SchemaConfiguration configuration) { - return JsonSchema.validate(DateTimeSchema.class, arg, configuration); - } - } - public class DecimalSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - String.class - )); - static final String format = "number"; - - public static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(DecimalSchema.class, arg, configuration); - } - } - public class DoubleSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Double.class - )); - static final String format = "double"; - - public static Double validate(Double arg, SchemaConfiguration configuration) { - return JsonSchema.validate(DoubleSchema.class, arg, configuration); - } - } - public class FloatSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Float.class - )); - static final String format = "float"; - - public static Float validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(FloatSchema.class, arg, configuration); - } - } - public class Int32Schema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Integer.class, - Float.class - )); - static final String format = "int32"; - - public static Integer validate(Integer arg, SchemaConfiguration configuration) { - return JsonSchema.validate(Int32Schema.class, arg, configuration); - } - - public static Integer validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(Int32Schema.class, Integer.parseInt(arg.toString()), configuration); - } - } - public class Int64Schema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Integer.class, - Long.class, - Float.class, - Double.class - )); - static final String format = "int64"; - - public static Long validate(Integer arg, SchemaConfiguration configuration) { - return JsonSchema.validate(Int64Schema.class, Long.valueOf(arg), configuration); - } - - public static Long validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(Int64Schema.class, Long.parseLong(arg.toString()), configuration); - } - - public static Long validate(Long arg, SchemaConfiguration configuration) { - return JsonSchema.validate(Int64Schema.class, arg, configuration); - } - - public static Long validate(Double arg, SchemaConfiguration configuration) { - return JsonSchema.validate(Int64Schema.class, Long.parseLong(arg.toString()), configuration); - } - } - public class IntSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Long.class - )); - static final String format = "int"; - - public static Long validate(Integer arg, SchemaConfiguration configuration) { - return JsonSchema.validate(IntSchema.class, Long.valueOf(arg), configuration); - } - - public static Long validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(IntSchema.class, Long.parseLong(arg.toString()), configuration); - } - - public static Long validate(Long arg, SchemaConfiguration configuration) { - return JsonSchema.validate(IntSchema.class, arg, configuration); - } - - public static Long validate(Double arg, SchemaConfiguration configuration) { - return JsonSchema.validate(IntSchema.class, Long.parseLong(arg.toString()), configuration); - } - } - public class ListSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenList.class - )); - - public static FrozenList validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ListSchema.class, arg, configuration); - } - } - public class MapSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(MapSchema.class, arg, configuration); - } - } - public class NotAnyTypeSchema implements JsonSchema { - // todo add not definition here when that validator is added - } - public class NullSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Void.class - )); - - public static Void validate(Void arg, SchemaConfiguration configuration) { - return JsonSchema.validate(NullSchema.class, arg, configuration); - } - } - public class NumberSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - Integer.class, - Long.class, - Float.class, - Double.class - )); - - public static Number validate(Integer arg, SchemaConfiguration configuration) { - return JsonSchema.validate(NumberSchema.class, arg, configuration); - } - - public static Number validate(Long arg, SchemaConfiguration configuration) { - return JsonSchema.validate(NumberSchema.class, arg, configuration); - } - - public static Number validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(NumberSchema.class, arg, configuration); - } - - public static Number validate(Double arg, SchemaConfiguration configuration) { - return JsonSchema.validate(NumberSchema.class, arg, configuration); - } - } - public class StringSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - String.class - )); - - public static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(StringSchema.class, arg, configuration); - } - - public static String validate(ZonedDateTime arg, SchemaConfiguration configuration) { - return JsonSchema.validate(StringSchema.class, arg, configuration); - } - - public static String validate(LocalDate arg, SchemaConfiguration configuration) { - return JsonSchema.validate(StringSchema.class, arg, configuration); - } - } - public class UnsetAnyTypeSchema implements JsonSchema { - static Void validate(Void arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static Boolean validate(Boolean arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static Integer validate(Integer arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - public static Long validate(Long arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static Float validate(Float arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static Double validate(Double arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static String validate(ZonedDateTime arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static String validate(LocalDate arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static T validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - - static U validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UnsetAnyTypeSchema.class, arg, configuration); - } - } - public class UuidSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - String.class - )); - static final String format = "uuid"; - - public static String validate(String arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UuidSchema.class, arg, configuration); - } - - public static String validate(UUID arg, SchemaConfiguration configuration) { - return JsonSchema.validate(UuidSchema.class, arg, configuration); - } - } -} \ No newline at end of file diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ListJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ListJsonSchema.java index a5201ca34cb..948f7e64ffa 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ListJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ListJsonSchema.java @@ -1,18 +1,16 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class ListJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class ListJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/MapJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/MapJsonSchema.java index 473569422e8..ec2957339bf 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/MapJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/MapJsonSchema.java @@ -1,18 +1,16 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.FrozenMap; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; import java.util.Map; import java.util.Set; -import java.util.UUID; -public class MapJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class MapJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NotAnyTypeJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NotAnyTypeJsonSchema.java index af5421ee45b..941b782d4bd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NotAnyTypeJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NotAnyTypeJsonSchema.java @@ -1,16 +1,8 @@ package org.openapijsonschematools.schemas; -import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -public class NotAnyTypeJsonSchema implements JsonSchema { +public class NotAnyTypeJsonSchema extends JsonSchema { // todo add not definition here when that validator is added } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NullJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NullJsonSchema.java index 9b8d83c59ad..b13589dec8e 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NullJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NullJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class NullJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class NullJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NumberJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NumberJsonSchema.java index 27fb90f9163..9bfe0895db5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NumberJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/NumberJsonSchema.java @@ -1,18 +1,14 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class NumberJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class NumberJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/SchemaValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/SchemaValidator.java deleted file mode 100644 index 3a1c4b54561..00000000000 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/SchemaValidator.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.openapijsonschematools.schemas; - -import org.openapijsonschematools.schemas.validators.AdditionalPropertiesValidator; -import org.openapijsonschematools.schemas.validators.FakeValidator; -import org.openapijsonschematools.schemas.validators.FormatValidator; -import org.openapijsonschematools.schemas.validators.ItemsValidator; -import org.openapijsonschematools.schemas.validators.KeywordValidator; -import org.openapijsonschematools.schemas.validators.PropertiesValidator; -import org.openapijsonschematools.schemas.validators.RequiredValidator; -import org.openapijsonschematools.schemas.validators.TypeValidator; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public interface SchemaValidator { - static HashMap keywordToValidator = new HashMap(){{ - put("allOf", new FakeValidator()); - put("anyOf", new FakeValidator()); - put("const", new FakeValidator()); - put("contains", new FakeValidator()); - put("default", new FakeValidator()); - put("dependentRequired", new FakeValidator()); - put("dependentSchemas", new FakeValidator()); - put("discriminator", new FakeValidator()); - put("enumInfo", new FakeValidator()); - put("exclusiveMinimum", new FakeValidator()); - put("exclusiveMinimum", new FakeValidator()); - put("format", new FormatValidator()); - put("if_", new FakeValidator()); - put("then", new FakeValidator()); - put("else_", new FakeValidator()); - put("maxContains", new FakeValidator()); - put("maxItems", new FakeValidator()); - put("maxLength", new FakeValidator()); - put("maxProperties", new FakeValidator()); - put("maximum", new FakeValidator()); - put("minContains", new FakeValidator()); - put("minItems", new FakeValidator()); - put("minLength", new FakeValidator()); - put("minProperties", new FakeValidator()); - put("minimum", new FakeValidator()); - put("multipleOf", new FakeValidator()); - put("not", new FakeValidator()); - put("oneOf", new FakeValidator()); - put("pattern", new FakeValidator()); - put("patternProperties", new FakeValidator()); - put("prefixItems", new FakeValidator()); - put("required", new RequiredValidator()); - put("type", new TypeValidator()); - put("uniqueItems", new FakeValidator()); - put("items", new ItemsValidator()); - put("unevaluatedItems", new FakeValidator()); - put("properties", new PropertiesValidator()); - put("propertyNames", new FakeValidator()); - put("additionalProperties", new AdditionalPropertiesValidator()); - put("unevaluatedProperties", new FakeValidator()); - }}; - - static PathToSchemasMap validate( - Class schemaCls, - Object arg, - ValidationMetadata validationMetadata - ) { - HashMap fieldsToValues = new HashMap<>(); - LinkedHashSet disabledKeywords = validationMetadata.configuration().disabledKeywordFlags().getKeywords(); - Class usedSchemaCls = schemaCls; - if (schemaCls.getSuperclass() != Object.class) { - // only ref with no adjacent properties supported at this time - usedSchemaCls = schemaCls.getSuperclass(); - } - Field[] fields = usedSchemaCls.getDeclaredFields(); - for (Field field : fields) { - String fieldName = field.getName(); - if (fieldName.equals("keywordToValidator")) { - continue; - } - if (fieldName.equals("this$0")) { - continue; - } - if (disabledKeywords.contains(fieldName)) { - continue; - } - try { - Object value = field.get(null); - fieldsToValues.put(fieldName, value); - } catch (IllegalAccessException | IllegalArgumentException e) { - throw new RuntimeException(e); - } - } - Object extra = null; - PathToSchemasMap pathToSchemas = new PathToSchemasMap(); - Class castSchemaCls = (Class) schemaCls; - for (Map.Entry entry: fieldsToValues.entrySet()) { - String jsonKeyword = entry.getKey(); - Object constraint = entry.getValue(); - if (jsonKeyword.equals("additionalProperties") && fieldsToValues.containsKey("properties")) { - extra = fieldsToValues.get("properties"); - } - KeywordValidator validatorClass = keywordToValidator.get(jsonKeyword); - PathToSchemasMap otherPathToSchemas = validatorClass.validate( - castSchemaCls, - arg, - constraint, - validationMetadata, - extra - ); - if (otherPathToSchemas == null) { - continue; - } - pathToSchemas.update(otherPathToSchemas); - } - Class baseClass; - if (arg == null) { - baseClass = Void.class; - } else { - baseClass = arg.getClass(); - } - List pathToItem = validationMetadata.pathToItem(); - if (!pathToSchemas.containsKey(pathToItem)) { - pathToSchemas.put(validationMetadata.pathToItem(), new LinkedHashMap<>()); - } - pathToSchemas.get(pathToItem).put(baseClass, null); - pathToSchemas.get(pathToItem).put(schemaCls, null); - - return pathToSchemas; - } -} -/** - * @classmethod - * def _validate( - * cls, - * arg, - * validation_metadata: ValidationMetadata, - * ) -> PathToSchemasType: - * """ - * SchemaValidator validate - * All keyword validation except for type checking was done in calling stack frames - * If those validations passed, the validated classes are collected in path_to_schemas - * """ - * cls_schema = cls() - * json_schema_data = { - * k: v - * for k, v in vars(cls_schema).items() - * if k not in cls.__excluded_cls_properties - * and k - * not in validation_metadata.configuration.disabled_json_schema_python_keywords - * } - * contains_path_to_schemas = [] - * path_to_schemas: PathToSchemasType = {} - * if 'contains' in vars(cls_schema): - * contains_path_to_schemas = _get_contains_path_to_schemas( - * arg, - * vars(cls_schema)['contains'], - * validation_metadata, - * path_to_schemas - * ) - * if_path_to_schemas = None - * if 'if_' in vars(cls_schema): - * if_path_to_schemas = _get_if_path_to_schemas( - * arg, - * vars(cls_schema)['if_'], - * validation_metadata, - * ) - * validated_pattern_properties: typing.Optional[PathToSchemasType] = None - * if 'pattern_properties' in vars(cls_schema): - * validated_pattern_properties = _get_validated_pattern_properties( - * arg, - * vars(cls_schema)['pattern_properties'], - * cls, - * validation_metadata - * ) - * prefix_items_length = 0 - * if 'prefix_items' in vars(cls_schema): - * prefix_items_length = len(vars(cls_schema)['prefix_items']) - * for keyword, val in json_schema_data.items(): - * used_val: typing.Any - * if keyword in {'contains', 'min_contains', 'max_contains'}: - * used_val = (val, contains_path_to_schemas) - * elif keyword == 'items': - * used_val = (val, prefix_items_length) - * elif keyword in {'unevaluated_items', 'unevaluated_properties'}: - * used_val = (val, path_to_schemas) - * elif keyword in {'types'}: - * format: typing.Optional[str] = vars(cls_schema).get('format', None) - * used_val = (val, format) - * elif keyword in {'pattern_properties', 'additional_properties'}: - * used_val = (val, validated_pattern_properties) - * elif keyword in {'if_', 'then', 'else_'}: - * used_val = (val, if_path_to_schemas) - * else: - * used_val = val - * validator = json_schema_keyword_to_validator[keyword] - * - * other_path_to_schemas = validator( - * arg, - * used_val, - * cls, - * validation_metadata, - * - * ) - * if other_path_to_schemas: - * update(path_to_schemas, other_path_to_schemas) - * - * base_class = type(arg) - * if validation_metadata.path_to_item not in path_to_schemas: - * path_to_schemas[validation_metadata.path_to_item] = dict() - * path_to_schemas[validation_metadata.path_to_item][base_class] = None - * path_to_schemas[validation_metadata.path_to_item][cls] = None - * return path_to_schemas - */ diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/StringJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/StringJsonSchema.java index 96e0881b46c..ef82a27a9bd 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/StringJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/StringJsonSchema.java @@ -1,18 +1,17 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; import java.time.LocalDate; import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; -public class StringJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class StringJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UuidJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UuidJsonSchema.java index d3e55278ddc..de4a9fa02b4 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UuidJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UuidJsonSchema.java @@ -1,21 +1,18 @@ package org.openapijsonschematools.schemas; +import org.openapijsonschematools.schemas.validation.JsonSchema; import org.openapijsonschematools.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; -public class UuidJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class UuidJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "uuid"; + public static final String format = "uuid"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(UuidJsonSchema.class, arg, configuration); diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidator.java similarity index 75% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidator.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidator.java index e510d21a591..1335d4863be 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidator.java @@ -1,9 +1,4 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.JsonSchema; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -14,7 +9,7 @@ public class AdditionalPropertiesValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof Map)) { return null; } @@ -42,7 +37,7 @@ public PathToSchemasMap validate(Class cls, Object arg, Object // todo add_deeper_validated_schemas continue; } - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(addPropSchema, propValue, propValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(addPropSchema, propValue, propValidationMetadata); pathToSchemas.update(otherPathToSchemas); } return pathToSchemas; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/CustomIsoparser.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/CustomIsoparser.java similarity index 84% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/CustomIsoparser.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/CustomIsoparser.java index 620b2364a0f..b61e057c9ef 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/CustomIsoparser.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/CustomIsoparser.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import java.time.ZonedDateTime; import java.time.LocalDate; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FakeValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FakeValidator.java new file mode 100644 index 00000000000..c1b1658c07b --- /dev/null +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FakeValidator.java @@ -0,0 +1,8 @@ +package org.openapijsonschematools.schemas.validation; + +public class FakeValidator implements KeywordValidator { + @Override + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + return null; + } +} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/FormatValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FormatValidator.java similarity index 93% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/FormatValidator.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FormatValidator.java index e9b44b8fd61..d57115f6c12 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/FormatValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FormatValidator.java @@ -1,9 +1,4 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.CustomIsoparser; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.math.BigDecimal; import java.math.BigInteger; @@ -138,7 +133,7 @@ private Void validateStringFormat(String arg, String format, ValidationMetadata } @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { String format = (String) constraint; if (arg instanceof Number) { validateNumericFormat( diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FrozenList.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FrozenList.java similarity index 95% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FrozenList.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FrozenList.java index e9a203d2088..81c09bf1123 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FrozenList.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FrozenList.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import java.util.ArrayList; import java.util.Collection; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FrozenMap.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FrozenMap.java similarity index 97% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FrozenMap.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FrozenMap.java index 38d03e7ad3b..1076e74f08c 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/FrozenMap.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/FrozenMap.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import java.util.LinkedHashMap; import java.util.Map; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/ItemsValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/ItemsValidator.java similarity index 68% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/ItemsValidator.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/ItemsValidator.java index 35b86dfc63d..34f220b40ea 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/ItemsValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/ItemsValidator.java @@ -1,16 +1,11 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.JsonSchema; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.util.ArrayList; import java.util.List; public class ItemsValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof List)) { return null; } @@ -33,7 +28,7 @@ public PathToSchemasMap validate(Class cls, Object arg, Object i +=1; continue; } - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(itemsSchema, itemValue, itemValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, itemValue, itemValidationMetadata); pathToSchemas.update(otherPathToSchemas); i += 1; } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/JsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/JsonSchema.java new file mode 100644 index 00000000000..817f0496d0b --- /dev/null +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/JsonSchema.java @@ -0,0 +1,343 @@ +package org.openapijsonschematools.schemas.validation; + +import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; +import org.openapijsonschematools.configurations.SchemaConfiguration; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.HashMap; +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; + +public abstract class JsonSchema { + static HashMap keywordToValidator = new HashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry("allOf", new FakeValidator()), + new AbstractMap.SimpleEntry("anyOf", new FakeValidator()), + new AbstractMap.SimpleEntry("const", new FakeValidator()), + new AbstractMap.SimpleEntry("contains", new FakeValidator()), + new AbstractMap.SimpleEntry("default", new FakeValidator()), + new AbstractMap.SimpleEntry("dependentRequired", new FakeValidator()), + new AbstractMap.SimpleEntry("dependentSchemas", new FakeValidator()), + new AbstractMap.SimpleEntry("discriminator", new FakeValidator()), + new AbstractMap.SimpleEntry("enumInfo", new FakeValidator()), + new AbstractMap.SimpleEntry("exclusiveMaximum", new FakeValidator()), + new AbstractMap.SimpleEntry("exclusiveMinimum", new FakeValidator()), + new AbstractMap.SimpleEntry("format", new FormatValidator()), + new AbstractMap.SimpleEntry("if_", new FakeValidator()), + new AbstractMap.SimpleEntry("then", new FakeValidator()), + new AbstractMap.SimpleEntry("else_", new FakeValidator()), + new AbstractMap.SimpleEntry("maxContains", new FakeValidator()), + new AbstractMap.SimpleEntry("maxItems", new FakeValidator()), + new AbstractMap.SimpleEntry("maxLength", new FakeValidator()), + new AbstractMap.SimpleEntry("maxProperties", new FakeValidator()), + new AbstractMap.SimpleEntry("maximum", new FakeValidator()), + new AbstractMap.SimpleEntry("minContains", new FakeValidator()), + new AbstractMap.SimpleEntry("minItems", new FakeValidator()), + new AbstractMap.SimpleEntry("minLength", new FakeValidator()), + new AbstractMap.SimpleEntry("minProperties", new FakeValidator()), + new AbstractMap.SimpleEntry("minimum", new FakeValidator()), + new AbstractMap.SimpleEntry("multipleOf", new FakeValidator()), + new AbstractMap.SimpleEntry("not", new FakeValidator()), + new AbstractMap.SimpleEntry("oneOf", new FakeValidator()), + new AbstractMap.SimpleEntry("pattern", new FakeValidator()), + new AbstractMap.SimpleEntry("patternProperties", new FakeValidator()), + new AbstractMap.SimpleEntry("prefixItems", new FakeValidator()), + new AbstractMap.SimpleEntry("required", new RequiredValidator()), + new AbstractMap.SimpleEntry("type", new TypeValidator()), + new AbstractMap.SimpleEntry("uniqueItems", new FakeValidator()), + new AbstractMap.SimpleEntry("items", new ItemsValidator()), + new AbstractMap.SimpleEntry("unevaluatedItems", new FakeValidator()), + new AbstractMap.SimpleEntry("properties", new PropertiesValidator()), + new AbstractMap.SimpleEntry("propertyNames", new FakeValidator()), + new AbstractMap.SimpleEntry("additionalProperties", new AdditionalPropertiesValidator()), + new AbstractMap.SimpleEntry("unevaluatedProperties", new FakeValidator()) + )); + + protected static PathToSchemasMap validate( + Class schemaCls, + Object arg, + ValidationMetadata validationMetadata + ) { + HashMap fieldsToValues = new HashMap<>(); + LinkedHashSet disabledKeywords = validationMetadata.configuration().disabledKeywordFlags().getKeywords(); + Class usedSchemaCls = schemaCls; + Class superclass = schemaCls.getSuperclass(); + if (superclass != JsonSchema.class) { + // only ref with no adjacent properties supported at this time + usedSchemaCls = (Class) superclass; + } + Field[] fields = usedSchemaCls.getDeclaredFields(); + for (Field field : fields) { + String fieldName = field.getName(); + if (fieldName.equals("keywordToValidator")) { + continue; + } + if (fieldName.equals("this$0")) { + continue; + } + if (disabledKeywords.contains(fieldName)) { + continue; + } + try { + Object value = field.get(null); + fieldsToValues.put(fieldName, value); + } catch (IllegalAccessException | IllegalArgumentException e) { + throw new RuntimeException(e); + } + } + Object extra = null; + PathToSchemasMap pathToSchemas = new PathToSchemasMap(); + for (Map.Entry entry: fieldsToValues.entrySet()) { + String jsonKeyword = entry.getKey(); + Object constraint = entry.getValue(); + if (jsonKeyword.equals("additionalProperties") && fieldsToValues.containsKey("properties")) { + extra = fieldsToValues.get("properties"); + } + KeywordValidator validatorClass = keywordToValidator.get(jsonKeyword); + PathToSchemasMap otherPathToSchemas = validatorClass.validate( + schemaCls, + arg, + constraint, + validationMetadata, + extra + ); + if (otherPathToSchemas == null) { + continue; + } + pathToSchemas.update(otherPathToSchemas); + } + List pathToItem = validationMetadata.pathToItem(); + if (!pathToSchemas.containsKey(pathToItem)) { + pathToSchemas.put(validationMetadata.pathToItem(), new LinkedHashMap<>()); + } + pathToSchemas.get(pathToItem).put(schemaCls, null); + + return pathToSchemas; + } + + private static Object castToAllowedTypes(Object arg, List pathToItem, Set> pathSet) { + if (arg == null) { + pathSet.add(pathToItem); + return null; + } else if (arg instanceof String) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Map) { + pathSet.add(pathToItem); + LinkedHashMap argFixed = new LinkedHashMap<>(); + for (Map.Entry entry: ((Map) arg).entrySet()) { + String key = (String) entry.getKey(); + Object val = entry.getValue(); + List newPathToItem = new ArrayList<>(pathToItem); + newPathToItem.add(key); + Object fixedVal = castToAllowedTypes(val, newPathToItem, pathSet); + argFixed.put(key, fixedVal); + } + return new FrozenMap<>(argFixed); + } else if (arg instanceof Boolean) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Integer) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Long) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Float) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Double) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof List) { + pathSet.add(pathToItem); + List argFixed = new ArrayList<>(); + int i =0; + for (Object item: ((List) arg).toArray()) { + List newPathToItem = new ArrayList<>(pathToItem); + newPathToItem.add(i); + Object fixedVal = castToAllowedTypes(item, newPathToItem, pathSet); + argFixed.add(fixedVal); + i += 1; + } + return new FrozenList<>(argFixed); + } else if (arg instanceof ZonedDateTime) { + pathSet.add(pathToItem); + return arg.toString(); + } else if (arg instanceof LocalDate) { + pathSet.add(pathToItem); + return arg.toString(); + } else if (arg instanceof UUID) { + pathSet.add(pathToItem); + return arg.toString(); + } else { + Class argClass = arg.getClass(); + throw new RuntimeException("Invalid type passed in got input="+arg+" type="+argClass); + } + } + + private static PathToSchemasMap getPathToSchemas(Class cls, Object arg, ValidationMetadata validationMetadata, Set> pathSet) { + PathToSchemasMap pathToSchemasMap = new PathToSchemasMap(); + if (validationMetadata.validationRanEarlier(cls)) { + // todo add deeper validated schemas + } else { + PathToSchemasMap otherPathToSchemas = validate(cls, arg, validationMetadata); + pathToSchemasMap.update(otherPathToSchemas); + for (LinkedHashMap, Void> schemas: pathToSchemasMap.values()) { + Class firstSchema = schemas.entrySet().iterator().next().getKey(); + schemas.clear(); + schemas.put(firstSchema, null); + } + Set> missingPaths = pathSet; + missingPaths.removeAll(pathToSchemasMap.keySet()); + if (!missingPaths.isEmpty()) { + LinkedHashMap, Void> unsetAnyTypeSchema = new LinkedHashMap<>(); + unsetAnyTypeSchema.put(UnsetAnyTypeJsonSchema.class, null); + for (List pathToItem: missingPaths) { + pathToSchemasMap.put(pathToItem, unsetAnyTypeSchema); + } + } + } + return pathToSchemasMap; + } + + private static FrozenMap getProperties(Map arg, List pathToItem, PathToSchemasMap pathToSchemas) { + LinkedHashMap properties = new LinkedHashMap<>(); + for(Map.Entry entry: arg.entrySet()) { + String propertyName = (String) entry.getKey(); + List propertyPathToItem = new ArrayList<>(pathToItem); + propertyPathToItem.add(propertyName); + Class propertyClass = pathToSchemas.get(propertyPathToItem).entrySet().iterator().next().getKey(); + Object value = entry.getValue(); + Object castValue = getNewInstance(propertyClass, value, propertyPathToItem, pathToSchemas); + properties.put(propertyName, castValue); + } + return new FrozenMap<>(properties); + } + + private static FrozenList getItems(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + ArrayList items = new ArrayList<>(); + int i = 0; + for (Object item: arg) { + List itemPathToItem = new ArrayList<>(pathToItem); + itemPathToItem.add(i); + Class itemClass = pathToSchemas.get(itemPathToItem).entrySet().iterator().next().getKey(); + Object castItem = getNewInstance(itemClass, item, itemPathToItem, pathToSchemas); + items.add(castItem); + i += 1; + } + return new FrozenList<>(items); + } + + private static Object getNewInstance(Class cls, Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { + if (arg instanceof Map) { + FrozenMap usedArg = getProperties((Map) arg, pathToItem, pathToSchemas); + try { + Method method = cls.getDeclaredMethod("getMapOutputInstance", FrozenMap.class); + // needed because this is a protected method, but it is across packages + method.setAccessible(true); + return method.invoke(null, usedArg); + } catch (NoSuchMethodException e) { + return usedArg; + } catch (InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } else if (arg instanceof List) { + FrozenList usedArg = getItems((List) arg, pathToItem, pathToSchemas); + try { + Method method = cls.getDeclaredMethod("getListOutputInstance", FrozenList.class); + // needed because this is a protected method, but it is across packages + method.setAccessible(true); + return method.invoke(null, usedArg); + } catch (NoSuchMethodException e) { + return usedArg; + } catch (InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + // str, int, float, boolean, null, FileIO, bytes + return arg; + } + + protected static Void validate(Class cls, Void arg, SchemaConfiguration configuration) { + return (Void) validateObject(cls, arg, configuration); + } + + protected static Boolean validate(Class cls, Boolean arg, SchemaConfiguration configuration) { + return (Boolean) validateObject(cls, arg, configuration); + } + + protected static Integer validate(Class cls, Integer arg, SchemaConfiguration configuration) { + return (Integer) validateObject(cls, arg, configuration); + } + + protected static Long validate(Class cls, Long arg, SchemaConfiguration configuration) { + return (Long) validateObject(cls, arg, configuration); + } + + protected static Float validate(Class cls, Float arg, SchemaConfiguration configuration) { + return (Float) validateObject(cls, arg, configuration); + } + + protected static Double validate(Class cls, Double arg, SchemaConfiguration configuration) { + return (Double) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, String arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, ZonedDateTime arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, LocalDate arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, UUID arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static T validate(Class cls, Map arg, SchemaConfiguration configuration) { + return (T) validateObject(cls, arg, configuration); + } + + protected static U validate(Class cls, List arg, SchemaConfiguration configuration) { + return (U) validateObject(cls, arg, configuration); + } + + // todo add bytes and FileIO + + public static Object validateObject(Class cls, Object arg, SchemaConfiguration configuration) { + if (arg instanceof Map || arg instanceof List) { + // todo don't run validation if the instance is one of the class generic types + } + Set> pathSet = new HashSet(); + List pathToItem = new ArrayList<>(); + pathToItem.add("args[0]"); + Object 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(cls, castArg, validationMetadata, pathSet); + return getNewInstance(cls, castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + +} \ No newline at end of file diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/KeywordValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/KeywordValidator.java new file mode 100644 index 00000000000..e50f737b559 --- /dev/null +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/KeywordValidator.java @@ -0,0 +1,10 @@ +package org.openapijsonschematools.schemas.validation; + +public interface KeywordValidator { + PathToSchemasMap validate( + Class cls, + Object arg, + Object constraint, + ValidationMetadata validationMetadata, + Object extra); +} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/PathToSchemasMap.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PathToSchemasMap.java similarity index 58% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/PathToSchemasMap.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PathToSchemasMap.java index 9c9b9465998..ff038c2605b 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/PathToSchemasMap.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PathToSchemasMap.java @@ -1,15 +1,15 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public class PathToSchemasMap extends LinkedHashMap, LinkedHashMap, Void>> { +public class PathToSchemasMap extends LinkedHashMap, LinkedHashMap, Void>> { public void update(PathToSchemasMap other) { - for (Map.Entry, LinkedHashMap, Void>> entry: other.entrySet()) { + for (Map.Entry, LinkedHashMap, Void>> entry: other.entrySet()) { List pathToItem = entry.getKey(); - LinkedHashMap, Void> otherSchemas = entry.getValue(); + LinkedHashMap, Void> otherSchemas = entry.getValue(); if (containsKey(pathToItem)) { get(pathToItem).putAll(otherSchemas); } else { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/PathToTypeMap.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PathToTypeMap.java similarity index 72% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/PathToTypeMap.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PathToTypeMap.java index 9aba997ddaa..512f30e8052 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/PathToTypeMap.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PathToTypeMap.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import java.util.HashMap; import java.util.List; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/PropertiesValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PropertiesValidator.java similarity index 72% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/PropertiesValidator.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PropertiesValidator.java index e376bae076d..9f3f672323f 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/PropertiesValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/PropertiesValidator.java @@ -1,9 +1,4 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.JsonSchema; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -13,7 +8,7 @@ public class PropertiesValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof Map)) { return null; } @@ -37,7 +32,7 @@ public PathToSchemasMap validate(Class cls, Object arg, Object // todo add_deeper_validated_schemas continue; } - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(propSchema, propValue, propValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(propSchema, propValue, propValidationMetadata); pathToSchemas.update(otherPathToSchemas); } return pathToSchemas; diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/RequiredValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/RequiredValidator.java similarity index 72% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/RequiredValidator.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/RequiredValidator.java index 2aff713169b..a91638d9b21 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/RequiredValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/RequiredValidator.java @@ -1,8 +1,4 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.util.HashSet; import java.util.List; @@ -11,7 +7,7 @@ public class RequiredValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof Map)) { return null; } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/TypeValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/TypeValidator.java similarity index 54% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/TypeValidator.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/TypeValidator.java index de00d1459e4..20c4e899585 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/TypeValidator.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/TypeValidator.java @@ -1,14 +1,10 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.util.HashSet; public class TypeValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { HashSet> types = (HashSet>) constraint; Class argClass; if (arg == null) { diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UnsetAnyTypeJsonSchema.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/UnsetAnyTypeJsonSchema.java similarity index 95% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UnsetAnyTypeJsonSchema.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/UnsetAnyTypeJsonSchema.java index 0eb8458c6a9..e7ab09d8b80 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/UnsetAnyTypeJsonSchema.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/UnsetAnyTypeJsonSchema.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import org.openapijsonschematools.configurations.SchemaConfiguration; @@ -11,7 +11,7 @@ import java.util.UUID; -public class UnsetAnyTypeJsonSchema implements JsonSchema { +public class UnsetAnyTypeJsonSchema extends JsonSchema { static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(UnsetAnyTypeJsonSchema.class, arg, configuration); } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ValidationMetadata.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/ValidationMetadata.java similarity index 68% rename from samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ValidationMetadata.java rename to samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/ValidationMetadata.java index d15f5daa8ec..2ee4adaa3d5 100644 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/ValidationMetadata.java +++ b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validation/ValidationMetadata.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import org.openapijsonschematools.configurations.SchemaConfiguration; import java.util.List; @@ -12,8 +12,8 @@ public record ValidationMetadata( Set> seenClasses ) { - public boolean validationRanEarlier(Class cls) { - Map, Void> validatedSchemas = validatedPathToSchemas.getOrDefault(pathToItem, null); + public boolean validationRanEarlier(Class cls) { + Map, Void> validatedSchemas = validatedPathToSchemas.getOrDefault(pathToItem, null); if (validatedSchemas != null && validatedSchemas.containsKey(cls)) { return true; } diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/FakeValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/FakeValidator.java deleted file mode 100644 index c0010c0d90f..00000000000 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/FakeValidator.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; - -public class FakeValidator implements KeywordValidator { - @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { - return null; - } -} diff --git a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/KeywordValidator.java b/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/KeywordValidator.java deleted file mode 100644 index 73ca6e76c81..00000000000 --- a/samples/client/petstore/java/src/main/java/org/openapijsonschematools/schemas/validators/KeywordValidator.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; - -public interface KeywordValidator { - PathToSchemasMap validate( - Class cls, - Object arg, - Object constraint, - ValidationMetadata validationMetadata, - Object extra); -} diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/AnyTypeSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/AnyTypeSchemaTest.java index b5439521248..5fea1aebe6d 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/AnyTypeSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/AnyTypeSchemaTest.java @@ -4,6 +4,9 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.FrozenList; +import org.openapijsonschematools.schemas.validation.FrozenMap; + import java.time.LocalDate; import java.time.ZoneId; diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ArrayTypeSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ArrayTypeSchemaTest.java index 85453b94cd4..89e4fdac7a2 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ArrayTypeSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ArrayTypeSchemaTest.java @@ -4,54 +4,57 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -class ArrayWithItemsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenList.class - )); - static final Class items = StringJsonSchema.class; - public static FrozenList validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ArrayWithItemsSchema.class, arg, configuration); - } -} +public class ArrayTypeSchemaTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); -class ArrayWithOutputClsSchemaList extends FrozenList { - ArrayWithOutputClsSchemaList(FrozenList m) { - super(m); - } + public class ArrayWithItemsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenList.class + )); + public static final Class items = StringJsonSchema.class; - public static ArrayWithOutputClsSchemaList of(List arg, SchemaConfiguration configuration) { - return ArrayWithOutputClsSchema.validate(arg, configuration); + public static FrozenList validate(List arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ArrayWithItemsSchema.class, arg, configuration); + } } -} -class ArrayWithOutputClsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenList.class - )); - static final Class items = StringJsonSchema.class; + public static class ArrayWithOutputClsSchemaList extends FrozenList { + ArrayWithOutputClsSchemaList(FrozenList m) { + super(m); + } - public static ArrayWithOutputClsSchemaList getListOutputInstance(FrozenList arg) { - return new ArrayWithOutputClsSchemaList(arg); + public static ArrayWithOutputClsSchemaList of(List arg, SchemaConfiguration configuration) { + return ArrayWithOutputClsSchema.validate(arg, configuration); + } } - public static ArrayWithOutputClsSchemaList validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ArrayWithOutputClsSchema.class, arg, configuration); - } -} + public class ArrayWithOutputClsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenList.class + )); + public static final Class items = StringJsonSchema.class; -public class ArrayTypeSchemaTest { - static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); + protected static ArrayWithOutputClsSchemaList getListOutputInstance(FrozenList arg) { + return new ArrayWithOutputClsSchemaList(arg); + } + + public static ArrayWithOutputClsSchemaList validate(List arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ArrayWithOutputClsSchema.class, arg, configuration); + } + } @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( ArrayWithItemsSchema.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/BooleanSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/BooleanSchemaTest.java index 3b1fe8d0cf6..d1ab1fc8e71 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/BooleanSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/BooleanSchemaTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class BooleanSchemaTest { static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); @@ -22,7 +23,7 @@ public void testValidateFalse() { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( BooleanJsonSchema.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ListSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ListSchemaTest.java index 0f11f91a2ad..ee04c1bf160 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ListSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ListSchemaTest.java @@ -4,6 +4,8 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenList; import java.util.ArrayList; import java.util.List; @@ -13,7 +15,7 @@ public class ListSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( ListJsonSchema.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/MapSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/MapSchemaTest.java index 5cbdaae0e07..2d64caaad27 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/MapSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/MapSchemaTest.java @@ -4,6 +4,8 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; import java.time.LocalDate; import java.util.LinkedHashMap; @@ -14,7 +16,7 @@ public class MapSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( MapJsonSchema.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NullSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NullSchemaTest.java index 2799dcb8ffd..828fe23c5af 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NullSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NullSchemaTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; public class NullSchemaTest { static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); @@ -16,7 +17,7 @@ public void testValidateNull() { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( NullJsonSchema.class, Boolean.TRUE, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NumberSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NumberSchemaTest.java index 8fd2597e2e4..edbbfa34d15 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NumberSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/NumberSchemaTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; import java.math.BigDecimal; @@ -36,7 +37,7 @@ public void testValidateDouble() { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( NumberJsonSchema.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ObjectTypeSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ObjectTypeSchemaTest.java index a7d1ead5f95..94d654fa6a3 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ObjectTypeSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/ObjectTypeSchemaTest.java @@ -4,6 +4,8 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; +import org.openapijsonschematools.schemas.validation.FrozenMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -11,78 +13,79 @@ import java.util.Map; import java.util.Set; -class ObjectWithPropsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) - )); - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithPropsSchema.class, arg, configuration); - } -} +public class ObjectTypeSchemaTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); -class ObjectWithAddpropsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final Class additionalProperties = StringJsonSchema.class; + public class ObjectWithPropsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) + )); - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithAddpropsSchema.class, arg, configuration); + public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithPropsSchema.class, arg, configuration); + } } -} -class ObjectWithPropsAndAddpropsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) - )); - static final Class additionalProperties = BooleanJsonSchema.class; - - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithPropsAndAddpropsSchema.class, arg, configuration); + public class ObjectWithAddpropsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final Class additionalProperties = StringJsonSchema.class; + + public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithAddpropsSchema.class, arg, configuration); + } } -} -class ObjectWithOutputTypeSchemaMap extends FrozenMap { - ObjectWithOutputTypeSchemaMap(FrozenMap m) { - super(m); + public class ObjectWithPropsAndAddpropsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) + )); + public static final Class additionalProperties = BooleanJsonSchema.class; + + public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithPropsAndAddpropsSchema.class, arg, configuration); + } } - public static ObjectWithOutputTypeSchemaMap of(Map arg, SchemaConfiguration configuration) { - return ObjectWithOutputTypeSchema.validate(arg, configuration); + public static class ObjectWithOutputTypeSchemaMap extends FrozenMap { + ObjectWithOutputTypeSchemaMap(FrozenMap m) { + super(m); + } + + public static ObjectWithOutputTypeSchemaMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithOutputTypeSchema.validate(arg, configuration); + } } -} -class ObjectWithOutputTypeSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) - )); + public class ObjectWithOutputTypeSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) + )); - public static ObjectWithOutputTypeSchemaMap getMapOutputInstance(FrozenMap arg) { - return new ObjectWithOutputTypeSchemaMap(arg); - } + protected static ObjectWithOutputTypeSchemaMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithOutputTypeSchemaMap(arg); + } - public static ObjectWithOutputTypeSchemaMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithOutputTypeSchema.class, arg, configuration); + public static ObjectWithOutputTypeSchemaMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithOutputTypeSchema.class, arg, configuration); + } } -} - -public class ObjectTypeSchemaTest { - static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( ObjectWithPropsSchema.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/RefBooleanSchemaTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/RefBooleanSchemaTest.java index 2990402f87d..3f3dcdf5e1e 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/RefBooleanSchemaTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/RefBooleanSchemaTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; +import org.openapijsonschematools.schemas.validation.JsonSchema; class RefBooleanSchema { public class RefBooleanSchema1 extends BooleanJsonSchema{} @@ -26,7 +27,7 @@ public void testValidateFalse() { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( RefBooleanSchema.RefBooleanSchema1.class, (Void) null, configuration )); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidatorTest.java similarity index 87% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidatorTest.java index 743d71bb7a4..4b7df25f6e0 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/AdditionalPropertiesValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/AdditionalPropertiesValidatorTest.java @@ -1,14 +1,10 @@ -package org.openapijsonschematools.schemas.validators; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; import org.openapijsonschematools.schemas.StringJsonSchema; -import org.openapijsonschematools.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -37,7 +33,7 @@ public void testCorrectPropertySucceeds() { FrozenMap arg = new FrozenMap<>(mutableMap); final AdditionalPropertiesValidator validator = new AdditionalPropertiesValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, @@ -46,8 +42,7 @@ public void testCorrectPropertySucceeds() { List expectedPathToItem = new ArrayList<>(); expectedPathToItem.add("args[0]"); expectedPathToItem.add("someAddProp"); - LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); - expectedClasses.put(String.class, null); + LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); expectedClasses.put(StringJsonSchema.class, null); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); expectedPathToSchemas.put(expectedPathToItem, expectedClasses); @@ -66,7 +61,7 @@ public void testNotApplicableTypeReturnsNull() { ); final AdditionalPropertiesValidator validator = new AdditionalPropertiesValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, StringJsonSchema.class, validationMetadata, @@ -94,7 +89,7 @@ public void testIncorrectPropertyValueFails() { FrozenMap arg = new FrozenMap<>(mutableMap); final AdditionalPropertiesValidator validator = new AdditionalPropertiesValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/CustomIsoparserTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/CustomIsoparserTest.java similarity index 93% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/CustomIsoparserTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/CustomIsoparserTest.java index ac475c05ab6..5247e85cad9 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/CustomIsoparserTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/CustomIsoparserTest.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import java.time.LocalDate; import java.time.ZonedDateTime; diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/FormatValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/FormatValidatorTest.java similarity index 88% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/FormatValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/FormatValidatorTest.java index 1c651e6172a..c23c4a82e89 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/FormatValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/FormatValidatorTest.java @@ -1,12 +1,9 @@ -package org.openapijsonschematools.schemas.validators; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; import java.math.BigDecimal; import java.math.BigInteger; @@ -25,7 +22,7 @@ public class FormatValidatorTest { public void testIntFormatSucceedsWithFloat() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1.0f, "int", validationMetadata, @@ -38,7 +35,7 @@ public void testIntFormatSucceedsWithFloat() { public void testIntFormatFailsWithFloat() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 3.14f, "int", validationMetadata, @@ -50,7 +47,7 @@ public void testIntFormatFailsWithFloat() { public void testIntFormatSucceedsWithInt() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, "int", validationMetadata, @@ -63,7 +60,7 @@ public void testIntFormatSucceedsWithInt() { public void testInt32UnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, -2147483649L, "int32", validationMetadata, @@ -75,7 +72,7 @@ public void testInt32UnderMinFails() { public void testInt32InclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -2147483648, "int32", validationMetadata, @@ -88,7 +85,7 @@ public void testInt32InclusiveMinSucceeds() { public void testInt32InclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 2147483647, "int32", validationMetadata, @@ -101,7 +98,7 @@ public void testInt32InclusiveMaxSucceeds() { public void testInt32OverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 2147483648L, "int32", validationMetadata, @@ -114,7 +111,7 @@ public void testInt64UnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigInteger("-9223372036854775809"), "int64", validationMetadata, @@ -126,7 +123,7 @@ public void testInt64UnderMinFails() { public void testInt64InclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -9223372036854775808L, "int64", validationMetadata, @@ -139,7 +136,7 @@ public void testInt64InclusiveMinSucceeds() { public void testInt64InclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 9223372036854775807L, "int64", validationMetadata, @@ -153,7 +150,7 @@ public void testInt64OverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigInteger("9223372036854775808"), "int64", validationMetadata, @@ -165,7 +162,7 @@ public void testInt64OverMaxFails() { public void testFloatUnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, -3.402823466385289e+38d, "float", validationMetadata, @@ -177,7 +174,7 @@ public void testFloatUnderMinFails() { public void testFloatInclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -3.4028234663852886e+38f, "float", validationMetadata, @@ -190,7 +187,7 @@ public void testFloatInclusiveMinSucceeds() { public void testFloatInclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 3.4028234663852886e+38f, "float", validationMetadata, @@ -203,7 +200,7 @@ public void testFloatInclusiveMaxSucceeds() { public void testFloatOverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 3.402823466385289e+38d, "float", validationMetadata, @@ -215,7 +212,7 @@ public void testFloatOverMaxFails() { public void testDoubleUnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigDecimal("-1.7976931348623157082e+308"), "double", validationMetadata, @@ -227,7 +224,7 @@ public void testDoubleUnderMinFails() { public void testDoubleInclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -1.7976931348623157E+308d, "double", validationMetadata, @@ -240,7 +237,7 @@ public void testDoubleInclusiveMinSucceeds() { public void testDoubleInclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1.7976931348623157E+308d, "double", validationMetadata, @@ -253,7 +250,7 @@ public void testDoubleInclusiveMaxSucceeds() { public void testDoubleOverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigDecimal("1.7976931348623157082e+308"), "double", validationMetadata, @@ -265,7 +262,7 @@ public void testDoubleOverMaxFails() { public void testInvalidNumberStringFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, "abc", "number", validationMetadata, @@ -277,7 +274,7 @@ public void testInvalidNumberStringFails() { public void testValidFloatNumberStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "3.14", "number", validationMetadata, @@ -290,7 +287,7 @@ public void testValidFloatNumberStringSucceeds() { public void testValidIntNumberStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "1", "number", validationMetadata, @@ -303,7 +300,7 @@ public void testValidIntNumberStringSucceeds() { public void testInvalidDateStringFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, "abc", "date", validationMetadata, @@ -315,7 +312,7 @@ public void testInvalidDateStringFails() { public void testValidDateStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "2017-01-20", "date", validationMetadata, @@ -328,7 +325,7 @@ public void testValidDateStringSucceeds() { public void testInvalidDateTimeStringFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, "abc", "date-time", validationMetadata, @@ -340,7 +337,7 @@ public void testInvalidDateTimeStringFails() { public void testValidDateTimeStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "2017-07-21T17:32:28Z", "date-time", validationMetadata, diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/ItemsValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/ItemsValidatorTest.java similarity index 85% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/ItemsValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/ItemsValidatorTest.java index ab85495cac9..01affa9489a 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/ItemsValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/ItemsValidatorTest.java @@ -1,14 +1,10 @@ -package org.openapijsonschematools.schemas.validators; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenList; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; import org.openapijsonschematools.schemas.StringJsonSchema; -import org.openapijsonschematools.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -32,7 +28,7 @@ public void testCorrectItemsSucceeds() { FrozenList arg = new FrozenList<>(mutableList); final ItemsValidator validator = new ItemsValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, @@ -41,8 +37,7 @@ public void testCorrectItemsSucceeds() { List expectedPathToItem = new ArrayList<>(); expectedPathToItem.add("args[0]"); expectedPathToItem.add(0); - LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); - expectedClasses.put(String.class, null); + LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); expectedClasses.put(StringJsonSchema.class, null); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); expectedPathToSchemas.put(expectedPathToItem, expectedClasses); @@ -61,7 +56,7 @@ public void testNotApplicableTypeReturnsNull() { ); final ItemsValidator validator = new ItemsValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, StringJsonSchema.class, validationMetadata, @@ -85,7 +80,7 @@ public void testIncorrectItemFails() { FrozenList arg = new FrozenList<>(mutableList); final ItemsValidator validator = new ItemsValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/SchemaValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/JsonSchemaTest.java similarity index 78% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/SchemaValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/JsonSchemaTest.java index 75bb2023e7c..10cfa07211a 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/SchemaValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/JsonSchemaTest.java @@ -1,4 +1,4 @@ -package org.openapijsonschematools.schemas; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; @@ -11,13 +11,13 @@ import java.util.List; import java.util.Set; -class SomeSchema implements SchemaValidator { +class SomeSchema extends JsonSchema { static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); } -public class SchemaValidatorTest { +public class JsonSchemaTest { @Test public void testValidateSucceeds() { @@ -29,15 +29,14 @@ public void testValidateSucceeds() { new PathToSchemasMap(), new LinkedHashSet<>() ); - PathToSchemasMap pathToSchemas = SchemaValidator.validate( + PathToSchemasMap pathToSchemas = JsonSchema.validate( SomeSchema.class, "hi", validationMetadata ); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); - LinkedHashMap, Void> validatedClasses = new LinkedHashMap<>(); + LinkedHashMap, Void> validatedClasses = new LinkedHashMap<>(); validatedClasses.put(SomeSchema.class, null); - validatedClasses.put(String.class, null); expectedPathToSchemas.put(pathToItem, validatedClasses); Assert.assertEquals(pathToSchemas, expectedPathToSchemas); } diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/PropertiesValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/PropertiesValidatorTest.java similarity index 87% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/PropertiesValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/PropertiesValidatorTest.java index c70c091c6e2..01e65f19489 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/PropertiesValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/PropertiesValidatorTest.java @@ -1,14 +1,10 @@ -package org.openapijsonschematools.schemas.validators; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; import org.openapijsonschematools.schemas.StringJsonSchema; -import org.openapijsonschematools.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -36,7 +32,7 @@ public void testCorrectPropertySucceeds() { mutableMap.put("someString", "abc"); FrozenMap arg = new FrozenMap<>(mutableMap); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, properties, validationMetadata, @@ -45,8 +41,7 @@ public void testCorrectPropertySucceeds() { List expectedPathToItem = new ArrayList<>(); expectedPathToItem.add("args[0]"); expectedPathToItem.add("someString"); - LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); - expectedClasses.put(String.class, null); + LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); expectedClasses.put(StringJsonSchema.class, null); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); expectedPathToSchemas.put(expectedPathToItem, expectedClasses); @@ -68,7 +63,7 @@ public void testNotApplicableTypeReturnsNull() { new LinkedHashSet<>() ); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, properties, validationMetadata, @@ -95,7 +90,7 @@ public void testIncorrectPropertyValueFails() { mutableMap.put("someString", 1); FrozenMap arg = new FrozenMap<>(mutableMap); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, properties, validationMetadata, diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/RequiredValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/RequiredValidatorTest.java similarity index 89% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/RequiredValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/RequiredValidatorTest.java index 0c008805a7c..8c1e0ced9b2 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/RequiredValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/RequiredValidatorTest.java @@ -1,14 +1,10 @@ -package org.openapijsonschematools.schemas.validators; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.FrozenMap; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; import org.openapijsonschematools.schemas.StringJsonSchema; -import org.openapijsonschematools.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -37,7 +33,7 @@ public void testCorrectPropertySucceeds() { FrozenMap arg = new FrozenMap<>(mutableMap); final RequiredValidator validator = new RequiredValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, requiredProperties, validationMetadata, @@ -61,7 +57,7 @@ public void testNotApplicableTypeReturnsNull() { ); final RequiredValidator validator = new RequiredValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, properties, validationMetadata, @@ -88,7 +84,7 @@ public void testIncorrectPropertyFails() { FrozenMap arg = new FrozenMap<>(mutableMap); final RequiredValidator validator = new RequiredValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, requiredProperties, validationMetadata, diff --git a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/TypeValidatorTest.java b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/TypeValidatorTest.java similarity index 84% rename from samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/TypeValidatorTest.java rename to samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/TypeValidatorTest.java index 0f4ce8862b2..c94a8e0a91d 100644 --- a/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validators/TypeValidatorTest.java +++ b/samples/client/petstore/java/src/test/java/org/openapijsonschematools/schemas/validation/TypeValidatorTest.java @@ -1,12 +1,9 @@ -package org.openapijsonschematools.schemas.validators; +package org.openapijsonschematools.schemas.validation; import org.junit.Assert; import org.junit.Test; import org.openapijsonschematools.configurations.JsonSchemaKeywordFlags; import org.openapijsonschematools.configurations.SchemaConfiguration; -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -25,7 +22,7 @@ public void testValidateSucceeds() { new LinkedHashSet<>() ); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "hi", value, validationMetadata, @@ -46,7 +43,7 @@ public void testValidateFailsIntIsNotString() throws RuntimeException { new LinkedHashSet<>() ); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, value, validationMetadata, diff --git a/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java b/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java index d6ce79d76b8..9f880cf726c 100644 --- a/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java +++ b/src/main/java/org/openapijsonschematools/codegen/generators/DefaultGenerator.java @@ -348,6 +348,8 @@ public class DefaultGenerator implements Generator { // from deeper schema defined locations protected boolean addSchemaImportsFromV3SpecLocations = false; protected boolean deepestRefSchemaImportNeeded = false; + protected String objectIOClassNamePiece = "Dict"; + protected String arrayIOClassNamePiece = "Tuple"; @Override public List cliOptions() { @@ -2424,28 +2426,28 @@ public CodegenSchema fromSchema(Schema p, String sourceJsonPath, String currentJ property.mapInputJsonPathPiece = getKey(currentName + "DictInput", "schemaProperty", sourceJsonPath); // even though the definition is the same, mapOutputJsonPathPiece needs to be different // so an implementing class can be written - property.mapOutputJsonPathPiece = getKey(currentName + "Dict", "schemaProperty", sourceJsonPath); + property.mapOutputJsonPathPiece = getKey(currentName + objectIOClassNamePiece, "schemaProperty", sourceJsonPath); } break; case "11": // optional + required property.mapInputJsonPathPiece = getKey(currentName + "DictInput", "schemaProperty", sourceJsonPath); - property.mapOutputJsonPathPiece = getKey(currentName + "Dict", "schemaProperty", sourceJsonPath); + property.mapOutputJsonPathPiece = getKey(currentName + objectIOClassNamePiece, "schemaProperty", sourceJsonPath); break; case "10": // only required property.mapInputJsonPathPiece = property.requiredProperties.jsonPathPiece(); - property.mapOutputJsonPathPiece = getKey(currentName + "Dict", "schemaProperty", sourceJsonPath); + property.mapOutputJsonPathPiece = getKey(currentName + objectIOClassNamePiece, "schemaProperty", sourceJsonPath); break; case "01": // only optional property.mapInputJsonPathPiece = property.optionalProperties.jsonPathPiece(); - property.mapOutputJsonPathPiece = getKey(currentName + "Dict", "schemaProperty", sourceJsonPath); + property.mapOutputJsonPathPiece = getKey(currentName + objectIOClassNamePiece, "schemaProperty", sourceJsonPath); break; } } if ((property.types == null || property.types.contains("array")) && sourceJsonPath != null && property.items != null) { - property.arrayOutputJsonPathPiece = getKey(currentName + "Tuple", "schemaProperty", sourceJsonPath); + property.arrayOutputJsonPathPiece = getKey(currentName + arrayIOClassNamePiece, "schemaProperty", sourceJsonPath); property.arrayInputJsonPathPiece = getKey(currentName + "TupleInput", "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 f5d1c1efb84..ab1680b9928 100644 --- a/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java +++ b/src/main/java/org/openapijsonschematools/codegen/generators/JavaClientGenerator.java @@ -178,6 +178,8 @@ public JavaClientGenerator() { // if another schema $refs a schema in a parameter, the json path // and generated module must have the same parameter index as the spec sortParamsByRequiredFlag = Boolean.FALSE; + objectIOClassNamePiece = "Map"; + arrayIOClassNamePiece = "List"; // TODO: Move GlobalFeature.ParameterizedServer to library: jersey after moving featureSet to generatorMetadata @@ -299,30 +301,21 @@ public void processOpts() { List schemaSupportingFiles = new ArrayList<>(); schemaSupportingFiles.add("AnyTypeJsonSchema"); schemaSupportingFiles.add("BooleanJsonSchema"); - schemaSupportingFiles.add("CustomIsoparser"); schemaSupportingFiles.add("DateJsonSchema"); schemaSupportingFiles.add("DateTimeJsonSchema"); schemaSupportingFiles.add("DecimalJsonSchema"); schemaSupportingFiles.add("DoubleJsonSchema"); schemaSupportingFiles.add("FloatJsonSchema"); - schemaSupportingFiles.add("FrozenList"); - schemaSupportingFiles.add("FrozenMap"); schemaSupportingFiles.add("Int32JsonSchema"); schemaSupportingFiles.add("Int64JsonSchema"); schemaSupportingFiles.add("IntJsonSchema"); - schemaSupportingFiles.add("JsonSchema"); schemaSupportingFiles.add("ListJsonSchema"); schemaSupportingFiles.add("MapJsonSchema"); schemaSupportingFiles.add("NotAnyTypeJsonSchema"); schemaSupportingFiles.add("NullJsonSchema"); schemaSupportingFiles.add("NumberJsonSchema"); - schemaSupportingFiles.add("PathToSchemasMap"); - schemaSupportingFiles.add("PathToTypeMap"); - schemaSupportingFiles.add("SchemaValidator"); schemaSupportingFiles.add("StringJsonSchema"); - schemaSupportingFiles.add("UnsetAnyTypeJsonSchema"); schemaSupportingFiles.add("UuidJsonSchema"); - schemaSupportingFiles.add("ValidationMetadata"); for (String schemaSupportingFile: schemaSupportingFiles) { supportingFiles.add(new SupportingFile( "src/main/java/org/openapitools/schemas/"+schemaSupportingFile+".hbs", @@ -334,14 +327,12 @@ public void processOpts() { schemaTestSupportingFiles.add("AnyTypeSchemaTest"); schemaTestSupportingFiles.add("ArrayTypeSchemaTest"); schemaTestSupportingFiles.add("BooleanSchemaTest"); - schemaTestSupportingFiles.add("CustomIsoparserTest"); schemaTestSupportingFiles.add("ListSchemaTest"); schemaTestSupportingFiles.add("MapSchemaTest"); schemaTestSupportingFiles.add("NullSchemaTest"); schemaTestSupportingFiles.add("NumberSchemaTest"); schemaTestSupportingFiles.add("ObjectTypeSchemaTest"); schemaTestSupportingFiles.add("RefBooleanSchemaTest"); - schemaTestSupportingFiles.add("SchemaValidatorTest"); for (String schemaTestSupportingFile: schemaTestSupportingFiles) { supportingFiles.add(new SupportingFile( "src/test/java/org/openapitools/schemas/"+schemaTestSupportingFile+".hbs", @@ -349,34 +340,43 @@ public void processOpts() { schemaTestSupportingFile + ".java")); } - // keyword validators + // validation List keywordValidatorFiles = new ArrayList<>(); keywordValidatorFiles.add("AdditionalPropertiesValidator"); + keywordValidatorFiles.add("CustomIsoparser"); keywordValidatorFiles.add("FakeValidator"); keywordValidatorFiles.add("FormatValidator"); + keywordValidatorFiles.add("FrozenList"); + keywordValidatorFiles.add("FrozenMap"); keywordValidatorFiles.add("ItemsValidator"); + keywordValidatorFiles.add("JsonSchema"); keywordValidatorFiles.add("KeywordValidator"); + keywordValidatorFiles.add("PathToSchemasMap"); keywordValidatorFiles.add("PropertiesValidator"); keywordValidatorFiles.add("RequiredValidator"); keywordValidatorFiles.add("TypeValidator"); + keywordValidatorFiles.add("UnsetAnyTypeJsonSchema"); + keywordValidatorFiles.add("ValidationMetadata"); for (String keywordValidatorFile: keywordValidatorFiles) { supportingFiles.add(new SupportingFile( - "src/main/java/org/openapitools/schemas/validators/"+keywordValidatorFile+".hbs", - packagePath() + File.separatorChar + "schemas" + File.separatorChar + "validators", + "src/main/java/org/openapitools/schemas/validation/"+keywordValidatorFile+".hbs", + packagePath() + File.separatorChar + "schemas" + File.separatorChar + "validation", keywordValidatorFile + ".java")); } // tests List keywordValidatorTestFiles = new ArrayList<>(); keywordValidatorTestFiles.add("AdditionalPropertiesValidatorTest"); + keywordValidatorTestFiles.add("CustomIsoparserTest"); keywordValidatorTestFiles.add("FormatValidatorTest"); keywordValidatorTestFiles.add("ItemsValidatorTest"); keywordValidatorTestFiles.add("PropertiesValidatorTest"); keywordValidatorTestFiles.add("RequiredValidatorTest"); keywordValidatorTestFiles.add("TypeValidatorTest"); + keywordValidatorTestFiles.add("JsonSchemaTest"); for (String keywordValidatorTestFile: keywordValidatorTestFiles) { supportingFiles.add(new SupportingFile( - "src/test/java/org/openapitools/schemas/validators/"+keywordValidatorTestFile+".hbs", - testPackagePath() + File.separatorChar + "schemas" + File.separatorChar + "validators", + "src/test/java/org/openapitools/schemas/validation/"+keywordValidatorTestFile+".hbs", + testPackagePath() + File.separatorChar + "schemas" + File.separatorChar + "validation", keywordValidatorTestFile + ".java")); } @@ -1178,8 +1178,7 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu if (schema.isSimpleBoolean()) { imports.add("import "+packageName + ".schemas.BooleanJsonSchema;"); } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); } @@ -1187,8 +1186,7 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu if (schema.isSimpleNull()) { imports.add("import "+packageName + ".schemas.NullJsonSchema;"); } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); } @@ -1202,8 +1200,7 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu imports.add("import "+packageName + ".schemas.Int64JsonSchema;"); } } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); } @@ -1221,8 +1218,7 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu imports.add("import "+packageName + ".schemas.DoubleJsonSchema;"); } } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); } @@ -1243,11 +1239,10 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu imports.add("import "+packageName + ".schemas.StringJsonSchema;"); } else if (schema.format.equals("binary")) { // todo implement this - imports.add("import "+packageName + ".schemas.JsonSchema;"); + imports.add("import "+packageName + ".schemas.validation.JsonSchema;"); } } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); addStringSchemaImports(imports, schema); @@ -1256,8 +1251,7 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu if (schema.isSimpleObject()) { imports.add("import "+packageName + ".schemas.MapJsonSchema;"); } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); addMapSchemaImports(imports, schema); @@ -1266,16 +1260,14 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu if (schema.isSimpleArray()) { imports.add("import "+packageName + ".schemas.ListJsonSchema;"); } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); addListSchemaImports(imports, schema); } } } else if (schema.types.size() > 1) { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.util.LinkedHashSet;"); imports.add("import java.util.Set;"); if (schema.types.contains("string")) { @@ -1297,14 +1289,13 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu } else if (schema.isSimpleAnyType()) { imports.add("import "+packageName + ".schemas.AnyTypeJsonSchema;"); } else { - imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); - imports.add("import "+packageName + ".schemas.JsonSchema;"); + addCustomSchemaImports(imports); imports.add("import java.time.LocalDate;"); imports.add("import java.time.ZonedDateTime;"); imports.add("import java.util.UUID;"); - imports.add("import "+packageName + ".schemas.FrozenList;"); + imports.add("import "+packageName + ".schemas.validation.FrozenList;"); imports.add("import java.util.List;"); - imports.add("import "+packageName + ".schemas.FrozenMap;"); + imports.add("import "+packageName + ".schemas.validation.FrozenMap;"); imports.add("import java.util.Map;"); if (schema.properties != null) { imports.add("import java.util.Map;"); @@ -1320,8 +1311,14 @@ public Set getImports(String sourceJsonPath, CodegenSchema schema, Featu return imports; } + private void addCustomSchemaImports(Set imports) { + imports.add("import "+packageName + ".configurations.SchemaConfiguration;"); + imports.add("import "+packageName + ".schemas.validation.JsonSchema;"); + } + + private void addMapSchemaImports(Set imports, CodegenSchema schema) { - imports.add("import "+packageName + ".schemas.FrozenMap;"); + imports.add("import "+packageName + ".schemas.validation.FrozenMap;"); imports.add("import java.util.Map;"); if (schema.properties != null) { imports.add("import java.util.Map;"); @@ -1335,7 +1332,7 @@ private void addMapSchemaImports(Set imports, CodegenSchema schema) { } private void addListSchemaImports(Set imports, CodegenSchema schema) { - imports.add("import "+packageName + ".schemas.FrozenList;"); + imports.add("import "+packageName + ".schemas.validation.FrozenList;"); imports.add("import java.util.List;"); } diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs index 39afcbf2a7e..606632694d8 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_anytypeOrMultitype.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_boolean.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_boolean.hbs index 7abebe6083a..80b70141089 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_boolean.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_boolean.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_list.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_list.hbs index a12bba28503..60bf91cadad 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_list.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_list.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. @@ -60,6 +60,9 @@ public class {{jsonPathPiece.camelCase}} implements JsonSchema { {{!> components/schemas/schema_cls/_unevaluated_items }} {{/if}} {{#if arrayOutputJsonPathPiece}} + protected static {{arrayOutputJsonPathPiece.camelCase}} getListOutputInstance(FrozenList arg) { + return new {{arrayOutputJsonPathPiece.camelCase}}(arg); + } {{/if}} {{> src/main/java/org/openapitools/components/schemas/SchemaClass/_validate }} } \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_map.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_map.hbs index 02dd9080963..0ccb872af47 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_map.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_map.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. @@ -69,6 +69,9 @@ public class {{jsonPathPiece.camelCase}} implements JsonSchema { {{!> components/schemas/schema_cls/_unevaluated_properties }} {{/if}} {{#if mapOutputJsonPathPiece}} + protected static {{mapOutputJsonPathPiece.camelCase}} getMapOutputInstance(FrozenMap arg) { + return new {{mapOutputJsonPathPiece.camelCase}}(arg); + } {{/if}} {{> src/main/java/org/openapitools/components/schemas/SchemaClass/_validate }} } diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_null.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_null.hbs index 7abebe6083a..80b70141089 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_null.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_null.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_number.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_number.hbs index d5a7f10bd00..83955e15e7f 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_number.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_number.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_string.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_string.hbs index f39b2b89d82..90198169dea 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_string.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_string.hbs @@ -1,6 +1,6 @@ -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if componentModule}} /* NOTE: This class is auto generated by OpenAPI JSON Schema Generator. diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_varEqualsClass.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_varEqualsClass.hbs index 665bfc69621..823ff8e2bba 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_varEqualsClass.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_Schema_varEqualsClass.hbs @@ -20,7 +20,7 @@ public class {{../jsonPathPiece.camelCase}} extends {{jsonPathPiece.camelCase}} {{/with}} {{/if}} {{else}} -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { {{#if refInfo.refModule}} {{#with getDeepestRef}} {{> src/main/java/org/openapitools/components/schemas/SchemaClass/_validate includeContainer=true }} @@ -63,7 +63,7 @@ public class {{../jsonPathPiece.camelCase}} extends UuidJsonSchema {} public class {{../jsonPathPiece.camelCase}} extends DecimalJsonSchema {} {{/eq}} {{#eq ../format "binary"}} -public class {{jsonPathPiece.camelCase}} implements JsonSchema { +public class {{jsonPathPiece.camelCase}} extends JsonSchema { // BinarySchema } {{/eq}} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_format.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_format.hbs index 84ae01c4845..ceaa896bf42 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_format.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_format.hbs @@ -1 +1 @@ -static final String format = "{{format}}"; +public static final String format = "{{format}}"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_items.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_items.hbs index 4b92f1b5cfc..5a9e62daa1f 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_items.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_items.hbs @@ -1,3 +1,3 @@ {{#with items}} -static final Class items = {{#if refInfo.refClass}}{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}}{{else}}{{jsonPathPiece.camelCase}}{{/if}}.class; +public static final Class items = {{#if refInfo.refClass}}{{#if refInfo.refModule}}{{refInfo.refModule}}.{{/if}}{{refInfo.refClass}}{{else}}{{jsonPathPiece.camelCase}}{{/if}}.class; {{/with}} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_properties.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_properties.hbs index 260d6311d17..cbe641c1a48 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_properties.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_properties.hbs @@ -1,4 +1,4 @@ -static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( +public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( {{#each properties}} {{#if refInfo.refClass}} {{#if refInfo.refModule}} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_required.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_required.hbs index b39cabf7fe9..cfbc89020f1 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_required.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_required.hbs @@ -1,4 +1,4 @@ -static final Set required = new LinkedHashSet<>(Set.of( +public static final Set required = new LinkedHashSet<>(Set.of( {{#each requiredProperties}} "{{{@key.original}}}"{{#unless @last}},{{/unless}} {{/each}} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_types.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_types.hbs index 6bbb8302270..143d04247e0 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_types.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_types.hbs @@ -1,5 +1,5 @@ {{#if types}} -static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( {{#each types}} {{#eq this "null"}} Void.class{{#unless @last}},{{/unless}} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_validate.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_validate.hbs index fb6c3d92b9f..a0970e25aaf 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_validate.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/SchemaClass/_validate.hbs @@ -6,14 +6,26 @@ public static Void validate(Void arg, SchemaConfiguration configuration) { } {{/eq}} {{#eq this "object"}} + {{#if ../mapOutputJsonPathPiece}} +public static {{../mapOutputJsonPathPiece.camelCase}} validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate({{#if includeContainer}}{{containerJsonPathPiece.camelCase}}.{{/if}}{{jsonPathPiece.camelCase}}.class, arg, configuration); +} + {{else}} public static T validate(Map arg, SchemaConfiguration configuration) { return JsonSchema.validate({{#if includeContainer}}{{containerJsonPathPiece.camelCase}}.{{/if}}{{jsonPathPiece.camelCase}}.class, arg, configuration); } + {{/if}} {{/eq}} {{#eq this "array"}} + {{#if ../arrayOutputJsonPathPiece}} +public static {{../arrayOutputJsonPathPiece.camelCase}} validate(List arg, SchemaConfiguration configuration) { + return JsonSchema.validate({{#if includeContainer}}{{containerJsonPathPiece.camelCase}}.{{/if}}{{jsonPathPiece.camelCase}}.class, arg, configuration); +} + {{else}} public static U validate(List arg, SchemaConfiguration configuration) { return JsonSchema.validate({{#if includeContainer}}{{containerJsonPathPiece.camelCase}}.{{/if}}{{jsonPathPiece.camelCase}}.class, arg, configuration); } + {{/if}} {{/eq}} {{#eq this "string" }} {{#eq ../format "binary"}} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/Schema_getSchemas.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/Schema_getSchemas.hbs index 82962a0748a..ac44ff975e4 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/Schema_getSchemas.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/Schema_getSchemas.hbs @@ -28,10 +28,10 @@ {{!> components/schemas/_object_input_type }} {{else}} {{#eq instanceType "propertiesOutputType" }} -{{!> components/schemas/_object_output_type }} +{{> src/main/java/org/openapitools/components/schemas/_objectOutputType }} {{else}} {{#eq instanceType "arrayOutputType" }} -{{!> components/schemas/_array_output_type }} +{{> src/main/java/org/openapitools/components/schemas/_arrayOutputType }} {{else}} {{#eq instanceType "arrayInputType" }} {{!> components/schemas/_array_input_type }} diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/_arrayOutputType.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/_arrayOutputType.hbs new file mode 100644 index 00000000000..ab04019b7bd --- /dev/null +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/_arrayOutputType.hbs @@ -0,0 +1,7 @@ + + +public static class {{arrayOutputJsonPathPiece.camelCase}} extends FrozenList<{{#with items}}{{!> components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="]):" }}{{/with}}Object> { + {{arrayOutputJsonPathPiece.camelCase}}(FrozenList m) { + super(m); + } +} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/org/openapitools/components/schemas/_objectOutputType.hbs b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/_objectOutputType.hbs new file mode 100644 index 00000000000..d56b3981ade --- /dev/null +++ b/src/main/resources/java/src/main/java/org/openapitools/components/schemas/_objectOutputType.hbs @@ -0,0 +1,35 @@ + + +{{#if mapValueSchema}} + {{#if mapValueSchema.refInfo.refClass}} +public static class {{mapOutputJsonPathPiece.camelCase}} extends FrozenMap components/schemas/types/schema_output_type mode="unprefixed" fullRefModule="" endChar="]):" }}{{/with}}Object> { + {{mapOutputJsonPathPiece.camelCase}}(FrozenMap m) { + super(m); + } + {{else}} +public static class {{mapOutputJsonPathPiece.camelCase}} extends FrozenMap components/schemas/types/schema_output_type mode="unprefixed" fullRefModule=null endChar="]):" }}{{/with}}Object> { + {{mapOutputJsonPathPiece.camelCase}}(FrozenMap m) { + super(m); + } + {{/if}} +{{else}} +public static class {{mapOutputJsonPathPiece.camelCase}} extends FrozenMap { + {{mapOutputJsonPathPiece.camelCase}}(FrozenMap m) { + super(m); + } +{{/if}} + {{#eq optionalProperties null}} + {{#eq requiredProperties null}} + {{#if additionalProperties}} + {{#if additionalProperties.isBooleanSchemaFalse}} + // map with no key value pairs + {{/if}} + {{/if}} + {{/eq}} + {{/eq}} + public static {{mapOutputJsonPathPiece.camelCase}} of(Map arg, SchemaConfiguration configuration) { + return {{jsonPathPiece.camelCase}}.validate(arg, configuration); + } + {{!> components/schemas/__new__ }} + {{!> components/schemas/_object_output_properties }} +} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/AnyTypeJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/AnyTypeJsonSchema.hbs index 40a520236d2..bcd8e32a5d5 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/AnyTypeJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/AnyTypeJsonSchema.hbs @@ -1,5 +1,8 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; +import {{{packageName}}}.schemas.validation.FrozenMap; +import {{{packageName}}}.schemas.validation.FrozenList; import {{{packageName}}}.configurations.SchemaConfiguration; import java.time.LocalDate; @@ -9,7 +12,7 @@ import java.util.Map; import java.util.UUID; -public class AnyTypeJsonSchema implements JsonSchema { +public class AnyTypeJsonSchema extends JsonSchema { public static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(AnyTypeJsonSchema.class, arg, configuration); } diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/BooleanJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/BooleanJsonSchema.hbs index 581eed4b0d6..dcd36d6f758 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/BooleanJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/BooleanJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class BooleanJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class BooleanJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Boolean.class )); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/DateJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/DateJsonSchema.hbs index 75012b484e5..bb488e303f9 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/DateJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/DateJsonSchema.hbs @@ -1,18 +1,15 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DateJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DateJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); static final String format = "date"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/DateTimeJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/DateTimeJsonSchema.hbs index 34cc27c2bb7..9b189f2a424 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/DateTimeJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/DateTimeJsonSchema.hbs @@ -1,18 +1,15 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DateTimeJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DateTimeJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); static final String format = "date-time"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/DecimalJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/DecimalJsonSchema.hbs index f07ddf9c801..a07a7299288 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/DecimalJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/DecimalJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DecimalJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DecimalJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); static final String format = "number"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/DoubleJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/DoubleJsonSchema.hbs index 74ef91b3556..41e8b40369c 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/DoubleJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/DoubleJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class DoubleJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class DoubleJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Double.class )); static final String format = "double"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/FloatJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/FloatJsonSchema.hbs index 997dca0af90..762a11b4bb6 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/FloatJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/FloatJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class FloatJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class FloatJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Float.class )); static final String format = "float"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/Int32JsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/Int32JsonSchema.hbs index 2accf4c4f78..dc7ca32f0e3 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/Int32JsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/Int32JsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class Int32JsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class Int32JsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Float.class )); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/Int64JsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/Int64JsonSchema.hbs index 46be64f7de3..a4e6f280c32 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/Int64JsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/Int64JsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class Int64JsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class Int64JsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/IntJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/IntJsonSchema.hbs index 91cc5920ce8..ee518b61b87 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/IntJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/IntJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class IntJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class IntJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Long.class )); static final String format = "int"; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/JsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/JsonSchema.hbs deleted file mode 100644 index 491256dd12e..00000000000 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/JsonSchema.hbs +++ /dev/null @@ -1,237 +0,0 @@ -package {{{packageName}}}.schemas; - -import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; -import {{{packageName}}}.configurations.SchemaConfiguration; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -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; - -public interface JsonSchema extends SchemaValidator { - private static Object castToAllowedTypes(Object arg, List pathToItem, PathToTypeMap pathToType) { - if (arg == null) { - pathToType.put(pathToItem, Void.class); - return null; - } else if (arg instanceof String) { - pathToType.put(pathToItem, String.class); - return arg; - } else if (arg instanceof Map) { - pathToType.put(pathToItem, Map.class); - LinkedHashMap argFixed = new LinkedHashMap<>(); - for (Map.Entry entry: ((Map) arg).entrySet()) { - String key = (String) entry.getKey(); - Object val = entry.getValue(); - List newPathToItem = new ArrayList<>(pathToItem); - newPathToItem.add(key); - Object fixedVal = castToAllowedTypes(val, newPathToItem, pathToType); - argFixed.put(key, fixedVal); - } - return new FrozenMap<>(argFixed); - } else if (arg instanceof Boolean) { - pathToType.put(pathToItem, Boolean.class); - return arg; - } else if (arg instanceof Integer) { - pathToType.put(pathToItem, Integer.class); - return arg; - } else if (arg instanceof Long) { - pathToType.put(pathToItem, Long.class); - return arg; - } else if (arg instanceof Float) { - pathToType.put(pathToItem, Float.class); - return arg; - } else if (arg instanceof Double) { - pathToType.put(pathToItem, Double.class); - return arg; - } else if (arg instanceof List) { - pathToType.put(pathToItem, FrozenList.class); - List argFixed = new ArrayList<>(); - int i =0; - for (Object item: ((List) arg).toArray()) { - List newPathToItem = new ArrayList<>(pathToItem); - newPathToItem.add(i); - Object fixedVal = castToAllowedTypes(item, newPathToItem, pathToType); - argFixed.add(fixedVal); - i += 1; - } - return new FrozenList<>(argFixed); - } else if (arg instanceof ZonedDateTime) { - pathToType.put(pathToItem, String.class); - return arg.toString(); - } else if (arg instanceof LocalDate) { - pathToType.put(pathToItem, String.class); - return arg.toString(); - } else if (arg instanceof UUID) { - pathToType.put(pathToItem, String.class); - return arg.toString(); - } else { - Class argClass = arg.getClass(); - throw new RuntimeException("Invalid type passed in got input="+arg+" type="+argClass); - } - } - - private static PathToSchemasMap getPathToSchemas(Class cls, Object arg, ValidationMetadata validationMetadata, PathToTypeMap pathToType) { - PathToSchemasMap pathToSchemasMap = new PathToSchemasMap(); - if (validationMetadata.validationRanEarlier(cls)) { - // todo add deeper validated schemas - } else { - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(cls, arg, validationMetadata); - pathToSchemasMap.update(otherPathToSchemas); - for (LinkedHashMap, Void> schemas: pathToSchemasMap.values()) { - Class firstSchema = schemas.entrySet().iterator().next().getKey(); - schemas.clear(); - schemas.put(firstSchema, null); - } - Set> missingPaths = new HashSet<>(pathToType.keySet()); - missingPaths.removeAll(pathToSchemasMap.keySet()); - if (!missingPaths.isEmpty()) { - LinkedHashMap, Void> unsetAnyTypeSchema = new LinkedHashMap<>(); - unsetAnyTypeSchema.put(UnsetAnyTypeJsonSchema.class, null); - for (List pathToItem: missingPaths) { - pathToSchemasMap.put(pathToItem, unsetAnyTypeSchema); - } - } - } - return pathToSchemasMap; - } - - private static FrozenMap getProperties(Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { - LinkedHashMap properties = new LinkedHashMap<>(); - Map castArg = (Map) arg; - for(Map.Entry entry: castArg.entrySet()) { - String propertyName = entry.getKey(); - List propertyPathToItem = new ArrayList<>(pathToItem); - propertyPathToItem.add(propertyName); - Class propertyClass = (Class) pathToSchemas.get(propertyPathToItem).entrySet().iterator().next().getKey(); - Object value = entry.getValue(); - Object castValue = getNewInstance(propertyClass, value, propertyPathToItem, pathToSchemas); - properties.put(propertyName, castValue); - } - return new FrozenMap<>(properties); - } - - private static FrozenList getItems(Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { - ArrayList items = new ArrayList<>(); - List castItems = (List) arg; - int i = 0; - for (Object item: castItems) { - List itemPathToItem = new ArrayList<>(pathToItem); - itemPathToItem.add(i); - Class itemClass = (Class) pathToSchemas.get(itemPathToItem).entrySet().iterator().next().getKey(); - Object castItem = getNewInstance(itemClass, item, itemPathToItem, pathToSchemas); - items.add(castItem); - i += 1; - } - return new FrozenList<>(items); - } - - private static Object getNewInstance(Class cls, Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { - if (!(arg instanceof Map || arg instanceof List)) { - // str, int, float, boolean, null, FileIO, bytes - return arg; - } - if (arg instanceof Map) { - FrozenMap usedArg = getProperties(arg, pathToItem, pathToSchemas); - try { - Method method = cls.getMethod("getMapOutputInstance", FrozenMap.class); - return method.invoke(null, usedArg); - } catch (NoSuchMethodException e) { - return usedArg; - } catch (InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } else if (arg instanceof List) { - FrozenList usedArg = getItems(arg, pathToItem, pathToSchemas); - try { - Method method = cls.getMethod("getListOutputInstance", FrozenList.class); - return method.invoke(null, usedArg); - } catch (NoSuchMethodException e) { - return usedArg; - } catch (InvocationTargetException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - return null; - } - - static Void validate(Class cls, Void arg, SchemaConfiguration configuration) { - return (Void) validateObject(cls, arg, configuration); - } - - static Boolean validate(Class cls, Boolean arg, SchemaConfiguration configuration) { - return (Boolean) validateObject(cls, arg, configuration); - } - - static Integer validate(Class cls, Integer arg, SchemaConfiguration configuration) { - return (Integer) validateObject(cls, arg, configuration); - } - - static Long validate(Class cls, Long arg, SchemaConfiguration configuration) { - return (Long) validateObject(cls, arg, configuration); - } - - static Float validate(Class cls, Float arg, SchemaConfiguration configuration) { - return (Float) validateObject(cls, arg, configuration); - } - - static Double validate(Class cls, Double arg, SchemaConfiguration configuration) { - return (Double) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, String arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, ZonedDateTime arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, LocalDate arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static String validate(Class cls, UUID arg, SchemaConfiguration configuration) { - return (String) validateObject(cls, arg, configuration); - } - - static T validate(Class cls, Map arg, SchemaConfiguration configuration) { - return (T) validateObject(cls, arg, configuration); - } - - static U validate(Class cls, List arg, SchemaConfiguration configuration) { - return (U) validateObject(cls, arg, configuration); - } - - // todo add bytes and FileIO - - private static Object validateObject(Class cls, Object arg, SchemaConfiguration configuration) { - Class castCls = (Class) cls; - if (arg instanceof Map || arg instanceof List) { - // todo don't run validation if the instance is one of the class generic types - } - PathToTypeMap pathToType = new PathToTypeMap(); - List pathToItem = new ArrayList<>(); - pathToItem.add("args[0]"); - Object castArg = castToAllowedTypes(arg, pathToItem, pathToType); - 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(castCls, castArg, validationMetadata, pathToType); - return getNewInstance(castCls, castArg, validationMetadata.pathToItem(), pathToSchemasMap); - } - -} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/ListJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/ListJsonSchema.hbs index 2b3e5f61866..71e577b15e5 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/ListJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/ListJsonSchema.hbs @@ -1,18 +1,16 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.FrozenList; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class ListJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class ListJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenList.class )); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/MapJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/MapJsonSchema.hbs index 27ffdaa972c..f4f4acff018 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/MapJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/MapJsonSchema.hbs @@ -1,18 +1,16 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.FrozenMap; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; import java.util.Map; import java.util.Set; -import java.util.UUID; -public class MapJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class MapJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( FrozenMap.class )); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/NotAnyTypeJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/NotAnyTypeJsonSchema.hbs index 7a32088c483..a9e3770250e 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/NotAnyTypeJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/NotAnyTypeJsonSchema.hbs @@ -1,16 +1,8 @@ package {{{packageName}}}.schemas; -import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; -import java.time.LocalDate; -import java.time.ZonedDateTime; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -public class NotAnyTypeJsonSchema implements JsonSchema { +public class NotAnyTypeJsonSchema extends JsonSchema { // todo add not definition here when that validator is added } diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/NullJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/NullJsonSchema.hbs index 46e02d13411..8da6cf651cf 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/NullJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/NullJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class NullJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class NullJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Void.class )); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/NumberJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/NumberJsonSchema.hbs index 155eded3129..07ffe7b26ae 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/NumberJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/NumberJsonSchema.hbs @@ -1,18 +1,14 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; -import java.util.UUID; -public class NumberJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class NumberJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( Integer.class, Long.class, Float.class, diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/PathToTypeMap.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/PathToTypeMap.hbs deleted file mode 100644 index d16c7f5fe9c..00000000000 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/PathToTypeMap.hbs +++ /dev/null @@ -1,8 +0,0 @@ -package {{{packageName}}}.schemas; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class PathToTypeMap extends HashMap, Class> { -} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/SchemaValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/SchemaValidator.hbs deleted file mode 100644 index e3d4c2c535b..00000000000 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/SchemaValidator.hbs +++ /dev/null @@ -1,216 +0,0 @@ -package {{{packageName}}}.schemas; - -import {{{packageName}}}.schemas.validators.AdditionalPropertiesValidator; -import {{{packageName}}}.schemas.validators.FakeValidator; -import {{{packageName}}}.schemas.validators.FormatValidator; -import {{{packageName}}}.schemas.validators.ItemsValidator; -import {{{packageName}}}.schemas.validators.KeywordValidator; -import {{{packageName}}}.schemas.validators.PropertiesValidator; -import {{{packageName}}}.schemas.validators.RequiredValidator; -import {{{packageName}}}.schemas.validators.TypeValidator; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -public interface SchemaValidator { - static HashMap keywordToValidator = new HashMap()\{{ - put("allOf", new FakeValidator()); - put("anyOf", new FakeValidator()); - put("const", new FakeValidator()); - put("contains", new FakeValidator()); - put("default", new FakeValidator()); - put("dependentRequired", new FakeValidator()); - put("dependentSchemas", new FakeValidator()); - put("discriminator", new FakeValidator()); - put("enumInfo", new FakeValidator()); - put("exclusiveMinimum", new FakeValidator()); - put("exclusiveMinimum", new FakeValidator()); - put("format", new FormatValidator()); - put("if_", new FakeValidator()); - put("then", new FakeValidator()); - put("else_", new FakeValidator()); - put("maxContains", new FakeValidator()); - put("maxItems", new FakeValidator()); - put("maxLength", new FakeValidator()); - put("maxProperties", new FakeValidator()); - put("maximum", new FakeValidator()); - put("minContains", new FakeValidator()); - put("minItems", new FakeValidator()); - put("minLength", new FakeValidator()); - put("minProperties", new FakeValidator()); - put("minimum", new FakeValidator()); - put("multipleOf", new FakeValidator()); - put("not", new FakeValidator()); - put("oneOf", new FakeValidator()); - put("pattern", new FakeValidator()); - put("patternProperties", new FakeValidator()); - put("prefixItems", new FakeValidator()); - put("required", new RequiredValidator()); - put("type", new TypeValidator()); - put("uniqueItems", new FakeValidator()); - put("items", new ItemsValidator()); - put("unevaluatedItems", new FakeValidator()); - put("properties", new PropertiesValidator()); - put("propertyNames", new FakeValidator()); - put("additionalProperties", new AdditionalPropertiesValidator()); - put("unevaluatedProperties", new FakeValidator()); - }}; - - static PathToSchemasMap validate( - Class schemaCls, - Object arg, - ValidationMetadata validationMetadata - ) { - HashMap fieldsToValues = new HashMap<>(); - LinkedHashSet disabledKeywords = validationMetadata.configuration().disabledKeywordFlags().getKeywords(); - Class usedSchemaCls = schemaCls; - if (schemaCls.getSuperclass() != Object.class) { - // only ref with no adjacent properties supported at this time - usedSchemaCls = schemaCls.getSuperclass(); - } - Field[] fields = usedSchemaCls.getDeclaredFields(); - for (Field field : fields) { - String fieldName = field.getName(); - if (fieldName.equals("keywordToValidator")) { - continue; - } - if (fieldName.equals("this$0")) { - continue; - } - if (disabledKeywords.contains(fieldName)) { - continue; - } - try { - Object value = field.get(null); - fieldsToValues.put(fieldName, value); - } catch (IllegalAccessException | IllegalArgumentException e) { - throw new RuntimeException(e); - } - } - Object extra = null; - PathToSchemasMap pathToSchemas = new PathToSchemasMap(); - Class castSchemaCls = (Class) schemaCls; - for (Map.Entry entry: fieldsToValues.entrySet()) { - String jsonKeyword = entry.getKey(); - Object constraint = entry.getValue(); - if (jsonKeyword.equals("additionalProperties") && fieldsToValues.containsKey("properties")) { - extra = fieldsToValues.get("properties"); - } - KeywordValidator validatorClass = keywordToValidator.get(jsonKeyword); - PathToSchemasMap otherPathToSchemas = validatorClass.validate( - castSchemaCls, - arg, - constraint, - validationMetadata, - extra - ); - if (otherPathToSchemas == null) { - continue; - } - pathToSchemas.update(otherPathToSchemas); - } - Class baseClass; - if (arg == null) { - baseClass = Void.class; - } else { - baseClass = arg.getClass(); - } - List pathToItem = validationMetadata.pathToItem(); - if (!pathToSchemas.containsKey(pathToItem)) { - pathToSchemas.put(validationMetadata.pathToItem(), new LinkedHashMap<>()); - } - pathToSchemas.get(pathToItem).put(baseClass, null); - pathToSchemas.get(pathToItem).put(schemaCls, null); - - return pathToSchemas; - } -} -/** - * @classmethod - * def _validate( - * cls, - * arg, - * validation_metadata: ValidationMetadata, - * ) -> PathToSchemasType: - * """ - * SchemaValidator validate - * All keyword validation except for type checking was done in calling stack frames - * If those validations passed, the validated classes are collected in path_to_schemas - * """ - * cls_schema = cls() - * json_schema_data = { - * k: v - * for k, v in vars(cls_schema).items() - * if k not in cls.__excluded_cls_properties - * and k - * not in validation_metadata.configuration.disabled_json_schema_python_keywords - * } - * contains_path_to_schemas = [] - * path_to_schemas: PathToSchemasType = {} - * if 'contains' in vars(cls_schema): - * contains_path_to_schemas = _get_contains_path_to_schemas( - * arg, - * vars(cls_schema)['contains'], - * validation_metadata, - * path_to_schemas - * ) - * if_path_to_schemas = None - * if 'if_' in vars(cls_schema): - * if_path_to_schemas = _get_if_path_to_schemas( - * arg, - * vars(cls_schema)['if_'], - * validation_metadata, - * ) - * validated_pattern_properties: typing.Optional[PathToSchemasType] = None - * if 'pattern_properties' in vars(cls_schema): - * validated_pattern_properties = _get_validated_pattern_properties( - * arg, - * vars(cls_schema)['pattern_properties'], - * cls, - * validation_metadata - * ) - * prefix_items_length = 0 - * if 'prefix_items' in vars(cls_schema): - * prefix_items_length = len(vars(cls_schema)['prefix_items']) - * for keyword, val in json_schema_data.items(): - * used_val: typing.Any - * if keyword in {'contains', 'min_contains', 'max_contains'}: - * used_val = (val, contains_path_to_schemas) - * elif keyword == 'items': - * used_val = (val, prefix_items_length) - * elif keyword in {'unevaluated_items', 'unevaluated_properties'}: - * used_val = (val, path_to_schemas) - * elif keyword in {'types'}: - * format: typing.Optional[str] = vars(cls_schema).get('format', None) - * used_val = (val, format) - * elif keyword in {'pattern_properties', 'additional_properties'}: - * used_val = (val, validated_pattern_properties) - * elif keyword in {'if_', 'then', 'else_'}: - * used_val = (val, if_path_to_schemas) - * else: - * used_val = val - * validator = json_schema_keyword_to_validator[keyword] - * - * other_path_to_schemas = validator( - * arg, - * used_val, - * cls, - * validation_metadata, - * {{#if nonCompliantUseDiscriminatorIfCompositionFails}} - * **kwargs - * {{/if}} - * ) - * if other_path_to_schemas: - * update(path_to_schemas, other_path_to_schemas) - * - * base_class = type(arg) - * if validation_metadata.path_to_item not in path_to_schemas: - * path_to_schemas[validation_metadata.path_to_item] = dict() - * path_to_schemas[validation_metadata.path_to_item][base_class] = None - * path_to_schemas[validation_metadata.path_to_item][cls] = None - * return path_to_schemas - */ diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/StringJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/StringJsonSchema.hbs index c65a45c7da9..0f8bc980f31 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/StringJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/StringJsonSchema.hbs @@ -1,18 +1,17 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; import java.time.LocalDate; import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; -public class StringJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class StringJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/UuidJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/UuidJsonSchema.hbs index ab44f4af9f0..d1480d42432 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/UuidJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/UuidJsonSchema.hbs @@ -1,21 +1,18 @@ package {{{packageName}}}.schemas; +import {{{packageName}}}.schemas.validation.JsonSchema; import {{{packageName}}}.configurations.SchemaConfiguration; -import java.time.LocalDate; -import java.time.ZonedDateTime; import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; -public class UuidJsonSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( +public class UuidJsonSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); - static final String format = "uuid"; + public static final String format = "uuid"; public static String validate(String arg, SchemaConfiguration configuration) { return JsonSchema.validate(UuidJsonSchema.class, arg, configuration); diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/AdditionalPropertiesValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/AdditionalPropertiesValidator.hbs similarity index 77% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/validators/AdditionalPropertiesValidator.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/AdditionalPropertiesValidator.hbs index 76034e945b9..070e0da5679 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/AdditionalPropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/AdditionalPropertiesValidator.hbs @@ -1,9 +1,4 @@ -package {{{packageName}}}.schemas.validators; - -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.JsonSchema; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; +package {{{packageName}}}.schemas.validation; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -14,7 +9,7 @@ import java.util.Set; public class AdditionalPropertiesValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof Map)) { return null; } @@ -42,7 +37,7 @@ public class AdditionalPropertiesValidator implements KeywordValidator { // todo add_deeper_validated_schemas continue; } - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(addPropSchema, propValue, propValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(addPropSchema, propValue, propValidationMetadata); pathToSchemas.update(otherPathToSchemas); } return pathToSchemas; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/CustomIsoparser.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/CustomIsoparser.hbs similarity index 87% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/CustomIsoparser.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/CustomIsoparser.hbs index c7a6720a43e..ab111822f9f 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/CustomIsoparser.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/CustomIsoparser.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import java.time.ZonedDateTime; import java.time.LocalDate; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FakeValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FakeValidator.hbs new file mode 100644 index 00000000000..c1b1658c07b --- /dev/null +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FakeValidator.hbs @@ -0,0 +1,8 @@ +package org.openapijsonschematools.schemas.validation; + +public class FakeValidator implements KeywordValidator { + @Override + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + return null; + } +} diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/FormatValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FormatValidator.hbs similarity index 94% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/validators/FormatValidator.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FormatValidator.hbs index 1694fc0d647..ca67981cc0a 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/FormatValidator.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FormatValidator.hbs @@ -1,9 +1,4 @@ -package {{{packageName}}}.schemas.validators; - -import {{{packageName}}}.schemas.CustomIsoparser; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; +package {{{packageName}}}.schemas.validation; import java.math.BigDecimal; import java.math.BigInteger; @@ -138,7 +133,7 @@ public class FormatValidator implements KeywordValidator { } @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { String format = (String) constraint; if (arg instanceof Number) { validateNumericFormat( diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/FrozenList.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FrozenList.hbs similarity index 96% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/FrozenList.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FrozenList.hbs index dbc75da7932..ded2345d16e 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/FrozenList.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FrozenList.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/FrozenMap.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FrozenMap.hbs similarity index 98% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/FrozenMap.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FrozenMap.hbs index 291d6005197..f1cf2bc7cc4 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/FrozenMap.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/FrozenMap.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/ItemsValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/ItemsValidator.hbs similarity index 70% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/validators/ItemsValidator.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/ItemsValidator.hbs index f4607d7b7e3..7f44cb4e30a 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/ItemsValidator.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/ItemsValidator.hbs @@ -1,16 +1,11 @@ -package {{{packageName}}}.schemas.validators; - -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.JsonSchema; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; +package {{{packageName}}}.schemas.validation; import java.util.ArrayList; import java.util.List; public class ItemsValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof List)) { return null; } @@ -33,7 +28,7 @@ public class ItemsValidator implements KeywordValidator { i +=1; continue; } - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(itemsSchema, itemValue, itemValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(itemsSchema, itemValue, itemValidationMetadata); pathToSchemas.update(otherPathToSchemas); i += 1; } diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/JsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/JsonSchema.hbs new file mode 100644 index 00000000000..473fe3a6915 --- /dev/null +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/JsonSchema.hbs @@ -0,0 +1,343 @@ +package {{{packageName}}}.schemas.validation; + +import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; +import {{{packageName}}}.configurations.SchemaConfiguration; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Field; +import java.time.LocalDate; +import java.time.ZonedDateTime; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.HashMap; +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; + +public abstract class JsonSchema { + static HashMap keywordToValidator = new HashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry("allOf", new FakeValidator()), + new AbstractMap.SimpleEntry("anyOf", new FakeValidator()), + new AbstractMap.SimpleEntry("const", new FakeValidator()), + new AbstractMap.SimpleEntry("contains", new FakeValidator()), + new AbstractMap.SimpleEntry("default", new FakeValidator()), + new AbstractMap.SimpleEntry("dependentRequired", new FakeValidator()), + new AbstractMap.SimpleEntry("dependentSchemas", new FakeValidator()), + new AbstractMap.SimpleEntry("discriminator", new FakeValidator()), + new AbstractMap.SimpleEntry("enumInfo", new FakeValidator()), + new AbstractMap.SimpleEntry("exclusiveMaximum", new FakeValidator()), + new AbstractMap.SimpleEntry("exclusiveMinimum", new FakeValidator()), + new AbstractMap.SimpleEntry("format", new FormatValidator()), + new AbstractMap.SimpleEntry("if_", new FakeValidator()), + new AbstractMap.SimpleEntry("then", new FakeValidator()), + new AbstractMap.SimpleEntry("else_", new FakeValidator()), + new AbstractMap.SimpleEntry("maxContains", new FakeValidator()), + new AbstractMap.SimpleEntry("maxItems", new FakeValidator()), + new AbstractMap.SimpleEntry("maxLength", new FakeValidator()), + new AbstractMap.SimpleEntry("maxProperties", new FakeValidator()), + new AbstractMap.SimpleEntry("maximum", new FakeValidator()), + new AbstractMap.SimpleEntry("minContains", new FakeValidator()), + new AbstractMap.SimpleEntry("minItems", new FakeValidator()), + new AbstractMap.SimpleEntry("minLength", new FakeValidator()), + new AbstractMap.SimpleEntry("minProperties", new FakeValidator()), + new AbstractMap.SimpleEntry("minimum", new FakeValidator()), + new AbstractMap.SimpleEntry("multipleOf", new FakeValidator()), + new AbstractMap.SimpleEntry("not", new FakeValidator()), + new AbstractMap.SimpleEntry("oneOf", new FakeValidator()), + new AbstractMap.SimpleEntry("pattern", new FakeValidator()), + new AbstractMap.SimpleEntry("patternProperties", new FakeValidator()), + new AbstractMap.SimpleEntry("prefixItems", new FakeValidator()), + new AbstractMap.SimpleEntry("required", new RequiredValidator()), + new AbstractMap.SimpleEntry("type", new TypeValidator()), + new AbstractMap.SimpleEntry("uniqueItems", new FakeValidator()), + new AbstractMap.SimpleEntry("items", new ItemsValidator()), + new AbstractMap.SimpleEntry("unevaluatedItems", new FakeValidator()), + new AbstractMap.SimpleEntry("properties", new PropertiesValidator()), + new AbstractMap.SimpleEntry("propertyNames", new FakeValidator()), + new AbstractMap.SimpleEntry("additionalProperties", new AdditionalPropertiesValidator()), + new AbstractMap.SimpleEntry("unevaluatedProperties", new FakeValidator()) + )); + + protected static PathToSchemasMap validate( + Class schemaCls, + Object arg, + ValidationMetadata validationMetadata + ) { + HashMap fieldsToValues = new HashMap<>(); + LinkedHashSet disabledKeywords = validationMetadata.configuration().disabledKeywordFlags().getKeywords(); + Class usedSchemaCls = schemaCls; + Class superclass = schemaCls.getSuperclass(); + if (superclass != JsonSchema.class) { + // only ref with no adjacent properties supported at this time + usedSchemaCls = (Class) superclass; + } + Field[] fields = usedSchemaCls.getDeclaredFields(); + for (Field field : fields) { + String fieldName = field.getName(); + if (fieldName.equals("keywordToValidator")) { + continue; + } + if (fieldName.equals("this$0")) { + continue; + } + if (disabledKeywords.contains(fieldName)) { + continue; + } + try { + Object value = field.get(null); + fieldsToValues.put(fieldName, value); + } catch (IllegalAccessException | IllegalArgumentException e) { + throw new RuntimeException(e); + } + } + Object extra = null; + PathToSchemasMap pathToSchemas = new PathToSchemasMap(); + for (Map.Entry entry: fieldsToValues.entrySet()) { + String jsonKeyword = entry.getKey(); + Object constraint = entry.getValue(); + if (jsonKeyword.equals("additionalProperties") && fieldsToValues.containsKey("properties")) { + extra = fieldsToValues.get("properties"); + } + KeywordValidator validatorClass = keywordToValidator.get(jsonKeyword); + PathToSchemasMap otherPathToSchemas = validatorClass.validate( + schemaCls, + arg, + constraint, + validationMetadata, + extra + ); + if (otherPathToSchemas == null) { + continue; + } + pathToSchemas.update(otherPathToSchemas); + } + List pathToItem = validationMetadata.pathToItem(); + if (!pathToSchemas.containsKey(pathToItem)) { + pathToSchemas.put(validationMetadata.pathToItem(), new LinkedHashMap<>()); + } + pathToSchemas.get(pathToItem).put(schemaCls, null); + + return pathToSchemas; + } + + private static Object castToAllowedTypes(Object arg, List pathToItem, Set> pathSet) { + if (arg == null) { + pathSet.add(pathToItem); + return null; + } else if (arg instanceof String) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Map) { + pathSet.add(pathToItem); + LinkedHashMap argFixed = new LinkedHashMap<>(); + for (Map.Entry entry: ((Map) arg).entrySet()) { + String key = (String) entry.getKey(); + Object val = entry.getValue(); + List newPathToItem = new ArrayList<>(pathToItem); + newPathToItem.add(key); + Object fixedVal = castToAllowedTypes(val, newPathToItem, pathSet); + argFixed.put(key, fixedVal); + } + return new FrozenMap<>(argFixed); + } else if (arg instanceof Boolean) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Integer) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Long) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Float) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof Double) { + pathSet.add(pathToItem); + return arg; + } else if (arg instanceof List) { + pathSet.add(pathToItem); + List argFixed = new ArrayList<>(); + int i =0; + for (Object item: ((List) arg).toArray()) { + List newPathToItem = new ArrayList<>(pathToItem); + newPathToItem.add(i); + Object fixedVal = castToAllowedTypes(item, newPathToItem, pathSet); + argFixed.add(fixedVal); + i += 1; + } + return new FrozenList<>(argFixed); + } else if (arg instanceof ZonedDateTime) { + pathSet.add(pathToItem); + return arg.toString(); + } else if (arg instanceof LocalDate) { + pathSet.add(pathToItem); + return arg.toString(); + } else if (arg instanceof UUID) { + pathSet.add(pathToItem); + return arg.toString(); + } else { + Class argClass = arg.getClass(); + throw new RuntimeException("Invalid type passed in got input="+arg+" type="+argClass); + } + } + + private static PathToSchemasMap getPathToSchemas(Class cls, Object arg, ValidationMetadata validationMetadata, Set> pathSet) { + PathToSchemasMap pathToSchemasMap = new PathToSchemasMap(); + if (validationMetadata.validationRanEarlier(cls)) { + // todo add deeper validated schemas + } else { + PathToSchemasMap otherPathToSchemas = validate(cls, arg, validationMetadata); + pathToSchemasMap.update(otherPathToSchemas); + for (LinkedHashMap, Void> schemas: pathToSchemasMap.values()) { + Class firstSchema = schemas.entrySet().iterator().next().getKey(); + schemas.clear(); + schemas.put(firstSchema, null); + } + Set> missingPaths = pathSet; + missingPaths.removeAll(pathToSchemasMap.keySet()); + if (!missingPaths.isEmpty()) { + LinkedHashMap, Void> unsetAnyTypeSchema = new LinkedHashMap<>(); + unsetAnyTypeSchema.put(UnsetAnyTypeJsonSchema.class, null); + for (List pathToItem: missingPaths) { + pathToSchemasMap.put(pathToItem, unsetAnyTypeSchema); + } + } + } + return pathToSchemasMap; + } + + private static FrozenMap getProperties(Map arg, List pathToItem, PathToSchemasMap pathToSchemas) { + LinkedHashMap properties = new LinkedHashMap<>(); + for(Map.Entry entry: arg.entrySet()) { + String propertyName = (String) entry.getKey(); + List propertyPathToItem = new ArrayList<>(pathToItem); + propertyPathToItem.add(propertyName); + Class propertyClass = pathToSchemas.get(propertyPathToItem).entrySet().iterator().next().getKey(); + Object value = entry.getValue(); + Object castValue = getNewInstance(propertyClass, value, propertyPathToItem, pathToSchemas); + properties.put(propertyName, castValue); + } + return new FrozenMap<>(properties); + } + + private static FrozenList getItems(List arg, List pathToItem, PathToSchemasMap pathToSchemas) { + ArrayList items = new ArrayList<>(); + int i = 0; + for (Object item: arg) { + List itemPathToItem = new ArrayList<>(pathToItem); + itemPathToItem.add(i); + Class itemClass = pathToSchemas.get(itemPathToItem).entrySet().iterator().next().getKey(); + Object castItem = getNewInstance(itemClass, item, itemPathToItem, pathToSchemas); + items.add(castItem); + i += 1; + } + return new FrozenList<>(items); + } + + private static Object getNewInstance(Class cls, Object arg, List pathToItem, PathToSchemasMap pathToSchemas) { + if (arg instanceof Map) { + FrozenMap usedArg = getProperties((Map) arg, pathToItem, pathToSchemas); + try { + Method method = cls.getDeclaredMethod("getMapOutputInstance", FrozenMap.class); + // needed because this is a protected method, but it is across packages + method.setAccessible(true); + return method.invoke(null, usedArg); + } catch (NoSuchMethodException e) { + return usedArg; + } catch (InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } else if (arg instanceof List) { + FrozenList usedArg = getItems((List) arg, pathToItem, pathToSchemas); + try { + Method method = cls.getDeclaredMethod("getListOutputInstance", FrozenList.class); + // needed because this is a protected method, but it is across packages + method.setAccessible(true); + return method.invoke(null, usedArg); + } catch (NoSuchMethodException e) { + return usedArg; + } catch (InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + // str, int, float, boolean, null, FileIO, bytes + return arg; + } + + protected static Void validate(Class cls, Void arg, SchemaConfiguration configuration) { + return (Void) validateObject(cls, arg, configuration); + } + + protected static Boolean validate(Class cls, Boolean arg, SchemaConfiguration configuration) { + return (Boolean) validateObject(cls, arg, configuration); + } + + protected static Integer validate(Class cls, Integer arg, SchemaConfiguration configuration) { + return (Integer) validateObject(cls, arg, configuration); + } + + protected static Long validate(Class cls, Long arg, SchemaConfiguration configuration) { + return (Long) validateObject(cls, arg, configuration); + } + + protected static Float validate(Class cls, Float arg, SchemaConfiguration configuration) { + return (Float) validateObject(cls, arg, configuration); + } + + protected static Double validate(Class cls, Double arg, SchemaConfiguration configuration) { + return (Double) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, String arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, ZonedDateTime arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, LocalDate arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static String validate(Class cls, UUID arg, SchemaConfiguration configuration) { + return (String) validateObject(cls, arg, configuration); + } + + protected static T validate(Class cls, Map arg, SchemaConfiguration configuration) { + return (T) validateObject(cls, arg, configuration); + } + + protected static U validate(Class cls, List arg, SchemaConfiguration configuration) { + return (U) validateObject(cls, arg, configuration); + } + + // todo add bytes and FileIO + + public static Object validateObject(Class cls, Object arg, SchemaConfiguration configuration) { + if (arg instanceof Map || arg instanceof List) { + // todo don't run validation if the instance is one of the class generic types + } + Set> pathSet = new HashSet(); + List pathToItem = new ArrayList<>(); + pathToItem.add("args[0]"); + Object 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(cls, castArg, validationMetadata, pathSet); + return getNewInstance(cls, castArg, validationMetadata.pathToItem(), pathToSchemasMap); + } + +} \ No newline at end of file diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/KeywordValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/KeywordValidator.hbs new file mode 100644 index 00000000000..4df90b7ad06 --- /dev/null +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/KeywordValidator.hbs @@ -0,0 +1,10 @@ +package {{{packageName}}}.schemas.validation; + +public interface KeywordValidator { + PathToSchemasMap validate( + Class cls, + Object arg, + Object constraint, + ValidationMetadata validationMetadata, + Object extra); +} diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/PathToSchemasMap.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/PathToSchemasMap.hbs similarity index 58% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/PathToSchemasMap.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/PathToSchemasMap.hbs index 7aa27723b42..b287ed57ae6 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/PathToSchemasMap.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/PathToSchemasMap.hbs @@ -1,15 +1,15 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -public class PathToSchemasMap extends LinkedHashMap, LinkedHashMap, Void>> { +public class PathToSchemasMap extends LinkedHashMap, LinkedHashMap, Void>> { public void update(PathToSchemasMap other) { - for (Map.Entry, LinkedHashMap, Void>> entry: other.entrySet()) { + for (Map.Entry, LinkedHashMap, Void>> entry: other.entrySet()) { List pathToItem = entry.getKey(); - LinkedHashMap, Void> otherSchemas = entry.getValue(); + LinkedHashMap, Void> otherSchemas = entry.getValue(); if (containsKey(pathToItem)) { get(pathToItem).putAll(otherSchemas); } else { diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/PropertiesValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/PropertiesValidator.hbs similarity index 74% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/validators/PropertiesValidator.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/PropertiesValidator.hbs index 73eda969c6e..4f8f4499a69 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/PropertiesValidator.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/PropertiesValidator.hbs @@ -1,9 +1,4 @@ -package {{{packageName}}}.schemas.validators; - -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.JsonSchema; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; +package {{{packageName}}}.schemas.validation; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -13,7 +8,7 @@ import java.util.Set; public class PropertiesValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof Map)) { return null; } @@ -37,7 +32,7 @@ public class PropertiesValidator implements KeywordValidator { // todo add_deeper_validated_schemas continue; } - PathToSchemasMap otherPathToSchemas = SchemaValidator.validate(propSchema, propValue, propValidationMetadata); + PathToSchemasMap otherPathToSchemas = JsonSchema.validate(propSchema, propValue, propValidationMetadata); pathToSchemas.update(otherPathToSchemas); } return pathToSchemas; diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/RequiredValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/RequiredValidator.hbs similarity index 72% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/validators/RequiredValidator.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/RequiredValidator.hbs index 2aff713169b..a91638d9b21 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/RequiredValidator.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/RequiredValidator.hbs @@ -1,8 +1,4 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; +package org.openapijsonschematools.schemas.validation; import java.util.HashSet; import java.util.List; @@ -11,7 +7,7 @@ import java.util.Set; public class RequiredValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { if (!(arg instanceof Map)) { return null; } diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/TypeValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/TypeValidator.hbs similarity index 56% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/validators/TypeValidator.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/TypeValidator.hbs index 7102a33a6ab..5d9a8de90b2 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/TypeValidator.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/TypeValidator.hbs @@ -1,14 +1,10 @@ -package {{{packageName}}}.schemas.validators; - -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; +package {{{packageName}}}.schemas.validation; import java.util.HashSet; public class TypeValidator implements KeywordValidator { @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { + public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { HashSet> types = (HashSet>) constraint; Class argClass; if (arg == null) { diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/UnsetAnyTypeJsonSchema.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/UnsetAnyTypeJsonSchema.hbs similarity index 95% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/UnsetAnyTypeJsonSchema.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/UnsetAnyTypeJsonSchema.hbs index caacd88852d..3c062e4ed79 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/UnsetAnyTypeJsonSchema.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/UnsetAnyTypeJsonSchema.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import {{{packageName}}}.configurations.SchemaConfiguration; @@ -11,7 +11,7 @@ import java.util.Set; import java.util.UUID; -public class UnsetAnyTypeJsonSchema implements JsonSchema { +public class UnsetAnyTypeJsonSchema extends JsonSchema { static Void validate(Void arg, SchemaConfiguration configuration) { return JsonSchema.validate(UnsetAnyTypeJsonSchema.class, arg, configuration); } diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/ValidationMetadata.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/ValidationMetadata.hbs similarity index 69% rename from src/main/resources/java/src/main/java/org/openapitools/schemas/ValidationMetadata.hbs rename to src/main/resources/java/src/main/java/org/openapitools/schemas/validation/ValidationMetadata.hbs index 93209ca2483..e0b06e46fc1 100644 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/ValidationMetadata.hbs +++ b/src/main/resources/java/src/main/java/org/openapitools/schemas/validation/ValidationMetadata.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import {{{packageName}}}.configurations.SchemaConfiguration; import java.util.List; @@ -12,8 +12,8 @@ public record ValidationMetadata( Set> seenClasses ) { - public boolean validationRanEarlier(Class cls) { - Map, Void> validatedSchemas = validatedPathToSchemas.getOrDefault(pathToItem, null); + public boolean validationRanEarlier(Class cls) { + Map, Void> validatedSchemas = validatedPathToSchemas.getOrDefault(pathToItem, null); if (validatedSchemas != null && validatedSchemas.containsKey(cls)) { return true; } diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/FakeValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/FakeValidator.hbs deleted file mode 100644 index c0010c0d90f..00000000000 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/FakeValidator.hbs +++ /dev/null @@ -1,12 +0,0 @@ -package org.openapijsonschematools.schemas.validators; - -import org.openapijsonschematools.schemas.PathToSchemasMap; -import org.openapijsonschematools.schemas.SchemaValidator; -import org.openapijsonschematools.schemas.ValidationMetadata; - -public class FakeValidator implements KeywordValidator { - @Override - public PathToSchemasMap validate(Class cls, Object arg, Object constraint, ValidationMetadata validationMetadata, Object extra) { - return null; - } -} diff --git a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/KeywordValidator.hbs b/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/KeywordValidator.hbs deleted file mode 100644 index 09a4c40c957..00000000000 --- a/src/main/resources/java/src/main/java/org/openapitools/schemas/validators/KeywordValidator.hbs +++ /dev/null @@ -1,14 +0,0 @@ -package {{{packageName}}}.schemas.validators; - -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; - -public interface KeywordValidator { - PathToSchemasMap validate( - Class cls, - Object arg, - Object constraint, - ValidationMetadata validationMetadata, - Object extra); -} diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/AnyTypeSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/AnyTypeSchemaTest.hbs index 69864c0b8ef..1303417561f 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/AnyTypeSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/AnyTypeSchemaTest.hbs @@ -4,6 +4,9 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.FrozenList; +import {{{packageName}}}.schemas.validation.FrozenMap; + import java.time.LocalDate; import java.time.ZoneId; diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/ArrayTypeSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/ArrayTypeSchemaTest.hbs index d700cf512d3..a35e62a23fb 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/ArrayTypeSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/ArrayTypeSchemaTest.hbs @@ -4,54 +4,57 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; +import {{{packageName}}}.schemas.validation.FrozenList; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -class ArrayWithItemsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenList.class - )); - static final Class items = StringJsonSchema.class; - public static FrozenList validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ArrayWithItemsSchema.class, arg, configuration); - } -} +public class ArrayTypeSchemaTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); -class ArrayWithOutputClsSchemaList extends FrozenList { - ArrayWithOutputClsSchemaList(FrozenList m) { - super(m); - } + public class ArrayWithItemsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenList.class + )); + public static final Class items = StringJsonSchema.class; - public static ArrayWithOutputClsSchemaList of(List arg, SchemaConfiguration configuration) { - return ArrayWithOutputClsSchema.validate(arg, configuration); + public static FrozenList validate(List arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ArrayWithItemsSchema.class, arg, configuration); + } } -} -class ArrayWithOutputClsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenList.class - )); - static final Class items = StringJsonSchema.class; + public static class ArrayWithOutputClsSchemaList extends FrozenList { + ArrayWithOutputClsSchemaList(FrozenList m) { + super(m); + } - public static ArrayWithOutputClsSchemaList getListOutputInstance(FrozenList arg) { - return new ArrayWithOutputClsSchemaList(arg); + public static ArrayWithOutputClsSchemaList of(List arg, SchemaConfiguration configuration) { + return ArrayWithOutputClsSchema.validate(arg, configuration); + } } - public static ArrayWithOutputClsSchemaList validate(List arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ArrayWithOutputClsSchema.class, arg, configuration); - } -} + public class ArrayWithOutputClsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenList.class + )); + public static final Class items = StringJsonSchema.class; -public class ArrayTypeSchemaTest { - static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); + protected static ArrayWithOutputClsSchemaList getListOutputInstance(FrozenList arg) { + return new ArrayWithOutputClsSchemaList(arg); + } + + public static ArrayWithOutputClsSchemaList validate(List arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ArrayWithOutputClsSchema.class, arg, configuration); + } + } @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( ArrayWithItemsSchema.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/BooleanSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/BooleanSchemaTest.hbs index 6032b2cc6ab..c3626d6b8be 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/BooleanSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/BooleanSchemaTest.hbs @@ -4,6 +4,7 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; public class BooleanSchemaTest { static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); @@ -22,7 +23,7 @@ public class BooleanSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( BooleanJsonSchema.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/ListSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/ListSchemaTest.hbs index 8a3b71dc2ef..357df065371 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/ListSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/ListSchemaTest.hbs @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; +import {{{packageName}}}.schemas.validation.FrozenList; import java.util.ArrayList; import java.util.List; @@ -13,7 +15,7 @@ public class ListSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( ListJsonSchema.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/MapSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/MapSchemaTest.hbs index 136868abced..4aaea8c50e6 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/MapSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/MapSchemaTest.hbs @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; +import {{{packageName}}}.schemas.validation.FrozenMap; import java.time.LocalDate; import java.util.LinkedHashMap; @@ -14,7 +16,7 @@ public class MapSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( MapJsonSchema.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/NullSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/NullSchemaTest.hbs index 9a9c140868b..0c18606ff64 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/NullSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/NullSchemaTest.hbs @@ -4,6 +4,7 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; public class NullSchemaTest { static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); @@ -16,7 +17,7 @@ public class NullSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( NullJsonSchema.class, Boolean.TRUE, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/NumberSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/NumberSchemaTest.hbs index 861f99bf016..9049d954cea 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/NumberSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/NumberSchemaTest.hbs @@ -4,6 +4,7 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; import java.math.BigDecimal; @@ -36,7 +37,7 @@ public class NumberSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( NumberJsonSchema.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/ObjectTypeSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/ObjectTypeSchemaTest.hbs index 6c329eb4840..4bbece9ef85 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/ObjectTypeSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/ObjectTypeSchemaTest.hbs @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; +import {{{packageName}}}.schemas.validation.FrozenMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; @@ -11,78 +13,79 @@ import java.util.AbstractMap; import java.util.Map; import java.util.Set; -class ObjectWithPropsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) - )); - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithPropsSchema.class, arg, configuration); - } -} +public class ObjectTypeSchemaTest { + static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); -class ObjectWithAddpropsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final Class additionalProperties = StringJsonSchema.class; + public class ObjectWithPropsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) + )); - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithAddpropsSchema.class, arg, configuration); + public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithPropsSchema.class, arg, configuration); + } } -} -class ObjectWithPropsAndAddpropsSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) - )); - static final Class additionalProperties = BooleanJsonSchema.class; - - public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithPropsAndAddpropsSchema.class, arg, configuration); + public class ObjectWithAddpropsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final Class additionalProperties = StringJsonSchema.class; + + public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithAddpropsSchema.class, arg, configuration); + } } -} -class ObjectWithOutputTypeSchemaMap extends FrozenMap { - ObjectWithOutputTypeSchemaMap(FrozenMap m) { - super(m); + public class ObjectWithPropsAndAddpropsSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) + )); + public static final Class additionalProperties = BooleanJsonSchema.class; + + public static FrozenMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithPropsAndAddpropsSchema.class, arg, configuration); + } } - public static ObjectWithOutputTypeSchemaMap of(Map arg, SchemaConfiguration configuration) { - return ObjectWithOutputTypeSchema.validate(arg, configuration); + public static class ObjectWithOutputTypeSchemaMap extends FrozenMap { + ObjectWithOutputTypeSchemaMap(FrozenMap m) { + super(m); + } + + public static ObjectWithOutputTypeSchemaMap of(Map arg, SchemaConfiguration configuration) { + return ObjectWithOutputTypeSchema.validate(arg, configuration); + } } -} -class ObjectWithOutputTypeSchema implements JsonSchema { - static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( - FrozenMap.class - )); - static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( - new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) - )); + public class ObjectWithOutputTypeSchema extends JsonSchema { + public static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( + FrozenMap.class + )); + public static final LinkedHashMap> properties = new LinkedHashMap<>(Map.ofEntries( + new AbstractMap.SimpleEntry>("someString", StringJsonSchema.class) + )); - public static ObjectWithOutputTypeSchemaMap getMapOutputInstance(FrozenMap arg) { - return new ObjectWithOutputTypeSchemaMap(arg); - } + protected static ObjectWithOutputTypeSchemaMap getMapOutputInstance(FrozenMap arg) { + return new ObjectWithOutputTypeSchemaMap(arg); + } - public static ObjectWithOutputTypeSchemaMap validate(Map arg, SchemaConfiguration configuration) { - return JsonSchema.validate(ObjectWithOutputTypeSchema.class, arg, configuration); + public static ObjectWithOutputTypeSchemaMap validate(Map arg, SchemaConfiguration configuration) { + return JsonSchema.validate(ObjectWithOutputTypeSchema.class, arg, configuration); + } } -} - -public class ObjectTypeSchemaTest { - static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone()); @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( ObjectWithPropsSchema.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/RefBooleanSchemaTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/RefBooleanSchemaTest.hbs index 88ddee9e70e..b1807a9a045 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/RefBooleanSchemaTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/RefBooleanSchemaTest.hbs @@ -4,6 +4,7 @@ import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; +import {{{packageName}}}.schemas.validation.JsonSchema; class RefBooleanSchema { public class RefBooleanSchema1 extends BooleanJsonSchema{} @@ -26,7 +27,7 @@ public class RefBooleanSchemaTest { @Test public void testExceptionThrownForInvalidType() { - Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validate( + Assert.assertThrows(RuntimeException.class, () -> JsonSchema.validateObject( RefBooleanSchema.RefBooleanSchema1.class, (Void) null, configuration )); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/AdditionalPropertiesValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/AdditionalPropertiesValidatorTest.hbs similarity index 88% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/validators/AdditionalPropertiesValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/AdditionalPropertiesValidatorTest.hbs index 1c1c49b433f..2a74f29eabd 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/AdditionalPropertiesValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/AdditionalPropertiesValidatorTest.hbs @@ -1,14 +1,10 @@ -package {{{packageName}}}.schemas.validators; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; -import {{{packageName}}}.schemas.FrozenMap; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; import {{{packageName}}}.schemas.StringJsonSchema; -import {{{packageName}}}.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -37,7 +33,7 @@ public class AdditionalPropertiesValidatorTest { FrozenMap arg = new FrozenMap<>(mutableMap); final AdditionalPropertiesValidator validator = new AdditionalPropertiesValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, @@ -46,8 +42,7 @@ public class AdditionalPropertiesValidatorTest { List expectedPathToItem = new ArrayList<>(); expectedPathToItem.add("args[0]"); expectedPathToItem.add("someAddProp"); - LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); - expectedClasses.put(String.class, null); + LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); expectedClasses.put(StringJsonSchema.class, null); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); expectedPathToSchemas.put(expectedPathToItem, expectedClasses); @@ -66,7 +61,7 @@ public class AdditionalPropertiesValidatorTest { ); final AdditionalPropertiesValidator validator = new AdditionalPropertiesValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, StringJsonSchema.class, validationMetadata, @@ -94,7 +89,7 @@ public class AdditionalPropertiesValidatorTest { FrozenMap arg = new FrozenMap<>(mutableMap); final AdditionalPropertiesValidator validator = new AdditionalPropertiesValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/CustomIsoparserTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/CustomIsoparserTest.hbs similarity index 94% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/CustomIsoparserTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/CustomIsoparserTest.hbs index 9acb2375bf9..ed5b89f25de 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/CustomIsoparserTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/CustomIsoparserTest.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import java.time.LocalDate; import java.time.ZonedDateTime; diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/FormatValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/FormatValidatorTest.hbs similarity index 88% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/validators/FormatValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/FormatValidatorTest.hbs index c6a7a9430b9..62902eb935d 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/FormatValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/FormatValidatorTest.hbs @@ -1,12 +1,9 @@ -package {{{packageName}}}.schemas.validators; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; import java.math.BigDecimal; import java.math.BigInteger; @@ -25,7 +22,7 @@ public class FormatValidatorTest { public void testIntFormatSucceedsWithFloat() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1.0f, "int", validationMetadata, @@ -38,7 +35,7 @@ public class FormatValidatorTest { public void testIntFormatFailsWithFloat() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 3.14f, "int", validationMetadata, @@ -50,7 +47,7 @@ public class FormatValidatorTest { public void testIntFormatSucceedsWithInt() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, "int", validationMetadata, @@ -63,7 +60,7 @@ public class FormatValidatorTest { public void testInt32UnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, -2147483649L, "int32", validationMetadata, @@ -75,7 +72,7 @@ public class FormatValidatorTest { public void testInt32InclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -2147483648, "int32", validationMetadata, @@ -88,7 +85,7 @@ public class FormatValidatorTest { public void testInt32InclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 2147483647, "int32", validationMetadata, @@ -101,7 +98,7 @@ public class FormatValidatorTest { public void testInt32OverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 2147483648L, "int32", validationMetadata, @@ -114,7 +111,7 @@ public class FormatValidatorTest { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigInteger("-9223372036854775809"), "int64", validationMetadata, @@ -126,7 +123,7 @@ public class FormatValidatorTest { public void testInt64InclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -9223372036854775808L, "int64", validationMetadata, @@ -139,7 +136,7 @@ public class FormatValidatorTest { public void testInt64InclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 9223372036854775807L, "int64", validationMetadata, @@ -153,7 +150,7 @@ public class FormatValidatorTest { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigInteger("9223372036854775808"), "int64", validationMetadata, @@ -165,7 +162,7 @@ public class FormatValidatorTest { public void testFloatUnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, -3.402823466385289e+38d, "float", validationMetadata, @@ -177,7 +174,7 @@ public class FormatValidatorTest { public void testFloatInclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -3.4028234663852886e+38f, "float", validationMetadata, @@ -190,7 +187,7 @@ public class FormatValidatorTest { public void testFloatInclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 3.4028234663852886e+38f, "float", validationMetadata, @@ -203,7 +200,7 @@ public class FormatValidatorTest { public void testFloatOverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 3.402823466385289e+38d, "float", validationMetadata, @@ -215,7 +212,7 @@ public class FormatValidatorTest { public void testDoubleUnderMinFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigDecimal("-1.7976931348623157082e+308"), "double", validationMetadata, @@ -227,7 +224,7 @@ public class FormatValidatorTest { public void testDoubleInclusiveMinSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, -1.7976931348623157E+308d, "double", validationMetadata, @@ -240,7 +237,7 @@ public class FormatValidatorTest { public void testDoubleInclusiveMaxSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1.7976931348623157E+308d, "double", validationMetadata, @@ -253,7 +250,7 @@ public class FormatValidatorTest { public void testDoubleOverMaxFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, new BigDecimal("1.7976931348623157082e+308"), "double", validationMetadata, @@ -265,7 +262,7 @@ public class FormatValidatorTest { public void testInvalidNumberStringFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, "abc", "number", validationMetadata, @@ -277,7 +274,7 @@ public class FormatValidatorTest { public void testValidFloatNumberStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "3.14", "number", validationMetadata, @@ -290,7 +287,7 @@ public class FormatValidatorTest { public void testValidIntNumberStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "1", "number", validationMetadata, @@ -303,7 +300,7 @@ public class FormatValidatorTest { public void testInvalidDateStringFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, "abc", "date", validationMetadata, @@ -315,7 +312,7 @@ public class FormatValidatorTest { public void testValidDateStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "2017-01-20", "date", validationMetadata, @@ -328,7 +325,7 @@ public class FormatValidatorTest { public void testInvalidDateTimeStringFails() { final FormatValidator validator = new FormatValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, "abc", "date-time", validationMetadata, @@ -340,7 +337,7 @@ public class FormatValidatorTest { public void testValidDateTimeStringSucceeds() { final FormatValidator validator = new FormatValidator(); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "2017-07-21T17:32:28Z", "date-time", validationMetadata, diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/ItemsValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/ItemsValidatorTest.hbs similarity index 86% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/validators/ItemsValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/ItemsValidatorTest.hbs index 93689b20cb2..662cdf8983a 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/ItemsValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/ItemsValidatorTest.hbs @@ -1,14 +1,10 @@ -package {{{packageName}}}.schemas.validators; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; -import {{{packageName}}}.schemas.FrozenList; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; import {{{packageName}}}.schemas.StringJsonSchema; -import {{{packageName}}}.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -32,7 +28,7 @@ public class ItemsValidatorTest { FrozenList arg = new FrozenList<>(mutableList); final ItemsValidator validator = new ItemsValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, @@ -41,8 +37,7 @@ public class ItemsValidatorTest { List expectedPathToItem = new ArrayList<>(); expectedPathToItem.add("args[0]"); expectedPathToItem.add(0); - LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); - expectedClasses.put(String.class, null); + LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); expectedClasses.put(StringJsonSchema.class, null); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); expectedPathToSchemas.put(expectedPathToItem, expectedClasses); @@ -61,7 +56,7 @@ public class ItemsValidatorTest { ); final ItemsValidator validator = new ItemsValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, StringJsonSchema.class, validationMetadata, @@ -85,7 +80,7 @@ public class ItemsValidatorTest { FrozenList arg = new FrozenList<>(mutableList); final ItemsValidator validator = new ItemsValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, StringJsonSchema.class, validationMetadata, diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/SchemaValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/JsonSchemaTest.hbs similarity index 79% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/SchemaValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/JsonSchemaTest.hbs index d51fe0642cb..e40530799a7 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/SchemaValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/JsonSchemaTest.hbs @@ -1,4 +1,4 @@ -package {{{packageName}}}.schemas; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; @@ -11,13 +11,13 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -class SomeSchema implements SchemaValidator { +class SomeSchema extends JsonSchema { static final LinkedHashSet> type = new LinkedHashSet<>(Set.of( String.class )); } -public class SchemaValidatorTest { +public class JsonSchemaTest { @Test public void testValidateSucceeds() { @@ -29,15 +29,14 @@ public class SchemaValidatorTest { new PathToSchemasMap(), new LinkedHashSet<>() ); - PathToSchemasMap pathToSchemas = SchemaValidator.validate( + PathToSchemasMap pathToSchemas = JsonSchema.validate( SomeSchema.class, "hi", validationMetadata ); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); - LinkedHashMap, Void> validatedClasses = new LinkedHashMap<>(); + LinkedHashMap, Void> validatedClasses = new LinkedHashMap<>(); validatedClasses.put(SomeSchema.class, null); - validatedClasses.put(String.class, null); expectedPathToSchemas.put(pathToItem, validatedClasses); Assert.assertEquals(pathToSchemas, expectedPathToSchemas); } diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/PropertiesValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/PropertiesValidatorTest.hbs similarity index 88% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/validators/PropertiesValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/PropertiesValidatorTest.hbs index 2f28cb66eac..05ff78cf928 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/PropertiesValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/PropertiesValidatorTest.hbs @@ -1,14 +1,10 @@ -package {{{packageName}}}.schemas.validators; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; -import {{{packageName}}}.schemas.FrozenMap; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; import {{{packageName}}}.schemas.StringJsonSchema; -import {{{packageName}}}.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -36,7 +32,7 @@ public class PropertiesValidatorTest { mutableMap.put("someString", "abc"); FrozenMap arg = new FrozenMap<>(mutableMap); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, properties, validationMetadata, @@ -45,8 +41,7 @@ public class PropertiesValidatorTest { List expectedPathToItem = new ArrayList<>(); expectedPathToItem.add("args[0]"); expectedPathToItem.add("someString"); - LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); - expectedClasses.put(String.class, null); + LinkedHashMap, Void> expectedClasses = new LinkedHashMap<>(); expectedClasses.put(StringJsonSchema.class, null); PathToSchemasMap expectedPathToSchemas = new PathToSchemasMap(); expectedPathToSchemas.put(expectedPathToItem, expectedClasses); @@ -68,7 +63,7 @@ public class PropertiesValidatorTest { new LinkedHashSet<>() ); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, properties, validationMetadata, @@ -95,7 +90,7 @@ public class PropertiesValidatorTest { mutableMap.put("someString", 1); FrozenMap arg = new FrozenMap<>(mutableMap); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, properties, validationMetadata, diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/RequiredValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/RequiredValidatorTest.hbs similarity index 90% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/validators/RequiredValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/RequiredValidatorTest.hbs index 3bf20328420..1d25e0ceee5 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/RequiredValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/RequiredValidatorTest.hbs @@ -1,14 +1,10 @@ -package {{{packageName}}}.schemas.validators; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; -import {{{packageName}}}.schemas.FrozenMap; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; import {{{packageName}}}.schemas.StringJsonSchema; -import {{{packageName}}}.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -37,7 +33,7 @@ public class RequiredValidatorTest { FrozenMap arg = new FrozenMap<>(mutableMap); final RequiredValidator validator = new RequiredValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, requiredProperties, validationMetadata, @@ -61,7 +57,7 @@ public class RequiredValidatorTest { ); final RequiredValidator validator = new RequiredValidator(); PathToSchemasMap pathToSchemas = validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, properties, validationMetadata, @@ -88,7 +84,7 @@ public class RequiredValidatorTest { FrozenMap arg = new FrozenMap<>(mutableMap); final RequiredValidator validator = new RequiredValidator(); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, arg, requiredProperties, validationMetadata, diff --git a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/TypeValidatorTest.hbs b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/TypeValidatorTest.hbs similarity index 85% rename from src/main/resources/java/src/test/java/org/openapitools/schemas/validators/TypeValidatorTest.hbs rename to src/main/resources/java/src/test/java/org/openapitools/schemas/validation/TypeValidatorTest.hbs index c63d089a91f..98e0a17a7e2 100644 --- a/src/main/resources/java/src/test/java/org/openapitools/schemas/validators/TypeValidatorTest.hbs +++ b/src/main/resources/java/src/test/java/org/openapitools/schemas/validation/TypeValidatorTest.hbs @@ -1,12 +1,9 @@ -package {{{packageName}}}.schemas.validators; +package {{{packageName}}}.schemas.validation; import org.junit.Assert; import org.junit.Test; import {{{packageName}}}.configurations.JsonSchemaKeywordFlags; import {{{packageName}}}.configurations.SchemaConfiguration; -import {{{packageName}}}.schemas.PathToSchemasMap; -import {{{packageName}}}.schemas.SchemaValidator; -import {{{packageName}}}.schemas.ValidationMetadata; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -25,7 +22,7 @@ public class TypeValidatorTest { new LinkedHashSet<>() ); PathToSchemasMap pathToSchemasMap = validator.validate( - SchemaValidator.class, + JsonSchema.class, "hi", value, validationMetadata, @@ -46,7 +43,7 @@ public class TypeValidatorTest { new LinkedHashSet<>() ); Assert.assertThrows(RuntimeException.class, () -> validator.validate( - SchemaValidator.class, + JsonSchema.class, 1, value, validationMetadata,