Skip to content

Commit 94a1656

Browse files
Merge remote-tracking branch 'upstream/main' into forest-allof-enum
2 parents 7ed16e4 + 605c246 commit 94a1656

File tree

67 files changed

+2290
-432
lines changed

Some content is hidden

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

67 files changed

+2290
-432
lines changed

CHANGELOG.md

+32
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,29 @@ 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.2
8+
9+
### Features
10+
11+
- Add option to fail on warning [#427]. Thanks @forest-benchling!
12+
13+
### Fixes
14+
15+
- Properly strip out `UNSET` values from form data [#430]. Thanks @p1-ra!
16+
17+
## 0.9.1
18+
19+
### Features
20+
21+
- Allow references to non-object, non-enum types [#371][#418][#425]. Thanks @p1-ra!
22+
- Allow for attrs 21.x in generated clients [#412]
23+
- Allow for using any version of Black [#416] [#411]. Thanks @christhekeele!
24+
25+
### Fixes
26+
27+
- Prevent crash when providing a non-string default to a string attribute. [#414] [#415]
28+
- Deserialization of optional nullable properties when no value is returned from the API [#420] [#381]. Thanks @forest-benchling!
29+
730
## 0.9.0 - 2021-05-04
831

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

4770
- Attempt to detect and alert users if they are using an unsupported version of OpenAPI (#281).
71+
4872
- The media type application/vnd.api+json will now be handled just like application/json (#307). Thanks @jrversteegh!
73+
4974
- Support passing models into query parameters (#316). Thanks @forest-benchling!
75+
5076
- Add support for cookie parameters (#326).
77+
5178
- New `--file-encoding` command line option (#330). Sets the encoding used when writing generated files (defaults to utf-8). Thanks @dongfangtianyu!
5279

5380
### Changes
@@ -96,13 +123,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
96123
### Breaking Changes
97124

98125
- Any request/response field that is not `required` and wasn't specified is now set to `UNSET` instead of `None`.
126+
99127
- Values that are `UNSET` will not be sent along in API calls
128+
100129
- 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.
130+
101131
- 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.
102132

103133
- 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.
104134

105135
- Instead of skipping input properties with no type, enum, anyOf, or oneOf declared, the property will be declared as `None`.
136+
106137
- 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.
107138

108139
### Additions
@@ -268,6 +299,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
268299
### Changes
269300

270301
- The way most imports are handled was changed which _should_ lead to fewer unused imports in generated files.
302+
271303
- Better error messages
272304

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

dobby.toml

+3-3
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"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
my-test-api-client
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
""" Contains methods for accessing the API """
2+
3+
from typing import Type
4+
5+
from my_test_api_client.api.default import DefaultEndpoints
6+
from my_test_api_client.api.parameters import ParametersEndpoints
7+
from my_test_api_client.api.tests import TestsEndpoints
8+
9+
10+
class MyTestApiClientApi:
11+
@classmethod
12+
def tests(cls) -> Type[TestsEndpoints]:
13+
return TestsEndpoints
14+
15+
@classmethod
16+
def default(cls) -> Type[DefaultEndpoints]:
17+
return DefaultEndpoints
18+
19+
@classmethod
20+
def parameters(cls) -> Type[ParametersEndpoints]:
21+
return ParametersEndpoints
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
""" Contains methods for accessing the API Endpoints """
2+
3+
import types
4+
5+
from my_test_api_client.api.default import get_common_parameters, post_common_parameters
6+
7+
8+
class DefaultEndpoints:
9+
@classmethod
10+
def get_common_parameters(cls) -> types.ModuleType:
11+
return get_common_parameters
12+
13+
@classmethod
14+
def post_common_parameters(cls) -> types.ModuleType:
15+
return post_common_parameters
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
""" Contains methods for accessing the API Endpoints """
2+
3+
import types
4+
5+
from my_test_api_client.api.parameters import get_same_name_multiple_locations_param
6+
7+
8+
class ParametersEndpoints:
9+
@classmethod
10+
def get_same_name_multiple_locations_param(cls) -> types.ModuleType:
11+
return get_same_name_multiple_locations_param
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
""" Contains methods for accessing the API Endpoints """
2+
3+
import types
4+
5+
from my_test_api_client.api.tests import (
6+
defaults_tests_defaults_post,
7+
get_basic_list_of_booleans,
8+
get_basic_list_of_floats,
9+
get_basic_list_of_integers,
10+
get_basic_list_of_strings,
11+
get_user_list,
12+
int_enum_tests_int_enum_post,
13+
json_body_tests_json_body_post,
14+
no_response_tests_no_response_get,
15+
octet_stream_tests_octet_stream_get,
16+
optional_value_tests_optional_query_param,
17+
post_form_data,
18+
test_inline_objects,
19+
token_with_cookie_auth_token_with_cookie_get,
20+
unsupported_content_tests_unsupported_content_get,
21+
upload_file_tests_upload_post,
22+
)
23+
24+
25+
class TestsEndpoints:
26+
@classmethod
27+
def get_user_list(cls) -> types.ModuleType:
28+
"""
29+
Get a list of things
30+
"""
31+
return get_user_list
32+
33+
@classmethod
34+
def get_basic_list_of_strings(cls) -> types.ModuleType:
35+
"""
36+
Get a list of strings
37+
"""
38+
return get_basic_list_of_strings
39+
40+
@classmethod
41+
def get_basic_list_of_integers(cls) -> types.ModuleType:
42+
"""
43+
Get a list of integers
44+
"""
45+
return get_basic_list_of_integers
46+
47+
@classmethod
48+
def get_basic_list_of_floats(cls) -> types.ModuleType:
49+
"""
50+
Get a list of floats
51+
"""
52+
return get_basic_list_of_floats
53+
54+
@classmethod
55+
def get_basic_list_of_booleans(cls) -> types.ModuleType:
56+
"""
57+
Get a list of booleans
58+
"""
59+
return get_basic_list_of_booleans
60+
61+
@classmethod
62+
def post_form_data(cls) -> types.ModuleType:
63+
"""
64+
Post form data
65+
"""
66+
return post_form_data
67+
68+
@classmethod
69+
def upload_file_tests_upload_post(cls) -> types.ModuleType:
70+
"""
71+
Upload a file
72+
"""
73+
return upload_file_tests_upload_post
74+
75+
@classmethod
76+
def json_body_tests_json_body_post(cls) -> types.ModuleType:
77+
"""
78+
Try sending a JSON body
79+
"""
80+
return json_body_tests_json_body_post
81+
82+
@classmethod
83+
def defaults_tests_defaults_post(cls) -> types.ModuleType:
84+
"""
85+
Defaults
86+
"""
87+
return defaults_tests_defaults_post
88+
89+
@classmethod
90+
def octet_stream_tests_octet_stream_get(cls) -> types.ModuleType:
91+
"""
92+
Octet Stream
93+
"""
94+
return octet_stream_tests_octet_stream_get
95+
96+
@classmethod
97+
def no_response_tests_no_response_get(cls) -> types.ModuleType:
98+
"""
99+
No Response
100+
"""
101+
return no_response_tests_no_response_get
102+
103+
@classmethod
104+
def unsupported_content_tests_unsupported_content_get(cls) -> types.ModuleType:
105+
"""
106+
Unsupported Content
107+
"""
108+
return unsupported_content_tests_unsupported_content_get
109+
110+
@classmethod
111+
def int_enum_tests_int_enum_post(cls) -> types.ModuleType:
112+
"""
113+
Int Enum
114+
"""
115+
return int_enum_tests_int_enum_post
116+
117+
@classmethod
118+
def test_inline_objects(cls) -> types.ModuleType:
119+
"""
120+
Test Inline Objects
121+
"""
122+
return test_inline_objects
123+
124+
@classmethod
125+
def optional_value_tests_optional_query_param(cls) -> types.ModuleType:
126+
"""
127+
Test optional query parameters
128+
"""
129+
return optional_value_tests_optional_query_param
130+
131+
@classmethod
132+
def token_with_cookie_auth_token_with_cookie_get(cls) -> types.ModuleType:
133+
"""
134+
Test optional cookie parameters
135+
"""
136+
return token_with_cookie_auth_token_with_cookie_get
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from typing import Any, Dict
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...models.a_form_data import AFormData
7+
from ...types import Response
8+
9+
10+
def _get_kwargs(
11+
*,
12+
client: Client,
13+
form_data: AFormData,
14+
) -> Dict[str, Any]:
15+
url = "{}/tests/post_form_data".format(client.base_url)
16+
17+
headers: Dict[str, Any] = client.get_headers()
18+
cookies: Dict[str, Any] = client.get_cookies()
19+
20+
return {
21+
"url": url,
22+
"headers": headers,
23+
"cookies": cookies,
24+
"timeout": client.get_timeout(),
25+
"data": form_data.to_dict(),
26+
}
27+
28+
29+
def _build_response(*, response: httpx.Response) -> Response[None]:
30+
return Response(
31+
status_code=response.status_code,
32+
content=response.content,
33+
headers=response.headers,
34+
parsed=None,
35+
)
36+
37+
38+
def sync_detailed(
39+
*,
40+
client: Client,
41+
form_data: AFormData,
42+
) -> Response[None]:
43+
kwargs = _get_kwargs(
44+
client=client,
45+
form_data=form_data,
46+
)
47+
48+
response = httpx.post(
49+
**kwargs,
50+
)
51+
52+
return _build_response(response=response)
53+
54+
55+
async def asyncio_detailed(
56+
*,
57+
client: Client,
58+
form_data: AFormData,
59+
) -> Response[None]:
60+
kwargs = _get_kwargs(
61+
client=client,
62+
form_data=form_data,
63+
)
64+
65+
async with httpx.AsyncClient() as _client:
66+
response = await _client.post(**kwargs)
67+
68+
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/tests/upload_file_tests_upload_post.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ...client import Client
66
from ...models.body_upload_file_tests_upload_post import BodyUploadFileTestsUploadPost
77
from ...models.http_validation_error import HTTPValidationError
8-
from ...types import UNSET, File, Response, Unset
8+
from ...types import UNSET, Response, Unset
99

1010

1111
def _get_kwargs(
@@ -22,21 +22,14 @@ def _get_kwargs(
2222
if keep_alive is not UNSET:
2323
headers["keep-alive"] = keep_alive
2424

25-
files = {}
26-
data = {}
27-
for key, value in multipart_data.to_dict().items():
28-
if isinstance(value, File):
29-
files[key] = value
30-
else:
31-
data[key] = value
25+
multipart_multipart_data = multipart_data.to_multipart()
3226

3327
return {
3428
"url": url,
3529
"headers": headers,
3630
"cookies": cookies,
3731
"timeout": client.get_timeout(),
38-
"files": files,
39-
"data": data,
32+
"files": multipart_multipart_data,
4033
}
4134

4235

0 commit comments

Comments
 (0)