Skip to content

Commit 5cfcb0f

Browse files
authored
Update instructions in generated README.md to match new style of calling endpoints. Closes #247 (#248)
1 parent c0431c7 commit 5cfcb0f

File tree

4 files changed

+43
-24
lines changed

4 files changed

+43
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
### Fixes
3333

3434
- Fixed spacing and generation of properties of type `Union` in generated models (#241 - Thanks @packyg!).
35+
- Fixed usage instructions in generated README.md (#247 - Thanks @theFong!).
3536

3637
## 0.6.2 - 2020-11-03
3738

end_to_end_tests/golden-record-custom/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,34 @@ Now call your endpoint and use your models:
2323
```python
2424
from custom_e2e.models import MyDataModel
2525
from custom_e2e.api.my_tag import get_my_data_model
26+
from custom_e2e.types import Response
2627

27-
my_data: MyDataModel = get_my_data_model(client=client)
28+
my_data: MyDataModel = get_my_data_model.sync(client=client)
29+
# or if you need more info (e.g. status_code)
30+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
2831
```
2932

3033
Or do the same thing with an async version:
3134

3235
```python
3336
from custom_e2e.models import MyDataModel
3437
from custom_e2e.async_api.my_tag import get_my_data_model
38+
from custom_e2e.types import Response
3539

36-
my_data: MyDataModel = await get_my_data_model(client=client)
40+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
41+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
3742
```
3843

3944
Things to know:
40-
1. Every path/method combo becomes a Python function with type annotations.
45+
1. Every path/method combo becomes a Python module with four functions:
46+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
47+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
48+
1. `asyncio`: Like `sync` but the async instead of blocking
49+
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking
50+
4151
1. All path/query params, and bodies become method arguments.
4252
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
43-
1. Any endpoint which did not have a tag will be in `custom_e2e.api.default`
44-
1. If the API returns a response code that was not declared in the OpenAPI document, a
45-
`custom_e2e.api.errors.ApiResponseError` wil be raised
46-
with the `response` attribute set to the `httpx.Response` that was received.
47-
53+
1. Any endpoint which did not have a tag will be in `custom_e2e.api.default`
4854

4955
## Building / publishing this Client
5056
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:

end_to_end_tests/golden-record/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,34 @@ Now call your endpoint and use your models:
2323
```python
2424
from my_test_api_client.models import MyDataModel
2525
from my_test_api_client.api.my_tag import get_my_data_model
26+
from my_test_api_client.types import Response
2627

27-
my_data: MyDataModel = get_my_data_model(client=client)
28+
my_data: MyDataModel = get_my_data_model.sync(client=client)
29+
# or if you need more info (e.g. status_code)
30+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
2831
```
2932

3033
Or do the same thing with an async version:
3134

3235
```python
3336
from my_test_api_client.models import MyDataModel
3437
from my_test_api_client.async_api.my_tag import get_my_data_model
38+
from my_test_api_client.types import Response
3539

36-
my_data: MyDataModel = await get_my_data_model(client=client)
40+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
41+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
3742
```
3843

3944
Things to know:
40-
1. Every path/method combo becomes a Python function with type annotations.
45+
1. Every path/method combo becomes a Python module with four functions:
46+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
47+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
48+
1. `asyncio`: Like `sync` but the async instead of blocking
49+
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking
50+
4151
1. All path/query params, and bodies become method arguments.
4252
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
43-
1. Any endpoint which did not have a tag will be in `my_test_api_client.api.default`
44-
1. If the API returns a response code that was not declared in the OpenAPI document, a
45-
`my_test_api_client.api.errors.ApiResponseError` wil be raised
46-
with the `response` attribute set to the `httpx.Response` that was received.
47-
53+
1. Any endpoint which did not have a tag will be in `my_test_api_client.api.default`
4854

4955
## Building / publishing this Client
5056
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:

openapi_python_client/templates/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,34 @@ Now call your endpoint and use your models:
2323
```python
2424
from {{ package_name }}.models import MyDataModel
2525
from {{ package_name }}.api.my_tag import get_my_data_model
26+
from {{ package_name }}.types import Response
2627

27-
my_data: MyDataModel = get_my_data_model(client=client)
28+
my_data: MyDataModel = get_my_data_model.sync(client=client)
29+
# or if you need more info (e.g. status_code)
30+
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
2831
```
2932

3033
Or do the same thing with an async version:
3134

3235
```python
3336
from {{ package_name }}.models import MyDataModel
3437
from {{ package_name }}.async_api.my_tag import get_my_data_model
38+
from {{ package_name }}.types import Response
3539

36-
my_data: MyDataModel = await get_my_data_model(client=client)
40+
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
41+
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
3742
```
3843

3944
Things to know:
40-
1. Every path/method combo becomes a Python function with type annotations.
45+
1. Every path/method combo becomes a Python module with four functions:
46+
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
47+
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
48+
1. `asyncio`: Like `sync` but the async instead of blocking
49+
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking
50+
4151
1. All path/query params, and bodies become method arguments.
4252
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
43-
1. Any endpoint which did not have a tag will be in `{{ package_name }}.api.default`
44-
1. If the API returns a response code that was not declared in the OpenAPI document, a
45-
`{{ package_name }}.api.errors.ApiResponseError` wil be raised
46-
with the `response` attribute set to the `httpx.Response` that was received.
47-
53+
1. Any endpoint which did not have a tag will be in `{{ package_name }}.api.default`
4854

4955
## Building / publishing this Client
5056
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:

0 commit comments

Comments
 (0)