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

Commit d40e1cf

Browse files
authored
Java, improves schema doc code samples (#321)
* Adds int and long validation for type integer * Handles format types with enum numbers * Casts schema validate examples to the correct output class * Dereferences schemas when generating examples * Samples regen
1 parent 40533c5 commit d40e1cf

File tree

56 files changed

+475
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+475
-161
lines changed

samples/client/3_0_3_unit_test/java/docs/components/schemas/EnumWith0DoesNotMatchFalse.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import java.util.AbstractMap;
3030
3131
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
3232
33-
// Number validation
34-
Number validatedPayload = EnumWith0DoesNotMatchFalse.EnumWith0DoesNotMatchFalse1.validate(
33+
// int validation
34+
int validatedPayload = EnumWith0DoesNotMatchFalse.EnumWith0DoesNotMatchFalse1.validate(
3535
0,
3636
configuration
3737
);

samples/client/3_0_3_unit_test/java/docs/components/schemas/EnumWith1DoesNotMatchTrue.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import java.util.AbstractMap;
3030
3131
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
3232
33-
// Number validation
34-
Number validatedPayload = EnumWith1DoesNotMatchTrue.EnumWith1DoesNotMatchTrue1.validate(
33+
// int validation
34+
int validatedPayload = EnumWith1DoesNotMatchTrue.EnumWith1DoesNotMatchTrue1.validate(
3535
1,
3636
configuration
3737
);

samples/client/3_0_3_unit_test/java/docs/components/schemas/InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import java.util.AbstractMap;
3030
3131
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
3232
33-
// Integer validation
34-
Integer validatedPayload = InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf1.validate(
35-
1,
33+
// long validation
34+
long validatedPayload = InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf.InvalidInstanceShouldNotRaiseErrorWhenFloatDivisionInf1.validate(
35+
1L,
3636
configuration
3737
);
3838
```

samples/client/3_0_3_unit_test/java/docs/components/schemas/NestedItems.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ NestedItems.NestedItemsList validatedPayload =
4545
Arrays.asList(
4646
Arrays.asList(
4747
Arrays.asList(
48-
3.14
48+
1
4949
)
5050
)
5151
)
@@ -110,7 +110,7 @@ NestedItems.ItemsList2 validatedPayload =
110110
Arrays.asList(
111111
Arrays.asList(
112112
Arrays.asList(
113-
3.14
113+
1
114114
)
115115
)
116116
),
@@ -173,7 +173,7 @@ NestedItems.ItemsList1 validatedPayload =
173173
NestedItems.Items1.validate(
174174
Arrays.asList(
175175
Arrays.asList(
176-
3.14
176+
1
177177
)
178178
),
179179
configuration
@@ -234,7 +234,7 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch
234234
NestedItems.ItemsList validatedPayload =
235235
NestedItems.Items2.validate(
236236
Arrays.asList(
237-
3.14
237+
1
238238
),
239239
configuration
240240
);

samples/client/3_0_3_unit_test/java/docs/components/schemas/SimpleEnumValidation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import java.util.AbstractMap;
3030
3131
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
3232
33-
// Number validation
34-
Number validatedPayload = SimpleEnumValidation.SimpleEnumValidation1.validate(
33+
// int validation
34+
int validatedPayload = SimpleEnumValidation.SimpleEnumValidation1.validate(
3535
1,
3636
configuration
3737
);

samples/client/3_0_3_unit_test/java/docs/components/schemas/TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.TheDefaultKeywordDoesNo
3838
MapMaker.makeMap(
3939
new AbstractMap.SimpleEntry<>(
4040
"alpha",
41-
3.14
41+
1
4242
)
4343
),
4444
configuration
@@ -65,7 +65,7 @@ A class to store validated Map payloads
6565
| Modifier and Type | Method and Description |
6666
| ----------------- | ---------------------- |
6767
| static [TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingMap](#thedefaultkeyworddoesnotdoanythingifthepropertyismissingmap) | of(Map<String, Object> arg, SchemaConfiguration configuration) |
68-
| Number | alpha()<br>[optional] if omitted the server will use the default value of 5 |
68+
| Number | alpha()<br>[optional] if omitted the server will use the default value of 5.0 |
6969
| Object | getAdditionalProperty(String name)<br>provides type safety for additional properties |
7070

7171
## Input Map Keys
@@ -74,7 +74,7 @@ type: Map<String, Object>
7474
```
7575
| Key | Type | Description | Notes |
7676
| --- | ---- | ------------ | ----- |
77-
| **alpha** | Number | | [optional] if omitted the server will use the default value of 5 |
77+
| **alpha** | Number | | [optional] if omitted the server will use the default value of 5.0 |
7878
| **anyStringName** | Object | any string name can be used but the value must be the correct type | [optional] |
7979

8080
## Alpha
@@ -98,9 +98,9 @@ import java.util.AbstractMap;
9898
9999
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
100100
101-
// Number validation
102-
Number validatedPayload = TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.Alpha.validate(
103-
3.14,
101+
// int validation
102+
int validatedPayload = TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissing.Alpha.validate(
103+
1,
104104
configuration
105105
);
106106
```

samples/client/3_0_3_unit_test/python/docs/components/schema/the_default_keyword_does_not_do_anything_if_the_property_is_missing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: typing.Mapping[str, schemas.INPUT_TYPES_ALL]
1515
```
1616
Key | Type | Description | Notes
1717
------------ | ------------- | ------------- | -------------
18-
**alpha** | float, int | | [optional] if omitted the server will use the default value of 5
18+
**alpha** | float, int | | [optional] if omitted the server will use the default value of 5.0
1919
**any_string_name** | dict, schemas.immutabledict, list, tuple, decimal.Decimal, float, int, str, datetime.date, datetime.datetime, uuid.UUID, bool, None, bytes, io.FileIO, io.BufferedReader, schemas.FileIO | any string name can be used but the value must be the correct type | [optional]
2020

2121
## TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingDict
@@ -26,13 +26,13 @@ base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2626
### &lowbar;&lowbar;new&lowbar;&lowbar; method
2727
Keyword Argument | Type | Description | Notes
2828
---------------- | ---- | ----------- | -----
29-
**alpha** | float, int, schemas.Unset | | [optional] if omitted the server will use the default value of 5
29+
**alpha** | float, int, schemas.Unset | | [optional] if omitted the server will use the default value of 5.0
3030
**kwargs** | schemas.immutabledict, tuple, float, int, str, bool, None, bytes, schemas.FileIO | any string name can be used but the value must be the correct type | [optional] typed value is accessed with the get_additional_property_ method
3131

3232
### properties
3333
Property | Type | Description | Notes
3434
-------- | ---- | ----------- | -----
35-
**alpha** | float, int, schemas.Unset | | [optional] if omitted the server will use the default value of 5
35+
**alpha** | float, int, schemas.Unset | | [optional] if omitted the server will use the default value of 5.0
3636

3737
### methods
3838
Method | Input Type | Return Type | Notes

samples/client/petstore/java/docs/components/requestbodies/userarray/content/applicationjson/Schema.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,44 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch
3535
Schema.SchemaList validatedPayload =
3636
Schema.Schema1.validate(
3737
Arrays.asList(
38+
MapMaker.makeMap(
39+
new AbstractMap.SimpleEntry<>(
40+
"id",
41+
1L
42+
),
43+
new AbstractMap.SimpleEntry<>(
44+
"username",
45+
"a"
46+
),
47+
new AbstractMap.SimpleEntry<>(
48+
"firstName",
49+
"a"
50+
),
51+
new AbstractMap.SimpleEntry<>(
52+
"lastName",
53+
"a"
54+
),
55+
new AbstractMap.SimpleEntry<>(
56+
"email",
57+
"a"
58+
),
59+
new AbstractMap.SimpleEntry<>(
60+
"password",
61+
"a"
62+
),
63+
new AbstractMap.SimpleEntry<>(
64+
"phone",
65+
"a"
66+
),
67+
new AbstractMap.SimpleEntry<>(
68+
"userStatus",
69+
1
70+
),
71+
new AbstractMap.SimpleEntry<>(
72+
"objectWithNoDeclaredPropsNullable",
73+
(Void) null
74+
)
75+
)
3876
),
3977
configuration
4078
);

samples/client/petstore/java/docs/components/responses/successfulxmlandjsonarrayofpet/content/applicationjson/Schema.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,50 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch
3535
Schema.SchemaList validatedPayload =
3636
Schema.Schema1.validate(
3737
Arrays.asList(
38+
MapMaker.makeMap(
39+
new AbstractMap.SimpleEntry<>(
40+
"name",
41+
"a"
42+
),
43+
new AbstractMap.SimpleEntry<>(
44+
"photoUrls",
45+
Arrays.asList(
46+
"a"
47+
)
48+
),
49+
new AbstractMap.SimpleEntry<>(
50+
"id",
51+
1L
52+
),
53+
new AbstractMap.SimpleEntry<>(
54+
"category",
55+
MapMaker.makeMap(
56+
new AbstractMap.SimpleEntry<>(
57+
"name",
58+
"a"
59+
),
60+
new AbstractMap.SimpleEntry<>(
61+
"id",
62+
1L
63+
)
64+
)
65+
),
66+
new AbstractMap.SimpleEntry<>(
67+
"tags",
68+
Arrays.asList(
69+
MapMaker.makeMap(
70+
new AbstractMap.SimpleEntry<>(
71+
"name",
72+
"a"
73+
)
74+
)
75+
)
76+
),
77+
new AbstractMap.SimpleEntry<>(
78+
"status",
79+
"available"
80+
)
81+
)
3882
),
3983
configuration
4084
);

samples/client/petstore/java/docs/components/responses/successfulxmlandjsonarrayofpet/content/applicationxml/Schema.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,50 @@ static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSch
3535
Schema.SchemaList validatedPayload =
3636
Schema.Schema1.validate(
3737
Arrays.asList(
38+
MapMaker.makeMap(
39+
new AbstractMap.SimpleEntry<>(
40+
"name",
41+
"a"
42+
),
43+
new AbstractMap.SimpleEntry<>(
44+
"photoUrls",
45+
Arrays.asList(
46+
"a"
47+
)
48+
),
49+
new AbstractMap.SimpleEntry<>(
50+
"id",
51+
1L
52+
),
53+
new AbstractMap.SimpleEntry<>(
54+
"category",
55+
MapMaker.makeMap(
56+
new AbstractMap.SimpleEntry<>(
57+
"name",
58+
"a"
59+
),
60+
new AbstractMap.SimpleEntry<>(
61+
"id",
62+
1L
63+
)
64+
)
65+
),
66+
new AbstractMap.SimpleEntry<>(
67+
"tags",
68+
Arrays.asList(
69+
MapMaker.makeMap(
70+
new AbstractMap.SimpleEntry<>(
71+
"name",
72+
"a"
73+
)
74+
)
75+
)
76+
),
77+
new AbstractMap.SimpleEntry<>(
78+
"status",
79+
"available"
80+
)
81+
)
3882
),
3983
configuration
4084
);

0 commit comments

Comments
 (0)