Skip to content

Commit e7e8b14

Browse files
committed
Merge remote-tracking branch 'upstream/main' into 2.x
2 parents 3d512e0 + 40d63f9 commit e7e8b14

File tree

11 files changed

+406
-9
lines changed

11 files changed

+406
-9
lines changed

.github/workflows/checks.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
os: [ ubuntu-latest, macos-latest, windows-latest ]
1616
runs-on: ${{ matrix.os }}
1717
steps:
18-
- uses: actions/[email protected].1
18+
- uses: actions/[email protected].2
1919
- name: Set up Python
20-
uses: actions/setup-python@v5.2.0
20+
uses: actions/setup-python@v5.3.0
2121
with:
2222
python-version: ${{ matrix.python }}
2323

@@ -77,7 +77,7 @@ jobs:
7777
needs: test
7878
runs-on: ubuntu-latest
7979
steps:
80-
- uses: actions/[email protected].1
80+
- uses: actions/[email protected].2
8181
- uses: actions/setup-python@v5
8282
with:
8383
python-version: "3.12"
@@ -127,9 +127,9 @@ jobs:
127127
ports:
128128
- "3000:3000"
129129
steps:
130-
- uses: actions/[email protected].1
130+
- uses: actions/[email protected].2
131131
- name: Set up Python
132-
uses: actions/setup-python@v5.2.0
132+
uses: actions/setup-python@v5.3.0
133133
with:
134134
python-version: "3.8"
135135
- name: Get Python Version

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
permissions:
1313
id-token: write
1414
steps:
15-
- uses: actions/[email protected].1
15+
- uses: actions/[email protected].2
1616
- name: Install Hatchling
1717
run: pip install --upgrade hatchling
1818
- name: Build

