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

Commit 208b7cb

Browse files
authored
Issue 246 fix (#252)
* Fixes headers typo * Adds class properties to fix mypy errors for api response * Converts api response classes back into dataclasses * Petstore regen * Adds typeschema debugging * Updates java schema addition to be permissive * Does not add schema if additionalProperties is false * Samples regenerated * Regens samples, fixes maps with values that are refed * Fixes python test * Adds java tests
1 parent 06f86e9 commit 208b7cb

File tree

823 files changed

+2550
-6000
lines changed

Some content is hidden

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

823 files changed

+2550
-6000
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Key | Type | Description | Notes
3434

3535
## AdditionalpropertiesAllowsASchemaWhichShouldValidateDict
3636
```
37-
base class: schemas.immutabledict[str, bool]
37+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
3838
3939
```
4040
### __new__ method

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Key | Type | Description | Notes
3737

3838
## _0Dict
3939
```
40-
base class: schemas.immutabledict[str, int]
40+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
4141
4242
```
4343
### __new__ method
@@ -78,7 +78,7 @@ Key | Type | Description | Notes
7878

7979
## _1Dict
8080
```
81-
base class: schemas.immutabledict[str, str]
81+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
8282
8383
```
8484
### __new__ method

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Key | Type | Description | Notes
2020

2121
## AllofWithBaseSchemaDict
2222
```
23-
base class: schemas.immutabledict[str, int]
23+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2424
2525
```
2626
### __new__ method
@@ -68,7 +68,7 @@ Key | Type | Description | Notes
6868

6969
## _0Dict
7070
```
71-
base class: schemas.immutabledict[str, str]
71+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
7272
7373
```
7474
### __new__ method
@@ -109,7 +109,7 @@ Key | Type | Description | Notes
109109

110110
## _1Dict
111111
```
112-
base class: schemas.immutabledict[str, None]
112+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
113113
114114
```
115115
### __new__ method

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Key | Type | Description | Notes
3737

3838
## _0Dict
3939
```
40-
base class: schemas.immutabledict[str, int]
40+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
4141
4242
```
4343
### __new__ method
@@ -78,7 +78,7 @@ Key | Type | Description | Notes
7878

7979
## _1Dict
8080
```
81-
base class: schemas.immutabledict[str, str]
81+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
8282
8383
```
8484
### __new__ method

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Key | Type | Description | Notes
2121

2222
## EnumsInPropertiesDict
2323
```
24-
base class: schemas.immutabledict[str, str]
24+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2525
2626
```
2727
### __new__ method

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Key | Type | Description | Notes
2121
## ForbiddenPropertyDict
2222
```
2323
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
24+
2425
```
2526
### __new__ method
2627
Keyword Argument | Type | Description | Notes

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Key | Type | Description | Notes
2020

2121
## InvalidStringValueForDefaultDict
2222
```
23-
base class: schemas.immutabledict[str, str]
23+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2424
2525
```
2626
### __new__ method

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Key | Type | Description | Notes
3636

3737
## NotDict
3838
```
39-
base class: schemas.immutabledict[str, str]
39+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
4040
4141
```
4242
### __new__ method

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Key | Type | Description | Notes
3737

3838
## _0Dict
3939
```
40-
base class: schemas.immutabledict[str, int]
40+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
4141
4242
```
4343
### __new__ method
@@ -78,7 +78,7 @@ Key | Type | Description | Notes
7878

7979
## _1Dict
8080
```
81-
base class: schemas.immutabledict[str, str]
81+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
8282
8383
```
8484
### __new__ method

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Key | Type | Description | Notes
3939
## _0Dict
4040
```
4141
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
42+
4243
```
4344
### __new__ method
4445
Keyword Argument | Type | Description | Notes
@@ -82,6 +83,7 @@ Key | Type | Description | Notes
8283
## _1Dict
8384
```
8485
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
86+
8587
```
8688
### __new__ method
8789
Keyword Argument | Type | Description | Notes

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Key | Type | Description | Notes
2525

2626
## PropertiesWithEscapedCharactersDict
2727
```
28-
base class: schemas.immutabledict[str, typing.Union[int, float]]
28+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2929
3030
```
3131
### __new__ method
@@ -37,7 +37,7 @@ Keyword Argument | Type | Description | Notes
3737
Method | Input Type | Return Type | Notes
3838
------ | ---------- | ----------- | ------
3939
from_dict_ | [PropertiesWithEscapedCharactersDictInput](#propertieswithescapedcharactersdictinput), [PropertiesWithEscapedCharactersDict](#propertieswithescapedcharactersdict), str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | [PropertiesWithEscapedCharactersDict](#propertieswithescapedcharactersdict), str, float, int, bool, None, tuple, bytes, io.FileIO | a constructor
40-
__getitem__ | str | float, int | This model has invalid python names so this method is used under the hood when you access instance["foo\nbar"], instance["foo\"bar"], instance["foo\\bar"], instance["foo\rbar"], instance["foo\tbar"], instance["foo\fbar"],
40+
__getitem__ | str | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | This model has invalid python names so this method is used under the hood when you access instance["foo\nbar"], instance["foo\"bar"], instance["foo\\bar"], instance["foo\rbar"], instance["foo\tbar"], instance["foo\fbar"],
4141
get_additional_property_ | str | schemas.immutabledict, tuple, float, int, str, bool, None, bytes, schemas.FileIO, schemas.Unset }} | provides type safety for additional properties
4242

