Skip to content

Commit 4d7e4d8

Browse files
authored
Merge branch 'main' into dependabot/pip/pyyaml-5.4.1
2 parents c5ed84a + d08b7d5 commit 4d7e4d8

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
project info.
1616
- `none` will not create a project folder at all, only the inner package folder (which won't be inner anymore)
1717
- Attempt to detect and alert users if they are using an unsupported version of OpenAPI (#281).
18+
- Fixes `Enum` deserialization when the value is `UNSET`.
19+
- Add handling of application/vnd.api+json media type.
1820

1921
### Changes
2022

end_to_end_tests/golden-record-custom/custom_e2e/models/model_with_union_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def _parse_a_property(data: Any) -> Union[Unset, AnEnum, AnIntEnum]:
4646
try:
4747
a_property = UNSET
4848
_a_property = data
49-
if _a_property is not None:
49+
if _a_property is not None and _a_property is not UNSET:
5050
a_property = AnEnum(_a_property)
5151

5252
return a_property
5353
except: # noqa: E722
5454
pass
5555
a_property = UNSET
5656
_a_property = data
57-
if _a_property is not None:
57+
if _a_property is not None and _a_property is not UNSET:
5858
a_property = AnIntEnum(_a_property)
5959

6060
return a_property

end_to_end_tests/golden-record/my_test_api_client/models/model_with_union_property.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ def _parse_a_property(data: Any) -> Union[Unset, AnEnum, AnIntEnum]:
4646
try:
4747
a_property = UNSET
4848
_a_property = data
49-
if _a_property is not None:
49+
if _a_property is not None and _a_property is not UNSET:
5050
a_property = AnEnum(_a_property)
5151

5252
return a_property
5353
except: # noqa: E722
5454
pass
5555
a_property = UNSET
5656
_a_property = data
57-
if _a_property is not None:
57+
if _a_property is not None and _a_property is not UNSET:
5858
a_property = AnIntEnum(_a_property)
5959

6060
return a_property

openapi_python_client/parser/responses.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Response:
2020

2121
_SOURCE_BY_CONTENT_TYPE = {
2222
"application/json": "response.json()",
23+
"application/vnd.api+json": "response.json()",
2324
"application/octet-stream": "response.content",
2425
"text/html": "response.text",
2526
}

openapi_python_client/templates/property_templates/enum_property.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% else %}
55
{{ property.python_name }} = {{ initial_value }}
66
_{{ property.python_name }} = {{ source }}
7-
if _{{ property.python_name }} is not None:
7+
if _{{ property.python_name }} is not None and _{{ property.python_name }} is not UNSET:
88
{{ property.python_name }} = {{ property.reference.class_name }}(_{{ property.python_name }})
99
{% endif %}
1010
{% endmacro %}

0 commit comments

Comments
 (0)