Skip to content

Commit 4bf52d5

Browse files
authored
Merge branch 'main' into enhance-split-words
2 parents 999a81d + 0f58cfd commit 4bf52d5

27 files changed

+920
-201
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## 0.9.1
8+
9+
### Features
10+
11+
- Allow references to non-object, non-enum types [#371][#418][#425]. Thanks @p1-ra!
12+
- Allow for attrs 21.x in generated clients [#412]
13+
- Allow for using any version of Black [#416] [#411]. Thanks @christhekeele!
14+
15+
### Fixes
16+
17+
- Prevent crash when providing a non-string default to a string attribute. [#414] [#415]
18+
- Deserialization of optional nullable properties when no value is returned from the API [#420] [#381]. Thanks @forest-benchling!
19+
720
## 0.9.0 - 2021-05-04
821

922
### Breaking Changes
@@ -45,9 +58,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4558
- `none` will not create a project folder at all, only the inner package folder (which won't be inner anymore)
4659

4760
- Attempt to detect and alert users if they are using an unsupported version of OpenAPI (#281).
61+
4862
- The media type application/vnd.api+json will now be handled just like application/json (#307). Thanks @jrversteegh!
63+
4964
- Support passing models into query parameters (#316). Thanks @forest-benchling!
65+
5066
- Add support for cookie parameters (#326).
67+
5168
- New `--file-encoding` command line option (#330). Sets the encoding used when writing generated files (defaults to utf-8). Thanks @dongfangtianyu!
5269

5370
### Changes
@@ -96,13 +113,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
96113
### Breaking Changes
97114

98115
- Any request/response field that is not `required` and wasn't specified is now set to `UNSET` instead of `None`.
116+
99117
- Values that are `UNSET` will not be sent along in API calls
118+
100119
- Schemas defined with `type=object` will now be converted into classes, just like if they were created as ref components. The previous behavior was a combination of skipping and using generic Dicts for these schemas.
120+
101121
- Response schema handling was unified with input schema handling, meaning that responses will behave differently than before. Specifically, instead of the content-type deciding what the generated Python type is, the schema itself will.
102122

103123
- As a result of this, endpoints that used to return `bytes` when content-type was application/octet-stream will now return a `File` object if the type of the data is "binary", just like if you were submitting that type instead of receiving it.
104124

105125
- Instead of skipping input properties with no type, enum, anyOf, or oneOf declared, the property will be declared as `None`.
126+
106127
- Class (models and Enums) names will now contain the name of their parent element (if any). For example, a property declared in an endpoint will be named like {endpoint*name}*{previous*class*name}. Classes will no longer be deduplicated by appending a number to the end of the generated name, so if two names conflict with this new naming scheme, there will be an error instead.
107128

108129
### Additions
@@ -268,6 +289,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
268289
### Changes
269290

270291
- The way most imports are handled was changed which _should_ lead to fewer unused imports in generated files.
292+
271293
- Better error messages
272294

273295
- Most error messages will contain some useful information about why it failed instead of a stack trace

dobby.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[[workflows]]
2-
name = "Start Task"
2+
name = "task"
33
[[workflows.steps]]
44
type = "SelectGitHubIssue"
55

66
[[workflows.steps]]
77
type = "SwitchBranches"
88

99
[[workflows]]
10-
name = "Prepare Release"
10+
name = "release"
1111
[[workflows.steps]]
1212
type = "UpdateProjectFromCommits"
1313

1414
[[workflows.steps]]
1515
type = "Command"
16-
command = "prettier --write CHANGELOG.md"
16+
command = "npx prettier --write CHANGELOG.md"
1717

1818
[github]
1919
owner = "triaxtec"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
""" Contains all the data models used in inputs/outputs """
22

33
from .a_model import AModel
4+
from .a_model_with_properties_reference_that_are_not_object import AModelWithPropertiesReferenceThatAreNotObject
45
from .all_of_sub_model import AllOfSubModel
56
from .an_all_of_enum import AnAllOfEnum
67
from .an_enum import AnEnum

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

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
186186

187187
def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.datetime]:
188188
try:
189-
a_camel_date_time_type_0: datetime.datetime
190189
if not isinstance(data, str):
191190
raise TypeError()
192191
a_camel_date_time_type_0 = isoparse(data)
@@ -196,7 +195,6 @@ def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.date
196195
pass
197196
if not isinstance(data, str):
198197
raise TypeError()
199-
a_camel_date_time_type_1: datetime.date
200198
a_camel_date_time_type_1 = isoparse(data).date()
201199

202200
return a_camel_date_time_type_1
@@ -209,7 +207,6 @@ def _parse_a_camel_date_time(data: object) -> Union[datetime.date, datetime.date
209207

210208
def _parse_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionProperty]:
211209
try:
212-
one_of_models_type_0: FreeFormModel
213210
if not isinstance(data, dict):
214211
raise TypeError()
215212
one_of_models_type_0 = FreeFormModel.from_dict(data)
@@ -219,7 +216,6 @@ def _parse_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionPro
219216
pass
220217
if not isinstance(data, dict):
221218
raise TypeError()
222-
one_of_models_type_1: ModelWithUnionProperty
223219
one_of_models_type_1 = ModelWithUnionProperty.from_dict(data)
224220

225221
return one_of_models_type_1
@@ -228,9 +224,11 @@ def _parse_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionPro
228224

229225
model = ModelWithUnionProperty.from_dict(d.pop("model"))
230226

231-
an_optional_allof_enum: Union[Unset, AnAllOfEnum] = UNSET
232227
_an_optional_allof_enum = d.pop("an_optional_allof_enum", UNSET)
233-
if not isinstance(_an_optional_allof_enum, Unset):
228+
an_optional_allof_enum: Union[Unset, AnAllOfEnum]
229+
if isinstance(_an_optional_allof_enum, Unset):
230+
an_optional_allof_enum = UNSET
231+
else:
234232
an_optional_allof_enum = AnAllOfEnum(_an_optional_allof_enum)
235233

236234
nested_list_of_enums = []
@@ -245,14 +243,18 @@ def _parse_one_of_models(data: object) -> Union[FreeFormModel, ModelWithUnionPro
245243

246244
nested_list_of_enums.append(nested_list_of_enums_item)
247245

248-
a_nullable_date = None
249246
_a_nullable_date = d.pop("a_nullable_date")
250-
if _a_nullable_date is not None:
247+
a_nullable_date: Optional[datetime.date]
248+
if _a_nullable_date is None:
249+
a_nullable_date = None
250+
else:
251251
a_nullable_date = isoparse(_a_nullable_date).date()
252252

253-
a_not_required_date: Union[Unset, datetime.date] = UNSET
254253
_a_not_required_date = d.pop("a_not_required_date", UNSET)
255-
if not isinstance(_a_not_required_date, Unset):
254+
a_not_required_date: Union[Unset, datetime.date]
255+
if isinstance(_a_not_required_date, Unset):
256+
a_not_required_date = UNSET
257+
else:
256258
a_not_required_date = isoparse(_a_not_required_date).date()
257259

258260
attr_1_leading_digit = d.pop("1_leading_digit", UNSET)
@@ -267,7 +269,6 @@ def _parse_nullable_one_of_models(data: object) -> Union[FreeFormModel, ModelWit
267269
if data is None:
268270
return data
269271
try:
270-
nullable_one_of_models_type_0: FreeFormModel
271272
if not isinstance(data, dict):
272273
raise TypeError()
273274
nullable_one_of_models_type_0 = FreeFormModel.from_dict(data)
@@ -277,7 +278,6 @@ def _parse_nullable_one_of_models(data: object) -> Union[FreeFormModel, ModelWit
277278
pass
278279
if not isinstance(data, dict):
279280
raise TypeError()
280-
nullable_one_of_models_type_1: ModelWithUnionProperty
281281
nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(data)
282282

283283
return nullable_one_of_models_type_1
@@ -288,23 +288,25 @@ def _parse_not_required_one_of_models(data: object) -> Union[FreeFormModel, Mode
288288
if isinstance(data, Unset):
289289
return data
290290
try:
291-
not_required_one_of_models_type_0: Union[Unset, FreeFormModel]
292291
if not isinstance(data, dict):
293292
raise TypeError()
294-
not_required_one_of_models_type_0 = UNSET
295293
_not_required_one_of_models_type_0 = data
296-
if not isinstance(_not_required_one_of_models_type_0, Unset):
294+
not_required_one_of_models_type_0: Union[Unset, FreeFormModel]
295+
if isinstance(_not_required_one_of_models_type_0, Unset):
296+
not_required_one_of_models_type_0 = UNSET
297+
else:
297298
not_required_one_of_models_type_0 = FreeFormModel.from_dict(_not_required_one_of_models_type_0)
298299

299300
return not_required_one_of_models_type_0
300301
except: # noqa: E722
301302
pass
302303
if not isinstance(data, dict):
303304
raise TypeError()
304-
not_required_one_of_models_type_1: Union[Unset, ModelWithUnionProperty]
305-
not_required_one_of_models_type_1 = UNSET
306305
_not_required_one_of_models_type_1 = data
307-
if not isinstance(_not_required_one_of_models_type_1, Unset):
306+
not_required_one_of_models_type_1: Union[Unset, ModelWithUnionProperty]
307+
if isinstance(_not_required_one_of_models_type_1, Unset):
308+
not_required_one_of_models_type_1 = UNSET
309+
else:
308310
not_required_one_of_models_type_1 = ModelWithUnionProperty.from_dict(_not_required_one_of_models_type_1)
309311

310312
return not_required_one_of_models_type_1
@@ -319,12 +321,13 @@ def _parse_not_required_nullable_one_of_models(
319321
if isinstance(data, Unset):
320322
return data
321323
try:
322-
not_required_nullable_one_of_models_type_0: Union[Unset, FreeFormModel]
323324
if not isinstance(data, dict):
324325
raise TypeError()
325-
not_required_nullable_one_of_models_type_0 = UNSET
326326
_not_required_nullable_one_of_models_type_0 = data
327-
if not isinstance(_not_required_nullable_one_of_models_type_0, Unset):
327+
not_required_nullable_one_of_models_type_0: Union[Unset, FreeFormModel]
328+
if isinstance(_not_required_nullable_one_of_models_type_0, Unset):
329+
not_required_nullable_one_of_models_type_0 = UNSET
330+
else:
328331
not_required_nullable_one_of_models_type_0 = FreeFormModel.from_dict(
329332
_not_required_nullable_one_of_models_type_0
330333
)
@@ -333,12 +336,13 @@ def _parse_not_required_nullable_one_of_models(
333336
except: # noqa: E722
334337
pass
335338
try:
336-
not_required_nullable_one_of_models_type_1: Union[Unset, ModelWithUnionProperty]
337339
if not isinstance(data, dict):
338340
raise TypeError()
339-
not_required_nullable_one_of_models_type_1 = UNSET
340341
_not_required_nullable_one_of_models_type_1 = data
341-
if not isinstance(_not_required_nullable_one_of_models_type_1, Unset):
342+
not_required_nullable_one_of_models_type_1: Union[Unset, ModelWithUnionProperty]
343+
if isinstance(_not_required_nullable_one_of_models_type_1, Unset):
344+
not_required_nullable_one_of_models_type_1 = UNSET
345+
else:
342346
not_required_nullable_one_of_models_type_1 = ModelWithUnionProperty.from_dict(
343347
_not_required_nullable_one_of_models_type_1
344348
)
@@ -352,19 +356,27 @@ def _parse_not_required_nullable_one_of_models(
352356
d.pop("not_required_nullable_one_of_models", UNSET)
353357
)
354358

355-
nullable_model = None
356359
_nullable_model = d.pop("nullable_model")
357-
if _nullable_model is not None:
360+
nullable_model: Optional[ModelWithUnionProperty]
361+
if _nullable_model is None:
362+
nullable_model = None
363+
else:
358364
nullable_model = ModelWithUnionProperty.from_dict(_nullable_model)
359365

360-
not_required_model: Union[Unset, ModelWithUnionProperty] = UNSET
361366
_not_required_model = d.pop("not_required_model", UNSET)
362-
if not isinstance(_not_required_model, Unset):
367+
not_required_model: Union[Unset, ModelWithUnionProperty]
368+
if isinstance(_not_required_model, Unset):
369+
not_required_model = UNSET
370+
else:
363371
not_required_model = ModelWithUnionProperty.from_dict(_not_required_model)
364372

365-
not_required_nullable_model = None
366373
_not_required_nullable_model = d.pop("not_required_nullable_model", UNSET)
367-
if _not_required_nullable_model is not None and not isinstance(_not_required_nullable_model, Unset):
374+
not_required_nullable_model: Union[Unset, None, ModelWithUnionProperty]
375+
if _not_required_nullable_model is None:
376+
not_required_nullable_model = None
377+
elif isinstance(_not_required_nullable_model, Unset):
378+
not_required_nullable_model = UNSET
379+
else:
368380
not_required_nullable_model = ModelWithUnionProperty.from_dict(_not_required_nullable_model)
369381

370382
a_model = cls(

0 commit comments

Comments
 (0)