4343
[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Key | Type | Description | Notes
2020

2121
## PropertyNamedRefThatIsNotAReferenceDict
2222
```
23-
base class: schemas.immutabledict[str, str]
23+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2424
2525
```
2626
### __new__ method
@@ -32,7 +32,7 @@ Keyword Argument | Type | Description | Notes
3232
Method | Input Type | Return Type | Notes
3333
------ | ---------- | ----------- | ------
3434
from_dict_ | [PropertyNamedRefThatIsNotAReferenceDictInput](#propertynamedrefthatisnotareferencedictinput), [PropertyNamedRefThatIsNotAReferenceDict](#propertynamedrefthatisnotareferencedict), str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | [PropertyNamedRefThatIsNotAReferenceDict](#propertynamedrefthatisnotareferencedict), str, float, int, bool, None, tuple, bytes, io.FileIO | a constructor
35-
__getitem__ | str | str | This model has invalid python names so this method is used under the hood when you access instance["$ref"],
35+
__getitem__ | str | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | This model has invalid python names so this method is used under the hood when you access instance["$ref"],
3636
get_additional_property_ | str | schemas.immutabledict, tuple, float, int, str, bool, None, bytes, schemas.FileIO, schemas.Unset }} | provides type safety for additional properties
3737

3838
[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Key | Type | Description | Notes
2626
## RefInAdditionalpropertiesDict
2727
```
2828
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
29+
2930
```
3031
### __new__ method
3132
Keyword Argument | Type | Description | Notes

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Key | Type | Description | Notes
2121
## RefInPropertyDict
2222
```
2323
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
24+
2425
```
2526
### __new__ method
2627
Keyword Argument | Type | Description | Notes

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Key | Type | Description | Notes
2626
## RequiredWithEscapedCharactersDict
2727
```
2828
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
29+
2930
```
3031
### __new__ method
3132
Keyword Argument | Type | Description | Notes
@@ -36,7 +37,7 @@ Keyword Argument | Type | Description | Notes
3637
Method | Input Type | Return Type | Notes
3738
------ | ---------- | ----------- | ------
3839
from_dict_ | [RequiredWithEscapedCharactersDictInput](#requiredwithescapedcharactersdictinput), [RequiredWithEscapedCharactersDict](#requiredwithescapedcharactersdict), str, datetime.date, datetime.datetime, uuid.UUID, int, float, bool, None, list, tuple, bytes, io.FileIO, io.BufferedReader | [RequiredWithEscapedCharactersDict](#requiredwithescapedcharactersdict), str, float, int, bool, None, tuple, bytes, io.FileIO | a constructor
39-
__getitem__ | str | schemas.OUTPUT_BASE_TYPES | This model has invalid python names so this method is used under the hood when you access instance["foo\tbar"], instance["foo\nbar"], instance["foo\fbar"], instance["foo\rbar"], instance["foo\"bar"], instance["foo\\bar"],
40+
__getitem__ | str | schemas.immutabledict, str, float, int, bool, None, tuple, bytes, io.FileIO | This model has invalid python names so this method is used under the hood when you access instance["foo\tbar"], instance["foo\nbar"], instance["foo\fbar"], instance["foo\rbar"], instance["foo\"bar"], instance["foo\\bar"],
4041
get_additional_property_ | str | schemas.immutabledict, tuple, float, int, str, bool, None, bytes, schemas.FileIO, schemas.Unset }} | provides type safety for additional properties
4142

