Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Java, adds 303 unit test client json schema tests #307

Merged
merged 21 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fcd8355
Adds test files
spacether Nov 30, 2023
3b968b1
Improves test templates
spacether Nov 30, 2023
63e4d88
Fixes handling on null character in enums
spacether Nov 30, 2023
32c5984
Fixes validate method for anytype with map + max + min length validat…
spacether Nov 30, 2023
a698fa2
Changes from List.of to Arrays.asList to allow nulls in at initializa…
spacether Nov 30, 2023
03f33a5
Adjusts numeric formatting to only apply for known formats
spacether Nov 30, 2023
09bd0ec
Adds not validator to java and templates
spacether Nov 30, 2023
3b64c9c
java 303 sample regen
spacether Nov 30, 2023
d9d42a0
Adds Integer type ton IntJsonSchema
spacether Nov 30, 2023
d500db9
Fixes not validator
spacether Nov 30, 2023
3737b2f
Adds getMapOutputInstance to anytype schemas
spacether Nov 30, 2023
6c46c0f
Improves list validate and getListOutputInstance method generation
spacether Nov 30, 2023
7eeecab
Allows float and double into intjsonschema
spacether Nov 30, 2023
4accced
Gets NotAnyTypeJsonSchema working
spacether Nov 30, 2023
7920251
Fixes keywords generation, fixes java test testPropertiesDefinedInAll…
spacether Nov 30, 2023
da226da
Adds and uses MapBuilder to allow null entries into maps
spacether Nov 30, 2023
514344a
Fixes two java enum tests by inserting float values into enum when in…
spacether Dec 1, 2023
6234825
Fixes multipleOf validator
spacether Dec 1, 2023
4bb62d8
Adjusts pattern processing to remve leading and traling /
spacether Dec 1, 2023
eccdd75
Stops adding float values of int in enum, enum validator handles int …
spacether Dec 1, 2023
90c5259
Samples regen
spacether Dec 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions samples/client/3_0_3_unit_test/java/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ src/main/java/org/openapijsonschematools/schemas/Int64JsonSchema.java
src/main/java/org/openapijsonschematools/schemas/IntJsonSchema.java
src/main/java/org/openapijsonschematools/schemas/ListJsonSchema.java
src/main/java/org/openapijsonschematools/schemas/MapJsonSchema.java
src/main/java/org/openapijsonschematools/schemas/MapMaker.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
Expand Down Expand Up @@ -222,6 +223,7 @@ src/main/java/org/openapijsonschematools/schemas/validation/MinLengthValidator.j
src/main/java/org/openapijsonschematools/schemas/validation/MinPropertiesValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MinimumValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/MultipleOfValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/NotValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/OneOfValidator.java
src/main/java/org/openapijsonschematools/schemas/validation/PathToSchemasMap.java
src/main/java/org/openapijsonschematools/schemas/validation/PatternValidator.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("additionalProperties", new AdditionalPropertiesValidator([AdditionalProperties.class](#additionalproperties))),<br>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("allOf", new AllOfValidator(List.of(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[Schema0.class](#schema0)<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("not", new NotValidator([Not2.class](#not2)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("not", new NotValidator([Not.class](#not)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("enum", new EnumValidator(Set.of(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hello\x00there"<br>)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("type", new TypeValidator(Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("enum", new EnumValidator(Set.of(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hello\0there"<br>)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"/a+/"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"a+"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"/^a*$/"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("pattern", new PatternValidator(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"^a*$"<br>&nbsp;&nbsp;&nbsp;&nbsp;)))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A schema class that validates payloads
### Field Summary
| Modifier and Type | Field and Description |
| ----------------- | ---------------------- |
| static LinkedHashMap<String, KeywordValidator> |keywordToValidator<br/>new LinkedHashMap<>(Map.ofEntries(<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("not", new NotValidator([PropertyNamedRefThatIsNotAReference.PropertyNamedRefThatIsNotAReference1.class](../../components/schemas/PropertyNamedRefThatIsNotAReference.md#propertynamedrefthatisnotareference1))<br>)); |

### Method Summary
| Modifier and Type | Method and Description |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public static class AdditionalpropertiesAllowsASchemaWhichShouldValidate1 extend
new PropertyEntry("bar", Bar.class)
))),
new KeywordEntry("additionalProperties", new AdditionalPropertiesValidator(AdditionalProperties.class))

));

protected static AdditionalpropertiesAllowsASchemaWhichShouldValidateMap getMapOutputInstance(FrozenMap<String, Object> arg) {
return new AdditionalpropertiesAllowsASchemaWhichShouldValidateMap(arg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public static class AdditionalpropertiesAreAllowedByDefault1 extends JsonSchema
new PropertyEntry("bar", Bar.class)
)))
));

