Skip to content

Commit 2303165

Browse files
authored
Merge branch 'main' into fix-datetime-conflict
2 parents a29be49 + 55cb94a commit 2303165

File tree

63 files changed

+1455
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1455
-119
lines changed

.github/workflows/checks.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
- name: Run pylint
6262
run: poetry run pylint openapi_python_client
6363

64+
- name: Regenerate Golden Record
65+
run: poetry run task regen_e2e
66+
6467
- name: Run pytest
6568
run: poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp
6669
env:
@@ -73,3 +76,63 @@ jobs:
7376
- uses: codecov/codecov-action@v2
7477
with:
7578
files: ./coverage.xml
79+
80+
- uses: stefanzweifel/git-auto-commit-action@v4
81+
if: runner.os == 'Linux'
82+
with:
83+
commit_message: "chore: Regenerate E2E Golden Record"
84+
file_pattern: end_to_end_tests/golden-record end_to_end_tests/custom-templates-golden-record
85+
86+
integration:
87+
name: Integration Tests
88+
runs-on: ubuntu-latest
89+
services:
90+
openapi-test-server:
91+
image: ghcr.io/openapi-generators/openapi-test-server:latest
92+
ports:
93+
- "3000:3000"
94+
steps:
95+
- uses: actions/checkout@v2
96+
- name: Set up Python
97+
uses: actions/setup-python@v2
98+
with:
99+
python-version: "3.10"
100+
- name: Get Python Version
101+
id: get_python_version
102+
run: echo "::set-output name=python_version::$(python --version)"
103+
- name: Cache dependencies
104+
uses: actions/cache@v2
105+
with:
106+
path: .venv
107+
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry.lock') }}
108+
restore-keys: |
109+
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
110+
- name: Install dependencies
111+
run: |
112+
pip install poetry
113+
python -m venv .venv
114+
poetry run python -m pip install --upgrade pip
115+
poetry install
116+
- name: Regenerate Integration Client
117+
run: |
118+
poetry run openapi-python-client update --url http://localhost:3000/openapi.json --config integration-tests-config.yaml
119+
- name: Cache Generated Client Dependencies
120+
uses: actions/cache@v2
121+
with:
122+
path: integration-tests/.venv
123+
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/poetry.lock') }}
124+
restore-keys: |
125+
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies
126+
- name: Install Integration Dependencies
127+
run: |
128+
cd integration-tests
129+
python -m venv .venv
130+
poetry run python -m pip install --upgrade pip
131+
poetry install
132+
- name: Run Tests
133+
run: |
134+
cd integration-tests
135+
poetry run pytest
136+
- uses: stefanzweifel/git-auto-commit-action@v4
137+
with:
138+
commit_message: "chore: Regenerate Integration Client"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
Breaking changes to any of the following will cause the **minor** version to be incremented (as long as this project is 0.x). Only these pieces are considered part of the public API:
8+
9+
- The _behavior_ of the generated code. Specifically, the way in which generated endpoints and classes are called and the way in which those calls communicate with an OpenAPI server. Any other property of the generated code is not considered part of the versioned, public API (e.g., code formatting, comments).
10+
- The invocation of the CLI (e.g., commands or arguments).
11+
12+
Programmatic usage of this project (e.g., importing it as a Python module) and the usage of custom templates are not considered part of the public API and therefore may change behavior at any time without notice.
13+
14+
The 0.x prefix used in versions for this project is to indicate that breaking changes are expected frequently (several times a year). Breaking changes will increment the minor number, all other changes will increment the patch number. You can track the progress toward 1.0 [here](https://github.com/openapi-generators/openapi-python-client/projects/2).
15+
716
## 0.10.8
817

918
### Features

CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
2. When in a Poetry shell (`poetry shell`) run `task check` in order to run most of the same checks CI runs. This will auto-reformat the code, check type annotations, run unit tests, check code coverage, and lint the code.
2323

24-
### Rework end to end tests
24+
### Rework end-to-end tests
2525

26-
3. If you're writing a new feature, try to add it to the end to end test.
26+
3. If you're writing a new feature, try to add it to the end-to-end test.
2727
1. If adding support for a new OpenAPI feature, add it somewhere in `end_to_end_tests/openapi.json`
28-
2. Regenerate the "golden records" with `task regen`. This client is generated from the OpenAPI document used for end to end testing.
28+
2. Regenerate the "golden records" with `task regen`. This client is generated from the OpenAPI document used for end-to-end testing.
2929
3. Check the changes to `end_to_end_tests/golden-record` to confirm only what you intended to change did change and that the changes look correct.
30-
4. Run the end to end tests with `task e2e`. This will generate clients against `end_to_end_tests/openapi.json` and compare them with the golden record. The tests will fail if **anything is different**. The end to end tests are not included in `task check` as they take longer to run and don't provide very useful feedback in the event of failure. If an e2e test does fail, the easiest way to check what's wrong is to run `task regen` and check the diffs. You can also use `task re` which will run `regen` and `e2e` in that order.
30+
4. **If you added a test above OR modified the templates**: Run the end-to-end tests with `task e2e`. This will generate clients against `end_to_end_tests/openapi.json` and compare them with the golden record. The tests will fail if **anything is different**. The end-to-end tests are not included in `task check` as they take longer to run and don't provide very useful feedback in the event of failure. If an e2e test does fail, the easiest way to check what's wrong is to run `task regen` and check the diffs. You can also use `task re` which will run `regen` and `e2e` in that order.
31+
3132

3233
## Creating a Pull Request
3334

end_to_end_tests/golden-record/my_test_api_client/api/default/get_common_parameters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def _get_kwargs(
2222
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
2323

2424
return {
25+
"method": "get",
2526
"url": url,
2627
"headers": headers,
2728
"cookies": cookies,
@@ -57,7 +58,7 @@ def sync_detailed(
5758
common=common,
5859
)
5960

60-
response = httpx.get(
61+
response = httpx.request(
6162
verify=client.verify_ssl,
6263
**kwargs,
6364
)
@@ -84,6 +85,6 @@ async def asyncio_detailed(
8485
)
8586

8687
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
87-
response = await _client.get(**kwargs)
88+
response = await _client.request(**kwargs)
8889

8990
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/default/post_common_parameters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def _get_kwargs(
2222
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
2323

2424
return {
25+
"method": "post",
2526
"url": url,
2627
"headers": headers,
2728
"cookies": cookies,
@@ -57,7 +58,7 @@ def sync_detailed(
5758
common=common,
5859
)
5960

60-
response = httpx.post(
61+
response = httpx.request(
6162
verify=client.verify_ssl,
6263
**kwargs,
6364
)
@@ -84,6 +85,6 @@ async def asyncio_detailed(
8485
)
8586

8687
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
87-
response = await _client.post(**kwargs)
88+
response = await _client.request(**kwargs)
8889

8990
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/location/get_location_query_optionality.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def _get_kwargs(
4343
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
4444

4545
return {
46+
"method": "get",
4647
"url": url,
4748
"headers": headers,
4849
"cookies": cookies,
@@ -87,7 +88,7 @@ def sync_detailed(
8788
not_null_not_required=not_null_not_required,
8889
)
8990

90-
response = httpx.get(
91+
response = httpx.request(
9192
verify=client.verify_ssl,
9293
**kwargs,
9394
)
@@ -123,6 +124,6 @@ async def asyncio_detailed(
123124
)
124125

125126
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
126-
response = await _client.get(**kwargs)
127+
response = await _client.request(**kwargs)
127128

128129
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/parameters/delete_common_parameters_overriding_param.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def _get_kwargs(
2323
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
2424

2525
return {
26+
"method": "delete",
2627
"url": url,
2728
"headers": headers,
2829
"cookies": cookies,
@@ -61,7 +62,7 @@ def sync_detailed(
6162
param_query=param_query,
6263
)
6364

64-
response = httpx.delete(
65+
response = httpx.request(
6566
verify=client.verify_ssl,
6667
**kwargs,
6768
)
@@ -91,6 +92,6 @@ async def asyncio_detailed(
9192
)
9293

9394
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
94-
response = await _client.delete(**kwargs)
95+
response = await _client.request(**kwargs)
9596

9697
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_common_parameters_overriding_param.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def _get_kwargs(
2323
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
2424

2525
return {
26+
"method": "get",
2627
"url": url,
2728
"headers": headers,
2829
"cookies": cookies,
@@ -63,7 +64,7 @@ def sync_detailed(
6364
param_query=param_query,
6465
)
6566

66-
response = httpx.get(
67+
response = httpx.request(
6768
verify=client.verify_ssl,
6869
**kwargs,
6970
)
@@ -95,6 +96,6 @@ async def asyncio_detailed(
9596
)
9697

9798
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
98-
response = await _client.get(**kwargs)
99+
response = await _client.request(**kwargs)
99100

100101
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/parameters/get_same_name_multiple_locations_param.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def _get_kwargs(
3131
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
3232

3333
return {
34+
"method": "get",
3435
"url": url,
3536
"headers": headers,
3637
"cookies": cookies,
@@ -75,7 +76,7 @@ def sync_detailed(
7576
param_cookie=param_cookie,
7677
)
7778

78-
response = httpx.get(
79+
response = httpx.request(
7980
verify=client.verify_ssl,
8081
**kwargs,
8182
)
@@ -111,6 +112,6 @@ async def asyncio_detailed(
111112
)
112113

113114
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
114-
response = await _client.get(**kwargs)
115+
response = await _client.request(**kwargs)
115116

116117
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/parameters/multiple_path_parameters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def _get_kwargs(
2222
cookies: Dict[str, Any] = client.get_cookies()
2323

2424
return {
25+
"method": "get",
2526
"url": url,
2627
"headers": headers,
2728
"cookies": cookies,
@@ -65,7 +66,7 @@ def sync_detailed(
6566
client=client,
6667
)
6768

68-
response = httpx.get(
69+
response = httpx.request(
6970
verify=client.verify_ssl,
7071
**kwargs,
7172
)
@@ -101,6 +102,6 @@ async def asyncio_detailed(
101102
)
102103

103104
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
104-
response = await _client.get(**kwargs)
105+
response = await _client.request(**kwargs)
105106

106107
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/tag1/get_tag_with_number.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def _get_kwargs(
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

1818
return {
19+
"method": "get",
1920
"url": url,
2021
"headers": headers,
2122
"cookies": cookies,
@@ -45,7 +46,7 @@ def sync_detailed(
4546
client=client,
4647
)
4748

48-
response = httpx.get(
49+
response = httpx.request(
4950
verify=client.verify_ssl,
5051
**kwargs,
5152
)
@@ -67,6 +68,6 @@ async def asyncio_detailed(
6768
)
6869

6970
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
70-
response = await _client.get(**kwargs)
71+
response = await _client.request(**kwargs)
7172

7273
return _build_response(response=response)

end_to_end_tests/golden-record/my_test_api_client/api/tests/defaults_tests_defaults_post.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def _get_kwargs(
7575
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
7676

7777
return {
78+
"method": "post",
7879
"url": url,
7980
"headers": headers,
8081
"cookies": cookies,
@@ -153,7 +154,7 @@ def sync_detailed(
153154
required_model_prop=required_model_prop,
154155
)
155156

156-
response = httpx.post(
157+
response = httpx.request(
157158
verify=client.verify_ssl,
158159
**kwargs,
159160
)
@@ -261,7 +262,7 @@ async def asyncio_detailed(
261262
)
262263

263264
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
264-
response = await _client.post(**kwargs)
265+
response = await _client.request(**kwargs)
265266

266267
return _build_response(response=response)
267268

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_booleans.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def _get_kwargs(
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

1818
return {
19+
"method": "get",
1920
"url": url,
2021
"headers": headers,
2122
"cookies": cookies,
@@ -56,7 +57,7 @@ def sync_detailed(
5657
client=client,
5758
)
5859

59-
response = httpx.get(
60+
response = httpx.request(
6061
verify=client.verify_ssl,
6162
**kwargs,
6263
)
@@ -98,7 +99,7 @@ async def asyncio_detailed(
9899
)
99100

100101
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
101-
response = await _client.get(**kwargs)
102+
response = await _client.request(**kwargs)
102103

103104
return _build_response(response=response)
104105

end_to_end_tests/golden-record/my_test_api_client/api/tests/get_basic_list_of_floats.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def _get_kwargs(
1616
cookies: Dict[str, Any] = client.get_cookies()
1717

1818
return {
19+
"method": "get",
1920
"url": url,
2021
"headers": headers,
2122
"cookies": cookies,
@@ -56,7 +57,7 @@ def sync_detailed(
5657
client=client,
5758
)
5859

59-
response = httpx.get(
60+
response = httpx.request(
6061
verify=client.verify_ssl,
6162
**kwargs,
6263
)
@@ -98,7 +99,7 @@ async def asyncio_detailed(
9899
)
99100

100101
async with httpx.AsyncClient(verify=client.verify_ssl) as _client:
101-
response = await _client.get(**kwargs)
102+
response = await _client.request(**kwargs)
102103

103104
return _build_response(response=response)
104105

0 commit comments

Comments
 (0)