Skip to content

Commit c0fd042

Browse files
committed
Merge branch 'main' into release/0.6.0
2 parents fad604a + 849be6e commit c0fd042

File tree

11 files changed

+579
-16
lines changed

11 files changed

+579
-16
lines changed

.deepsource.toml

Lines changed: 0 additions & 12 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
a fluid api (e.g. `my_endpoint.sync(my_client.with_cookies({"MyCookie": "cookie"}).with_timeout(10.0))`).
2929

3030

31-
## 0.5.4 - Unreleased
31+
## 0.5.4 - 2020-08-29
3232
### Additions
33-
- Added support for octet-stream content type (#116)
33+
- Support for octet-stream content type (#116)
3434
- Support for [nullable](https://swagger.io/docs/specification/data-models/data-types/#null) (#99)
35-
- Union properties defined using oneOf (#98)
35+
- Union properties can be defined using oneOf (#98)
36+
- Support for lists of strings, integers, floats and booleans as responses (#165). Thanks @Maistho!
3637

3738

3839
## 0.5.3 - 2020-08-13

end_to_end_tests/fastapi_app/__init__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ def get_list(
6161
return
6262

6363

64+
@test_router.get("/basic_lists/strings", response_model=List[str], operation_id="getBasicListOfStrings")
65+
def get_basic_list_of_strings():
66+
""" Get a list of strings """
67+
return
68+
69+
70+
@test_router.get("/basic_lists/integers", response_model=List[int], operation_id="getBasicListOfIntegers")
71+
def get_basic_list_of_integers():
72+
""" Get a list of integers """
73+
return
74+
75+
76+
@test_router.get("/basic_lists/floats", response_model=List[float], operation_id="getBasicListOfFloats")
77+
def get_basic_list_of_floats():
78+
""" Get a list of floats """
79+
return
80+
81+
82+
@test_router.get("/basic_lists/booleans", response_model=List[bool], operation_id="getBasicListOfBooleans")
83+
def get_basic_list_of_booleans():
84+
""" Get a list of booleans """
85+
return
86+
87+
6488
@test_router.post("/upload")
6589
async def upload_file(some_file: UploadFile = File(...), keep_alive: bool = Header(None)):
6690
""" Upload a file """

end_to_end_tests/fastapi_app/openapi.json

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,110 @@
9494
}
9595
}
9696
},
97+
"/tests/basic_lists/strings": {
98+
"get": {
99+
"tags": [
100+
"tests"
101+
],
102+
"summary": "Get Basic List Of Strings",
103+
"description": "Get a list of strings ",
104+
"operationId": "getBasicListOfStrings",
105+
"responses": {
106+
"200": {
107+
"description": "Successful Response",
108+
"content": {
109+
"application/json": {
110+
"schema": {
111+
"title": "Response Get Basic List Of Strings Tests Basic Lists Strings Get",
112+
"type": "array",
113+
"items": {
114+
"type": "string"
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}
121+
}
122+
},
123+
"/tests/basic_lists/integers": {
124+
"get": {
125+
"tags": [
126+
"tests"
127+
],
128+
"summary": "Get Basic List Of Integers",
129+
"description": "Get a list of integers ",
130+
"operationId": "getBasicListOfIntegers",
131+
"responses": {
132+
"200": {
133+
"description": "Successful Response",
134+
"content": {
135+
"application/json": {
136+
"schema": {
137+
"title": "Response Get Basic List Of Integers Tests Basic Lists Integers Get",
138+
"type": "array",
139+
"items": {
140+
"type": "integer"
141+
}
142+
}
143+
}
144+
}
145+
}
146+
}
147+
}
148+
},
149+
"/tests/basic_lists/floats": {
150+
"get": {
151+
"tags": [
152+
"tests"
153+
],
154+
"summary": "Get Basic List Of Floats",
155+
"description": "Get a list of floats ",
156+
"operationId": "getBasicListOfFloats",
157+
"responses": {
158+
"200": {
159+
"description": "Successful Response",
160+
"content": {
161+
"application/json": {
162+
"schema": {
163+
"title": "Response Get Basic List Of Floats Tests Basic Lists Floats Get",
164+
"type": "array",
165+
"items": {
166+
"type": "number"
167+
}
168+
}
169+
}
170+
}
171+
}
172+
}
173+
}
174+
},
175+
"/tests/basic_lists/booleans": {
176+
"get": {
177+
"tags": [
178+
"tests"
179+
],
180+
"summary": "Get Basic List Of Booleans",
181+
"description": "Get a list of booleans ",
182+
"operationId": "getBasicListOfBooleans",
183+
"responses": {
184+
"200": {
185+
"description": "Successful Response",
186+
"content": {
187+
"application/json": {
188+
"schema": {
189+
"title": "Response Get Basic List Of Booleans Tests Basic Lists Booleans Get",
190+
"type": "array",
191+
"items": {
192+
"type": "boolean"
193+
}
194+
}
195+
}
196+
}
197+
}
198+
}
199+
}
200+
},
97201
"/tests/upload": {
98202
"post": {
99203
"tags": [
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from dataclasses import asdict
2+
from typing import Any, Dict, List, Optional, Union, cast
3+
4+
import httpx
5+
6+
from ...client import AuthenticatedClient, Client
7+
from ...types import Response
8+
9+
10+
def _get_kwargs(
11+
*,
12+
client: Client,
13+
) -> Dict[str, Any]:
14+
url = "{}/tests/basic_lists/booleans".format(client.base_url)
15+
16+
headers: Dict[str, Any] = client.get_headers()
17+
18+
return {
19+
"url": url,
20+
"headers": headers,
21+
"cookies": client.get_cookies(),
22+
"timeout": client.get_timeout(),
23+
}
24+
25+
26+
def _parse_response(*, response: httpx.Response) -> Optional[List[bool]]:
27+
if response.status_code == 200:
28+
return [bool(item) for item in cast(List[bool], response.json())]
29+
return None
30+
31+
32+
def _build_response(*, response: httpx.Response) -> Response[List[bool]]:
33+
return Response(
34+
status_code=response.status_code,
35+
content=response.content,
36+
headers=response.headers,
37+
parsed=_parse_response(response=response),
38+
)
39+
40+
41+
def sync_detailed(
42+
*,
43+
client: Client,
44+
) -> Response[List[bool]]:
45+
kwargs = _get_kwargs(
46+
client=client,
47+
)
48+
49+
response = httpx.get(
50+
**kwargs,
51+
)
52+
53+
return _build_response(response=response)
54+
55+
56+
def sync(
57+
*,
58+
client: Client,
59+
) -> Optional[List[bool]]:
60+
""" Get a list of booleans """
61+
62+
return sync_detailed(
63+
client=client,
64+
).parsed
65+
66+
67+
async def asyncio_detailed(
68+
*,
69+
client: Client,
70+
) -> Response[List[bool]]:
71+
kwargs = _get_kwargs(
72+
client=client,
73+
)
74+
75+
async with httpx.AsyncClient() as _client:
76+
response = await _client.get(**kwargs)
77+
78+
return _build_response(response=response)
79+
80+
81+
async def asyncio(
82+
*,
83+
client: Client,
84+
) -> Optional[List[bool]]:
85+
""" Get a list of booleans """
86+
87+
return (
88+
await asyncio_detailed(
89+
client=client,
90+
)
91+
).parsed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
from dataclasses import asdict
2+
from typing import Any, Dict, List, Optional, Union, cast
3+
4+
import httpx
5+
6+
from ...client import AuthenticatedClient, Client
7+
from ...types import Response
8+
9+
10+
def _get_kwargs(
11+
*,
12+
client: Client,
13+
) -> Dict[str, Any]:
14+
url = "{}/tests/basic_lists/floats".format(client.base_url)
15+
16+
headers: Dict[str, Any] = client.get_headers()
17+
18+
return {
19+
"url": url,
20+
"headers": headers,
21+
"cookies": client.get_cookies(),
22+
"timeout": client.get_timeout(),
23+
}
24+
25+
26+
def _parse_response(*, response: httpx.Response) -> Optional[List[float]]:
27+
if response.status_code == 200:
28+
return [float(item) for item in cast(List[float], response.json())]
29+
return None
30+
31+
32+
def _build_response(*, response: httpx.Response) -> Response[List[float]]:
33+
return Response(
34+
status_code=response.status_code,
35+
content=response.content,
36+
headers=response.headers,
37+
parsed=_parse_response(response=response),
38+
)
39+
40+
41+
def sync_detailed(
42+
*,
43+
client: Client,
44+
) -> Response[List[float]]:
45+
kwargs = _get_kwargs(
46+
client=client,
47+
)
48+
49+
response = httpx.get(
50+
**kwargs,
51+
)
52+
53+
return _build_response(response=response)
54+
55+
56+
def sync(
57+
*,
58+
client: Client,
59+
) -> Optional[List[float]]:
60+
""" Get a list of floats """
61+
62+
return sync_detailed(
63+
client=client,
64+
).parsed
65+
66+
67+
async def asyncio_detailed(
68+
*,
69+
client: Client,
70+
) -> Response[List[float]]:
71+
kwargs = _get_kwargs(
72+
client=client,
73+
)
74+
75+
async with httpx.AsyncClient() as _client:
76+
response = await _client.get(**kwargs)
77+
78+
return _build_response(response=response)
79+
80+
81+
async def asyncio(
82+
*,
83+
client: Client,
84+
) -> Optional[List[float]]:
85+
""" Get a list of floats """
86+
87+
return (
88+
await asyncio_detailed(
89+
client=client,
90+
)
91+
).parsed

0 commit comments

Comments
 (0)