Skip to content

Commit 499c144

Browse files
committed
fix: Treat true and false as reserved words.
1 parent ee43748 commit 499c144

File tree

5 files changed

+86
-2
lines changed

5 files changed

+86
-2
lines changed
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 . import false_
6+
7+
8+
class True_Endpoints:
9+
@classmethod
10+
def false_(cls) -> types.ModuleType:
11+
return false_

end_to_end_tests/golden-record/my_test_api_client/api/true_/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from typing import Any, Dict
2+
3+
import httpx
4+
5+
from ...client import Client
6+
from ...types import UNSET, Response
7+
8+
9+
def _get_kwargs(
10+
*,
11+
client: Client,
12+
import_: str,
13+
) -> Dict[str, Any]:
14+
url = "{}/naming/keywords".format(client.base_url)
15+
16+
headers: Dict[str, Any] = client.get_headers()
17+
cookies: Dict[str, Any] = client.get_cookies()
18+
19+
params: Dict[str, Any] = {
20+
"import": import_,
21+
}
22+
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
23+
24+
return {
25+
"url": url,
26+
"headers": headers,
27+
"cookies": cookies,
28+
"timeout": client.get_timeout(),
29+
"params": params,
30+
}
31+
32+
33+
def _build_response(*, response: httpx.Response) -> Response[Any]:
34+
return Response(
35+
status_code=response.status_code,
36+
content=response.content,
37+
headers=response.headers,
38+
parsed=None,
39+
)
40+
41+
42+
def sync_detailed(
43+
*,
44+
client: Client,
45+
import_: str,
46+
) -> Response[Any]:
47+
kwargs = _get_kwargs(
48+
client=client,
49+
import_=import_,
50+
)
51+
52+
response = httpx.get(
53+
**kwargs,
54+
)
55+
56+
return _build_response(response=response)
57+
58+
59+
async def asyncio_detailed(
60+
*,
61+
client: Client,
62+
import_: str,
63+
) -> Response[Any]:
64+
kwargs = _get_kwargs(
65+
client=client,
66+
import_=import_,
67+
)
68+
69+
async with httpx.AsyncClient() as _client:
70+
response = await _client.get(**kwargs)
71+
72+
return _build_response(response=response)

end_to_end_tests/openapi.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,9 @@
938938
"description": "Ensure that Python keywords are renamed properly.",
939939
"get": {
940940
"tags": [
941-
"naming"
941+
"true"
942942
],
943+
"operationId": "false",
943944
"parameters": [
944945
{
945946
"name": "import",

openapi_python_client/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def split_words(value: str) -> List[str]:
4747
return re.findall(rf"[^{DELIMITERS}]+", value)
4848

4949

50-
RESERVED_WORDS = (set(dir(builtins)) | {"self"}) - {"type", "id"}
50+
RESERVED_WORDS = (set(dir(builtins)) | {"self", "true", "false"}) - {"type", "id"}
5151

5252

5353
def fix_reserved_words(value: str) -> str:

0 commit comments

Comments
 (0)