Skip to content

Update instructions in generated README.md #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixes

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

## 0.6.2 - 2020-11-03

Expand Down
22 changes: 14 additions & 8 deletions end_to_end_tests/golden-record-custom/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,34 @@ Now call your endpoint and use your models:
```python
from custom_e2e.models import MyDataModel
from custom_e2e.api.my_tag import get_my_data_model
from custom_e2e.types import Response

my_data: MyDataModel = get_my_data_model(client=client)
my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
```

Or do the same thing with an async version:

```python
from custom_e2e.models import MyDataModel
from custom_e2e.async_api.my_tag import get_my_data_model
from custom_e2e.types import Response

my_data: MyDataModel = await get_my_data_model(client=client)
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
```

Things to know:
1. Every path/method combo becomes a Python function with type annotations.
1. Every path/method combo becomes a Python module with four functions:
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
1. `asyncio`: Like `sync` but the async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking

1. All path/query params, and bodies become method arguments.
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)
1. Any endpoint which did not have a tag will be in `custom_e2e.api.default`
1. If the API returns a response code that was not declared in the OpenAPI document, a
`custom_e2e.api.errors.ApiResponseError` wil be raised
with the `response` attribute set to the `httpx.Response` that was received.

1. Any endpoint which did not have a tag will be in `custom_e2e.api.default`

## Building / publishing this Client
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
Expand Down
22 changes: 14 additions & 8 deletions end_to_end_tests/golden-record/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,34 @@ Now call your endpoint and use your models:
```python
from my_test_api_client.models import MyDataModel
from my_test_api_client.api.my_tag import get_my_data_model
from my_test_api_client.types import Response

my_data: MyDataModel = get_my_data_model(client=client)
my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
```

Or do the same thing with an async version:

```python
from my_test_api_client.models import MyDataModel
from my_test_api_client.async_api.my_tag import get_my_data_model
from my_test_api_client.types import Response

my_data: MyDataModel = await get_my_data_model(client=client)
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
```

Things to know:
1. Every path/method combo becomes a Python function with type annotations.
1. Every path/method combo becomes a Python module with four functions:
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
1. `asyncio`: Like `sync` but the async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking

1. All path/query params, and bodies become method arguments.
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)
1. Any endpoint which did not have a tag will be in `my_test_api_client.api.default`
1. If the API returns a response code that was not declared in the OpenAPI document, a
`my_test_api_client.api.errors.ApiResponseError` wil be raised
with the `response` attribute set to the `httpx.Response` that was received.

1. Any endpoint which did not have a tag will be in `my_test_api_client.api.default`

## Building / publishing this Client
This project uses [Poetry](https://python-poetry.org/) to manage dependencies and packaging. Here are the basics:
Expand Down
22 changes: 14 additions & 8 deletions openapi_python_client/templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,34 @@ Now call your endpoint and use your models:
```python
from {{ package_name }}.models import MyDataModel
from {{ package_name }}.api.my_tag import get_my_data_model
from {{ package_name }}.types import Response

my_data: MyDataModel = get_my_data_model(client=client)
my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
```

Or do the same thing with an async version:

```python
from {{ package_name }}.models import MyDataModel
from {{ package_name }}.async_api.my_tag import get_my_data_model
from {{ package_name }}.types import Response

my_data: MyDataModel = await get_my_data_model(client=client)
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
```

Things to know:
1. Every path/method combo becomes a Python function with type annotations.
1. Every path/method combo becomes a Python module with four functions:
1. `sync`: Blocking request that returns parsed data (if successful) or `None`
1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
1. `asyncio`: Like `sync` but the async instead of blocking
1. `asyncio_detailed`: Like `sync_detailed` by async instead of blocking

1. All path/query params, and bodies become method arguments.
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)
1. Any endpoint which did not have a tag will be in `{{ package_name }}.api.default`
1. If the API returns a response code that was not declared in the OpenAPI document, a
`{{ package_name }}.api.errors.ApiResponseError` wil be raised
with the `response` attribute set to the `httpx.Response` that was received.

1. Any endpoint which did not have a tag will be in `{{ package_name }}.api.default`

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