end_to_end_tests/baseline_openapi_3.0.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,47 @@
16801680
}
16811681
}
16821682
}
1683+
},
1684+
"/models/oneof-with-required-const": {
1685+
"get": {
1686+
"responses": {
1687+
"200": {
1688+
"description": "OK",
1689+
"content": {
1690+
"application/json": {
1691+
"schema": {
1692+
"oneOf": [
1693+
{
1694+
"type": "object",
1695+
"properties": {
1696+
"type": {
1697+
"const": "alpha"
1698+
},
1699+
"color": {
1700+
"type": "string"
1701+
}
1702+
},
1703+
"required": ["type"]
1704+
},
1705+
{
1706+
"type": "object",
1707+
"properties": {
1708+
"type": {
1709+
"const": "beta"
1710+
},
1711+
"texture": {
1712+
"type": "string"
1713+
}
1714+
},
1715+
"required": ["type"]
1716+
}
1717+
]
1718+
}
1719+
}
1720+
}
1721+
}
1722+
}
1723+
}
16831724
}
16841725
},
16851726
"components": {

end_to_end_tests/baseline_openapi_3.1.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,47 @@ info:
16711671
}
16721672
}
16731673
},
1674+
"/models/oneof-with-required-const": {
1675+
"get": {
1676+
"responses": {
1677+
"200": {
1678+
"description": "OK",
1679+
"content": {
1680+
"application/json": {
1681+
"schema": {
1682+
"oneOf": [
1683+
{
1684+
"type": "object",
1685+
"properties": {
1686+
"type": {
1687+
"const": "alpha"
1688+
},
1689+
"color": {
1690+
"type": "string"
1691+
}
1692+
},
1693+
"required": ["type"]
1694+
},
1695+
{
1696+
"type": "object",
1697+
"properties": {
1698+
"type": {
1699+
"const": "beta"
1700+
},
1701+
"texture": {
1702+
"type": "string"
1703+
}
1704+
},
1705+
"required": ["type"]
1706+
}
1707+
]
1708+
}
1709+
}
1710+
}
1711+
}
1712+
}
1713+
}
1714+
}
16741715
}
16751716
"components":
16761717
"schemas": {

end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/default/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
import types
44

5-
from . import get_common_parameters, get_models_allof, post_common_parameters, reserved_parameters
5+
from . import (
6+
get_common_parameters,
7+
get_models_allof,
8+
get_models_oneof_with_required_const,
9+
post_common_parameters,
10+
reserved_parameters,
11+
)
612

713

814
class DefaultEndpoints:
@@ -21,3 +27,7 @@ def reserved_parameters(cls) -> types.ModuleType:
2127
@classmethod
2228
def get_models_allof(cls) -> types.ModuleType:
2329
return get_models_allof
30+
31+
@classmethod
32+
def get_models_oneof_with_required_const(cls) -> types.ModuleType:
33+
return get_models_oneof_with_required_const
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
from http import HTTPStatus
2+
from typing import Any, Dict, Optional, Union
3+
4+
import httpx
5+
6+
from ... import errors
7+
from ...client import AuthenticatedClient, Client
8+
from ...models.get_models_oneof_with_required_const_response_200_type_0 import (
9+
GetModelsOneofWithRequiredConstResponse200Type0,
10+
)
11+
from ...models.get_models_oneof_with_required_const_response_200_type_1 import (
12+
GetModelsOneofWithRequiredConstResponse200Type1,
13+
)
14+
from ...types import Response
15+
16+
17+
def _get_kwargs() -> Dict[str, Any]:
18+
_kwargs: Dict[str, Any] = {
19+
"method": "get",
20+
"url": "/models/oneof-with-required-const",
21+
}
22+
23+
return _kwargs
24+
25+
26+
def _parse_response(
27+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
28+
) -> Optional[
29+
Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"]
30+
]:
31+
if response.status_code == 200:
32+
33+
def _parse_response_200(
34+
data: object,
35+
) -> Union[
36+
"GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"
37+
]:
38+
try:
39+
if not isinstance(data, dict):
40+
raise TypeError()
41+
response_200_type_0 = GetModelsOneofWithRequiredConstResponse200Type0.from_dict(data)
42+
43+
return response_200_type_0
44+
except: # noqa: E722
45+
pass
46+
if not isinstance(data, dict):
47+
raise TypeError()
48+
response_200_type_1 = GetModelsOneofWithRequiredConstResponse200Type1.from_dict(data)
49+
50+
return response_200_type_1
51+
52+
response_200 = _parse_response_200(response.json())
53+
54+
return response_200
55+
if client.raise_on_unexpected_status:
56+
raise errors.UnexpectedStatus(response.status_code, response.content)
57+
else:
58+
return None
59+
60+
61+
def _build_response(
62+
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
63+
) -> Response[
64+
Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"]
65+
]:
66+
return Response(
67+
status_code=HTTPStatus(response.status_code),
68+
content=response.content,
69+
headers=response.headers,
70+
parsed=_parse_response(client=client, response=response),
71+
)
72+
73+
74+
def sync_detailed(
75+
*,
76+
client: Union[AuthenticatedClient, Client],
77+
) -> Response[
78+
Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"]
79+
]:
80+
"""
81+
Raises:
82+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
83+
httpx.TimeoutException: If the request takes longer than Client.timeout.
84+
85+
Returns:
86+
Response[Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']]
87+
"""
88+
89+
kwargs = _get_kwargs()
90+
91+
response = client.get_httpx_client().request(
92+
**kwargs,
93+
)
94+
95+
return _build_response(client=client, response=response)
96+
97+
98+
def sync(
99+
*,
100+
client: Union[AuthenticatedClient, Client],
101+
) -> Optional[
102+
Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"]
103+
]:
104+
"""
105+
Raises:
106+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
107+
httpx.TimeoutException: If the request takes longer than Client.timeout.
108+
109+
Returns:
110+
Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']
111+
"""
112+
113+
return sync_detailed(
114+
client=client,
115+
).parsed
116+
117+
118+
async def asyncio_detailed(
119+
*,
120+
client: Union[AuthenticatedClient, Client],
121+
) -> Response[
122+
Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"]
123+
]:
124+
"""
125+
Raises:
126+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
127+
httpx.TimeoutException: If the request takes longer than Client.timeout.
128+
129+
Returns:
130+
Response[Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']]
131+
"""
132+
133+
kwargs = _get_kwargs()
134+
135+
response = await client.get_async_httpx_client().request(**kwargs)
136+
137+
return _build_response(client=client, response=response)
138+
139+
140+
async def asyncio(
141+
*,
142+
client: Union[AuthenticatedClient, Client],
143+
) -> Optional[
144+
Union["GetModelsOneofWithRequiredConstResponse200Type0", "GetModelsOneofWithRequiredConstResponse200Type1"]
145+
]:
146+
"""
147+
Raises:
148+
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
149+
httpx.TimeoutException: If the request takes longer than Client.timeout.
150+
151+
Returns:
152+
Union['GetModelsOneofWithRequiredConstResponse200Type0', 'GetModelsOneofWithRequiredConstResponse200Type1']
153+
"""
154+
155+
return (
156+
await asyncio_detailed(
157+
client=client,
158+
)
159+
).parsed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
from .get_location_header_types_int_enum_header import GetLocationHeaderTypesIntEnumHeader
4040
from .get_location_header_types_string_enum_header import GetLocationHeaderTypesStringEnumHeader
4141
from .get_models_allof_response_200 import GetModelsAllofResponse200
42+
from .get_models_oneof_with_required_const_response_200_type_0 import GetModelsOneofWithRequiredConstResponse200Type0
43+
from .get_models_oneof_with_required_const_response_200_type_1 import GetModelsOneofWithRequiredConstResponse200Type1
4244
from .http_validation_error import HTTPValidationError
4345
from .import_ import Import
4446
from .json_like_body import JsonLikeBody
@@ -121,6 +123,8 @@
121123
"GetLocationHeaderTypesIntEnumHeader",
122124
"GetLocationHeaderTypesStringEnumHeader",
123125
"GetModelsAllofResponse200",
126+
"GetModelsOneofWithRequiredConstResponse200Type0",
127+
"GetModelsOneofWithRequiredConstResponse200Type1",
124128
"HTTPValidationError",
125129
"Import",
126130
"JsonLikeBody",

0 commit comments

Comments
 (0)