4243
[[Back to top]](#top) [[Back to Component Schemas]](../../../README.md#Component-Schemas) [[Back to README]](../../../README.md)

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Key | Type | Description | Notes
2020

2121
## TheDefaultKeywordDoesNotDoAnythingIfThePropertyIsMissingDict
2222
```
23-
base class: schemas.immutabledict[str, typing.Union[int, float]]
23+
base class: schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]
2424
2525
```
2626
### __new__ method

samples/client/3_0_3_unit_test/python/src/unit_test_api/api_response.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,15 @@
1414
from unit_test_api import schemas
1515

1616

17+
@dataclasses.dataclass(frozen=True)
1718
class ApiResponse:
18-
def __init__(
19-
self,
20-
*,
21-
response: urllib3.HTTPResponse,
22-
body: typing.Union[schemas.Unset, schemas.OUTPUT_BASE_TYPES] = schemas.unset,
23-
headers: typing.Union[schemas.Unset, typing.Mapping[str, schemas.OUTPUT_BASE_TYPES]] = schemas.unset
24-
):
25-
self.response = response
26-
self.body = body
27-
self. headers = headers
19+
response: urllib3.HTTPResponse
20+
body: typing.Union[schemas.Unset, schemas.OUTPUT_BASE_TYPES]
21+
headers: typing.Union[schemas.Unset, typing.Mapping[str, schemas.OUTPUT_BASE_TYPES]]
2822

2923

24+
@dataclasses.dataclass(frozen=True)
3025
class ApiResponseWithoutDeserialization(ApiResponse):
31-
def __init__(
32-
self,
33-
*,
34-
response: urllib3.HTTPResponse,
35-
body: schemas.Unset = schemas.unset,
36-
headers: schemas.Unset = schemas.unset
37-
):
38-
self.response = response
39-
self.body = body
40-
self. headers = headers
26+
response: urllib3.HTTPResponse
27+
body: schemas.Unset = schemas.unset
28+
headers: schemas.Unset = schemas.unset

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424

25-
class AdditionalpropertiesAllowsASchemaWhichShouldValidateDict(schemas.immutabledict[str, bool]):
25+
class AdditionalpropertiesAllowsASchemaWhichShouldValidateDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
2626

2727
__required_keys__: typing.FrozenSet[str] = frozenset({
2828
})
@@ -74,20 +74,14 @@ def foo(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
7474
val = self.get("foo", schemas.unset)
7575
if isinstance(val, schemas.Unset):
7676
return val
77-
return typing.cast(
78-
schemas.OUTPUT_BASE_TYPES,
79-
val
80-
)
77+
return val
8178

8279
@property
8380
def bar(self) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
8481
val = self.get("bar", schemas.unset)
8582
if isinstance(val, schemas.Unset):
8683
return val
87-
return typing.cast(
88-
schemas.OUTPUT_BASE_TYPES,
89-
val
90-
)
84+
return val
9185

9286
def get_additional_property_(self, name: str) -> typing.Union[bool, schemas.Unset]:
9387
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
class _0Dict(schemas.immutabledict[str, int]):
22+
class _0Dict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
2323

2424
__required_keys__: typing.FrozenSet[str] = frozenset({
2525
"bar",
@@ -91,7 +91,7 @@ class _0(
9191
)
9292

9393

94-
class _1Dict(schemas.immutabledict[str, str]):
94+
class _1Dict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
9595

9696
__required_keys__: typing.FrozenSet[str] = frozenset({
9797
"foo",
@@ -125,7 +125,10 @@ def from_dict_(
125125

126126
@property
127127
def foo(self) -> str:
128-
return self.__getitem__("foo")
128+
return typing.cast(
129+
str,
130+
self.__getitem__("foo")
131+
)
129132

130133
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
131134
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
class _0Dict(schemas.immutabledict[str, str]):
22+
class _0Dict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
2323

2424
__required_keys__: typing.FrozenSet[str] = frozenset({
2525
"foo",
@@ -53,7 +53,10 @@ def from_dict_(
5353

5454
@property
5555
def foo(self) -> str:
56-
return self.__getitem__("foo")
56+
return typing.cast(
57+
str,
58+
self.__getitem__("foo")
59+
)
5760

5861
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
5962
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)
@@ -88,7 +91,7 @@ class _0(
8891
)
8992

9093

91-
class _1Dict(schemas.immutabledict[str, None]):
94+
class _1Dict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
9295

9396
__required_keys__: typing.FrozenSet[str] = frozenset({
9497
"baz",
@@ -122,7 +125,10 @@ def from_dict_(
122125

123126
@property
124127
def baz(self) -> None:
125-
return self.__getitem__("baz")
128+
return typing.cast(
129+
None,
130+
self.__getitem__("baz")
131+
)
126132

127133
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
128134
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)
@@ -161,7 +167,7 @@ class _1(
161167
)
162168

163169

164-
class AllofWithBaseSchemaDict(schemas.immutabledict[str, int]):
170+
class AllofWithBaseSchemaDict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
165171

166172
__required_keys__: typing.FrozenSet[str] = frozenset({
167173
"bar",

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020

2121

22-
class _0Dict(schemas.immutabledict[str, int]):
22+
class _0Dict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
2323

2424
__required_keys__: typing.FrozenSet[str] = frozenset({
2525
"bar",
@@ -91,7 +91,7 @@ class _0(
9191
)
9292

9393

94-
class _1Dict(schemas.immutabledict[str, str]):
94+
class _1Dict(schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES]):
9595

9696
__required_keys__: typing.FrozenSet[str] = frozenset({
9797
"foo",
@@ -125,7 +125,10 @@ def from_dict_(
125125

126126
@property
127127
def foo(self) -> str:
128-
return self.__getitem__("foo")
128+
return typing.cast(
129+
str,
130+
self.__getitem__("foo")
131+
)
129132

130133
def get_additional_property_(self, name: str) -> typing.Union[schemas.OUTPUT_BASE_TYPES, schemas.Unset]:
131134
schemas.raise_if_key_known(name, self.__required_keys__, self.__optional_keys__)

0 commit comments

Comments
 (0)