protected static AdditionalpropertiesAreAllowedByDefaultMap getMapOutputInstance(FrozenMap<String, Object> arg) {
return new AdditionalpropertiesAreAllowedByDefaultMap(arg);
}
public static Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AdditionalpropertiesAreAllowedByDefault1.class, arg, configuration);
}
Expand Down Expand Up @@ -112,11 +116,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(AdditionalpropertiesAreAllowedByDefault1.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static AdditionalpropertiesAreAllowedByDefaultMap validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AdditionalpropertiesAreAllowedByDefault1.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AdditionalpropertiesAreAllowedByDefault1.class, arg, configuration);
}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public static class AdditionalpropertiesCanExistByItself1 extends JsonSchema {
public static final LinkedHashMap<String, KeywordValidator> keywordToValidator = new LinkedHashMap<>(Map.ofEntries(
new KeywordEntry("type", new TypeValidator(Set.of(FrozenMap.class))),
new KeywordEntry("additionalProperties", new AdditionalPropertiesValidator(AdditionalProperties.class))

));

protected static AdditionalpropertiesCanExistByItselfMap getMapOutputInstance(FrozenMap<String, Boolean> arg) {
return new AdditionalpropertiesCanExistByItselfMap(arg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public static class Schema0 extends JsonSchema {
new PropertyEntry("foo", Foo.class)
)))
));

protected static Schema0Map getMapOutputInstance(FrozenMap<String, Object> arg) {
return new Schema0Map(arg);
}
public static Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}
Expand Down Expand Up @@ -101,11 +105,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Schema0.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static Schema0Map validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}
}
Expand Down Expand Up @@ -133,6 +137,16 @@ public static class AdditionalpropertiesShouldNotLookInApplicators1 extends Json

Do not edit the class manually.
*/
public static final LinkedHashMap<String, KeywordValidator> keywordToValidator = new LinkedHashMap<>(Map.ofEntries(
new KeywordEntry("additionalProperties", new AdditionalPropertiesValidator(AdditionalProperties.class)),
new KeywordEntry("allOf", new AllOfValidator(List.of(
Schema0.class
)))
));

protected static AdditionalpropertiesShouldNotLookInApplicatorsMap getMapOutputInstance(FrozenMap<String, Boolean> arg) {
return new AdditionalpropertiesShouldNotLookInApplicatorsMap(arg);
}
public static Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AdditionalpropertiesShouldNotLookInApplicators1.class, arg, configuration);
}
Expand Down Expand Up @@ -173,11 +187,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(AdditionalpropertiesShouldNotLookInApplicators1.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static AdditionalpropertiesShouldNotLookInApplicatorsMap validate(Map<String, Boolean> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AdditionalpropertiesShouldNotLookInApplicators1.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AdditionalpropertiesShouldNotLookInApplicators1.class, arg, configuration);
}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public static class Schema0 extends JsonSchema {
"bar"
)))
));

protected static Schema0Map getMapOutputInstance(FrozenMap<String, Object> arg) {
return new Schema0Map(arg);
}
public static Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}
Expand Down Expand Up @@ -99,11 +103,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Schema0.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static Schema0Map validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}
}
Expand Down Expand Up @@ -143,6 +147,10 @@ public static class Schema1 extends JsonSchema {
"foo"
)))
));

protected static Schema1Map getMapOutputInstance(FrozenMap<String, Object> arg) {
return new Schema1Map(arg);
}
public static Void validate(Void arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema1.class, arg, configuration);
}
Expand Down Expand Up @@ -183,11 +191,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Schema1.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static Schema1Map validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema1.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema1.class, arg, configuration);
}
}
Expand Down Expand Up @@ -245,11 +253,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Allof1.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenMap<String, Object> validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Allof1.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Allof1.class, arg, configuration);
}
}}
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Schema02.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenMap<String, Object> validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema02.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema02.class, arg, configuration);
}
}
Expand Down Expand Up @@ -118,11 +118,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Schema01.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenMap<String, Object> validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema01.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema01.class, arg, configuration);
}
}
Expand Down Expand Up @@ -171,11 +171,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(Schema0.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenMap<String, Object> validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(Schema0.class, arg, configuration);
}
}
Expand Down Expand Up @@ -238,11 +238,11 @@ public static String validate(UUID arg, SchemaConfiguration configuration) throw
return JsonSchema.validate(AllofCombinedWithAnyofOneof1.class, arg, configuration);
}

public static <T extends FrozenMap> T validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenMap<String, Object> validate(Map<String, Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AllofCombinedWithAnyofOneof1.class, arg, configuration);
}

public static <U extends FrozenList> U validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
public static FrozenList<Object> validate(List<Object> arg, SchemaConfiguration configuration) throws ValidationException {
return JsonSchema.validate(AllofCombinedWithAnyofOneof1.class, arg, configuration);
}
}}
Loading