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

Commit d41a95e

Browse files
authored
Generators, adjusts storage of exclusiveMaximum/exclusiveMinimum (#316)
* Adjusts storage of max/min/exclMax/Min * Fixes java tests * Updates python templates * Fiexes anytype template schemas for python * Move java fixes, add org.codehaus.janino back in * Samples regen * Updates python templates to use isSimpleX * Samples updated * Improves exclusive max and min handling in python templates * Fixes handling uniqueItems in python * Adds sample schema with exclusive min and max * Samples updated * Fixes java doc * Adds java tests * Sample regen
1 parent dd92159 commit d41a95e

35 files changed

Lines changed: 573 additions & 79 deletions

File tree

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@
438438
<artifactId>logback-core</artifactId>
439439
<version>${logback.version}</version>
440440
</dependency>
441+
<dependency>
442+
<groupId>org.codehaus.janino</groupId>
443+
<artifactId>janino</artifactId>
444+
<version>3.1.11</version>
445+
</dependency>
441446
</dependencies>
442447
<properties>
443448
<!-- RELEASE_VERSION -->

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_validation.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,17 @@
1010
from __future__ import annotations
1111
from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

13-
UniqueitemsFalseValidation: typing_extensions.TypeAlias = schemas.AnyTypeSchema
13+
14+
15+
@dataclasses.dataclass(frozen=True)
16+
class UniqueitemsFalseValidation(
17+
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
18+
):
19+
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
20+
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
21+
22+
Do not edit the class manually.
23+
"""
24+
# any type
25+
unique_items: bool = False
26+

samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_validation.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,17 @@
1010
from __future__ import annotations
1111
from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

13-
UniqueitemsFalseValidation: typing_extensions.TypeAlias = schemas.AnyTypeSchema
13+
14+
15+
@dataclasses.dataclass(frozen=True)
16+
class UniqueitemsFalseValidation(
17+
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
18+
):
19+
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
20+
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
21+
22+
Do not edit the class manually.
23+
"""
24+
# any type
25+
unique_items: bool = False
26+

samples/client/3_1_0_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_with_an_array_of_items.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ class UniqueitemsFalseWithAnArrayOfItems(
3131
_0,
3232
_1,
3333
)
34+
unique_items: bool = False
3435

samples/client/petstore/java/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ docs/components/schemas/NullableShape.md
103103
docs/components/schemas/NullableString.md
104104
docs/components/schemas/NumberOnly.md
105105
docs/components/schemas/NumberSchema.md
106+
docs/components/schemas/NumberWithExclusiveMinMax.md
106107
docs/components/schemas/NumberWithValidations.md
107108
docs/components/schemas/ObjWithRequiredProps.md
108109
docs/components/schemas/ObjWithRequiredPropsBase.md
@@ -406,6 +407,7 @@ src/main/java/org/openapijsonschematools/client/components/schemas/NullableShape
406407
src/main/java/org/openapijsonschematools/client/components/schemas/NullableString.java
407408
src/main/java/org/openapijsonschematools/client/components/schemas/NumberOnly.java
408409
src/main/java/org/openapijsonschematools/client/components/schemas/NumberSchema.java
410+
src/main/java/org/openapijsonschematools/client/components/schemas/NumberWithExclusiveMinMax.java
409411
src/main/java/org/openapijsonschematools/client/components/schemas/NumberWithValidations.java
410412
src/main/java/org/openapijsonschematools/client/components/schemas/ObjWithRequiredProps.java
411413
src/main/java/org/openapijsonschematools/client/components/schemas/ObjWithRequiredPropsBase.java

samples/client/petstore/java/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ allowed input and output types.
234234
| [NullableString.NullableString1](docs/components/schemas/NullableString.md#nullablestring1) | |
235235
| [NumberSchema.NumberSchema1](docs/components/schemas/NumberSchema.md#numberschema1) | |
236236
| [NumberOnly.NumberOnly1](docs/components/schemas/NumberOnly.md#numberonly1) | |
237+
| [NumberWithExclusiveMinMax.NumberWithExclusiveMinMax1](docs/components/schemas/NumberWithExclusiveMinMax.md#numberwithexclusiveminmax1) | |
237238
| [NumberWithValidations.NumberWithValidations1](docs/components/schemas/NumberWithValidations.md#numberwithvalidations1) | |
238239
| [ObjWithRequiredProps.ObjWithRequiredProps1](docs/components/schemas/ObjWithRequiredProps.md#objwithrequiredprops1) | |
239240
| [ObjWithRequiredPropsBase.ObjWithRequiredPropsBase1](docs/components/schemas/ObjWithRequiredPropsBase.md#objwithrequiredpropsbase1) | |
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# NumberWithExclusiveMinMax
2+
org.openapijsonschematools.client.components.schemas.NumberWithExclusiveMinMax.java
3+
public class NumberWithExclusiveMinMax
4+
5+
A class that contains necessary nested schema classes, and classes to store validated list and map payloads
6+
7+
## Nested Class Summary
8+
| Modifier and Type | Class and Description |
9+
| ----------------- | ---------------------- |
10+
| static class | [NumberWithExclusiveMinMax.NumberWithExclusiveMinMax1](#numberwithexclusiveminmax1)<br> schema class |
11+
12+
## NumberWithExclusiveMinMax1
13+
public static class NumberWithExclusiveMinMax1<br>
14+
extends JsonSchema
15+
16+
A schema class that validates payloads
17+
### Field Summary
18+
| Modifier and Type | Field and Description |
19+
| ----------------- | ---------------------- |
20+
| 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;Integer.class,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Long.class,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Float.class,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Double.class<br/>&nbsp;&nbsp;&nbsp;&nbsp;))),<br/>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("exclusiveMaximum", new ExclusiveMaximumValidator(12)),<br>&nbsp;&nbsp;&nbsp;&nbsp;new KeywordEntry("exclusiveMinimum", new ExclusiveMinimumValidator(10))<br>)); |
21+
22+
### Method Summary
23+
| Modifier and Type | Method and Description |
24+
| ----------------- | ---------------------- |
25+
| static Number | validate(Number arg, SchemaConfiguration configuration) |
26+
27+
[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package org.openapijsonschematools.client.components.schemas;
2+
import java.util.LinkedHashMap;
3+
import java.util.Map;
4+
import java.util.Set;
5+
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
6+
import org.openapijsonschematools.client.exceptions.ValidationException;
7+
import org.openapijsonschematools.client.schemas.validation.ExclusiveMaximumValidator;
8+
import org.openapijsonschematools.client.schemas.validation.ExclusiveMinimumValidator;
9+
import org.openapijsonschematools.client.schemas.validation.JsonSchema;
10+
import org.openapijsonschematools.client.schemas.validation.KeywordEntry;
11+
import org.openapijsonschematools.client.schemas.validation.KeywordValidator;
12+
import org.openapijsonschematools.client.schemas.validation.TypeValidator;
13+
14+
public class NumberWithExclusiveMinMax {
15+
// nest classes so all schemas and input/output classes can be public
16+
17+
18+
public static class NumberWithExclusiveMinMax1 extends JsonSchema {
19+
/*
20+
NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
21+
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
22+
23+
Do not edit the class manually.
24+
*/
25+
public static final LinkedHashMap<String, KeywordValidator> keywordToValidator = new LinkedHashMap<>(Map.ofEntries(
26+
new KeywordEntry("type", new TypeValidator(Set.of(
27+
Integer.class,
28+
Long.class,
29+
Float.class,
30+
Double.class
31+
))),
32+
new KeywordEntry("exclusiveMaximum", new ExclusiveMaximumValidator(12)),
33+
new KeywordEntry("exclusiveMinimum", new ExclusiveMinimumValidator(10))
34+
));
35+
public static int validate(int arg, SchemaConfiguration configuration) throws ValidationException {
36+
return JsonSchema.validateInt(NumberWithExclusiveMinMax1.class, arg, configuration);
37+
}
38+
39+
public static long validate(long arg, SchemaConfiguration configuration) throws ValidationException {
40+
return JsonSchema.validateLong(NumberWithExclusiveMinMax1.class, arg, configuration);
41+
}
42+
43+
public static float validate(float arg, SchemaConfiguration configuration) throws ValidationException {
44+
return JsonSchema.validateFloat(NumberWithExclusiveMinMax1.class, arg, configuration);
45+
}
46+
47+
public static double validate(double arg, SchemaConfiguration configuration) throws ValidationException {
48+
return JsonSchema.validateDouble(NumberWithExclusiveMinMax1.class, arg, configuration);
49+
}
50+
}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.openapijsonschematools.client.components.schemas;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
6+
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
7+
import org.openapijsonschematools.client.exceptions.ValidationException;
8+
import org.openapijsonschematools.client.schemas.validation.JsonSchema;
9+
import org.openapijsonschematools.client.schemas.MapMaker;
10+
11+
import java.util.Arrays;
12+
import java.util.List;
13+
import java.util.AbstractMap;
14+
15+
public class NumberWithExclusiveMinMaxTest {
16+
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
17+
}

samples/client/petstore/python/.openapi-generator/FILES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ docs/components/schema/nullable_shape.md
136136
docs/components/schema/nullable_string.md
137137
docs/components/schema/number.md
138138
docs/components/schema/number_only.md
139+
docs/components/schema/number_with_exclusive_min_max.md
139140
docs/components/schema/number_with_validations.md
140141
docs/components/schema/obj_with_required_props.md
141142
docs/components/schema/obj_with_required_props_base.md
@@ -646,6 +647,7 @@ src/petstore_api/components/schema/nullable_shape.py
646647
src/petstore_api/components/schema/nullable_string.py
647648
src/petstore_api/components/schema/number.py
648649
src/petstore_api/components/schema/number_only.py
650+
src/petstore_api/components/schema/number_with_exclusive_min_max.py
649651
src/petstore_api/components/schema/number_with_validations.py
650652
src/petstore_api/components/schema/obj_with_required_props.py
651653
src/petstore_api/components/schema/obj_with_required_props_base.py

0 commit comments

Comments
 (0)