Skip to content

Commit 3dae07e

Browse files
committed
docs: Document generated Client attributes.
1 parent 98a1e92 commit 3dae07e

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

end_to_end_tests/golden-record/my_test_api_client/client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66

77
@attr.s(auto_attribs=True)
88
class Client:
9-
"""A class for keeping track of data related to the API"""
9+
"""A class for keeping track of data related to the API
10+
11+
Attributes:
12+
base_url: The base URL for the API, all requests are made to a relative path to this URL
13+
cookies: A dictionary of cookies to be sent with every request
14+
headers: A dictionary of headers to be sent with every request
15+
timeout: The maximum amount of a time a request can take. API functions will raise httpx.TimeoutException if
16+
this is exceeded.
17+
verify_ssl: Whether or not to verify the SSL certificate of the API server. This should be True in production,
18+
but can be set to False for testing purposes.
19+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatusException if the API returns a
20+
status code that was not documented in the source OpenAPI document.
21+
"""
1022

1123
base_url: str
1224
cookies: Dict[str, str] = attr.ib(factory=dict, kw_only=True)

integration-tests/integration_tests/client.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@
66

77
@attr.s(auto_attribs=True)
88
class Client:
9-
"""A class for keeping track of data related to the API"""
9+
"""A class for keeping track of data related to the API
10+
11+
Attributes:
12+
base_url: The base URL for the API, all requests are made to a relative path to this URL
13+
cookies: A dictionary of cookies to be sent with every request
14+
headers: A dictionary of headers to be sent with every request
15+
timeout: The maximum amount of a time a request can take. API functions will raise httpx.TimeoutException if
16+
this is exceeded.
17+
verify_ssl: Whether or not to verify the SSL certificate of the API server. This should be True in production,
18+
but can be set to False for testing purposes.
19+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatusException if the API returns a
20+
status code that was not documented in the source OpenAPI document.
21+
"""
1022

1123
base_url: str
1224
cookies: Dict[str, str] = attr.ib(factory=dict, kw_only=True)

openapi_python_client/templates/README.md.jinja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ client = AuthenticatedClient(
6161
)
6262
```
6363

64+
There are more settings on the generated `Client` class which let you control more runtime behavior, check out the
65+
docstring on that class for more info.
66+
6467
Things to know:
6568
1. Every path/method combo becomes a Python module with four functions:
6669
1. `sync`: Blocking request that returns parsed data (if successful) or `None`

openapi_python_client/templates/client.py.jinja

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ import attr
44

55
@attr.s(auto_attribs=True)
66
class Client:
7-
""" A class for keeping track of data related to the API """
7+
""" A class for keeping track of data related to the API
8+
9+
Attributes:
10+
base_url: The base URL for the API, all requests are made to a relative path to this URL
11+
cookies: A dictionary of cookies to be sent with every request
12+
headers: A dictionary of headers to be sent with every request
13+
timeout: The maximum amount of a time a request can take. API functions will raise httpx.TimeoutException if
14+
this is exceeded.
15+
verify_ssl: Whether or not to verify the SSL certificate of the API server. This should be True in production,
16+
but can be set to False for testing purposes.
17+
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatusException if the API returns a
18+
status code that was not documented in the source OpenAPI document.
19+
"""
820

921
base_url: str
1022
cookies: Dict[str, str] = attr.ib(factory=dict, kw_only=True)

0 commit comments

Comments
 (0)