Skip to content

Commit 2c3ab6b

Browse files
authored
Merge branch 'main' into fix-multipart-body-file-array
2 parents fe841d7 + 9600088 commit 2c3ab6b

38 files changed

+554
-1067
lines changed

.changeset/add_metapdm_option_for_generating_pep621_pdm_metadata.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

.changeset/add_original_openapi_data_attribute_to_response_object.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/check_for_changes.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/checks.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
shell: bash
2828

2929
- name: Cache dependencies
30-
uses: actions/cache@v3
30+
uses: actions/cache@v4
3131
with:
3232
path: .venv
3333
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm.lock') }}
@@ -67,7 +67,7 @@ jobs:
6767
if: matrix.os == 'ubuntu-latest'
6868

6969
- name: Store coverage report
70-
uses: actions/upload-artifact@v4.1.0
70+
uses: actions/upload-artifact@v4.3.0
7171
if: matrix.os == 'ubuntu-latest'
7272
with:
7373
name: coverage-${{ matrix.python }}
@@ -109,7 +109,7 @@ jobs:
109109
.venv/bin/python -m coverage report --fail-under=100
110110
111111
- name: Upload HTML report if check failed.
112-
uses: actions/upload-artifact@v4.1.0
112+
uses: actions/upload-artifact@v4.3.0
113113
with:
114114
name: html-report
115115
path: htmlcov
@@ -138,7 +138,7 @@ jobs:
138138
id: get_python_version
139139
run: echo "python_version=$(python --version)" >> $GITHUB_OUTPUT
140140
- name: Cache dependencies
141-
uses: actions/cache@v3
141+
uses: actions/cache@v4
142142
with:
143143
path: .venv
144144
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/pdm.lock') }}
@@ -149,13 +149,8 @@ jobs:
149149
pip install pdm
150150
python -m venv .venv
151151
pdm install
152-
- name: Regenerate Integration Client
153-
run: |
154-
pdm run openapi-python-client update --url http://localhost:3000/openapi.json --config integration-tests-config.yaml --meta pdm
155-
- name: Check for any file changes
156-
run: python .github/check_for_changes.py
157152
- name: Cache Generated Client Dependencies
158-
uses: actions/cache@v3
153+
uses: actions/cache@v4
159154
with:
160155
path: integration-tests/.venv
161156
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/pdm.lock') }}

CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,42 @@ Programmatic usage of this project (e.g., importing it as a Python module) and t
1313

1414
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).
1515

16+
## 0.17.2 (2024-01-15)
17+
18+
### Features
19+
20+
#### Add `--meta=pdm` option for generating PEP621 + PDM metadata
21+
22+
The default metadata is still `--meta=poetry`, which generates a `pyproject.toml` file with Poetry-specific metadata.
23+
This change adds the `--meta=pdm` option which includes [PDM](https://pdm-project.org/latest/)-specific metadata, but also
24+
standard [PEP621](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#writing-pyproject-toml)
25+
metadata. This may be useful as a starting point for other dependency managers & build tools (like Hatch).
26+
27+
#### Add original OpenAPI `data` attribute to `Response` object
28+
29+
PR #767
30+
31+
In custom templates, you can now access a `response.data` attribute that contains the original OpenAPI definition of the
32+
response (Response Object or Reference Object).
33+
34+
#### Include the `UP` rule for generated Ruff config
35+
36+
This enables [pyupgrade-like improvements](https://docs.astral.sh/ruff/rules/#pyupgrade-up) which should replace some
37+
`.format()` calls with f-strings.
38+
39+
### Fixes
40+
41+
#### Fix Ruff formatting for `--meta=none`
42+
43+
PR #940 fixes issue #939. Thanks @satwell!
44+
45+
Due to the lack of `pyproject.toml`, Ruff was not getting configured properly when `--meta=none`.
46+
As a result, it didn't clean up common generation issues like duplicate imports, which would then cause errors from
47+
linters.
48+
49+
This is now fixed by changing the default `post_hook` to `ruff check . --fix --extend-select=I` when `--meta=none`.
50+
Using `generate --meta=none` should now be almost identical to the code generated by `update`.
51+
1652
## 0.17.1 (2024-01-04)
1753

1854
### Features
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
post_hooks:
2+
- echo "this should fail" && exit 1

end_to_end_tests/golden-record/my_test_api_client/api/parameter_references/get_parameter_references_path_param.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def _get_kwargs(
3434

3535
_kwargs: Dict[str, Any] = {
3636
"method": "get",
37-
"url": "/parameter-references/{path_param}".format(
38-
path_param=path_param,
39-
),
37+
"url": f"/parameter-references/{path_param}",
4038
"params": params,
4139
"cookies": cookies,
4240
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _get_kwargs(
2121

2222
_kwargs: Dict[str, Any] = {
2323
"method": "delete",
24-
"url": "/common_parameters_overriding/{param}".format(
25-
param=param_path,
26-
),
24+
"url": f"/common_parameters_overriding/{param_path}",
2725
"params": params,
2826
}
2927

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ def _get_kwargs(
2121

2222
_kwargs: Dict[str, Any] = {
2323
"method": "get",
24-
"url": "/common_parameters_overriding/{param}".format(
25-
param=param_path,
26-
),
24+
"url": f"/common_parameters_overriding/{param_path}",
2725
"params": params,
2826
}
2927

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def _get_kwargs(
3131

3232
_kwargs: Dict[str, Any] = {
3333
"method": "get",
34-
"url": "/same-name-multiple-locations/{param}".format(
35-
param=param_path,
36-
),
34+
"url": f"/same-name-multiple-locations/{param_path}",
3735
"params": params,
3836
"cookies": cookies,
3937
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ def _get_kwargs(
1616
) -> Dict[str, Any]:
1717
_kwargs: Dict[str, Any] = {
1818
"method": "get",
19-
"url": "/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}".format(
20-
param4=param4,
21-
param2=param2,
22-
param1=param1,
23-
param3=param3,
24-
),
19+
"url": f"/multiple-path-parameters/{param4}/something/{param2}/{param1}/{param3}",
2520
}
2621

2722
return _kwargs

end_to_end_tests/golden-record/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ requires = ["poetry-core>=1.0.0"]
2121
build-backend = "poetry.core.masonry.api"
2222

2323
[tool.ruff]
24-
select = ["F", "I"]
24+
select = ["F", "I", "UP"]
2525
line-length = 120

end_to_end_tests/metadata_snapshots/pdm.pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ requires = ["pdm-backend"]
1919
build-backend = "pdm.backend"
2020

2121
[tool.ruff]
22-
select = ["F", "I"]
22+
select = ["F", "I", "UP"]
2323
line-length = 120

end_to_end_tests/metadata_snapshots/poetry.pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ requires = ["poetry-core>=1.0.0"]
2121
build-backend = "poetry.core.masonry.api"
2222

2323
[tool.ruff]
24-
select = ["F", "I"]
24+
select = ["F", "I", "UP"]
2525
line-length = 120

end_to_end_tests/regen_golden_record.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ def regen_custom_template_golden_record():
7979
gr_path = Path(__file__).parent / "golden-record"
8080
tpl_gr_path = Path(__file__).parent / "custom-templates-golden-record"
8181

82-
output_path = Path(tempfile.mkdtemp())
82+
output_path = Path.cwd() / "my-test-api-client"
8383
config_path = Path(__file__).parent / "config.yml"
8484

8585
shutil.rmtree(tpl_gr_path, ignore_errors=True)
8686

87-
os.chdir(str(output_path.absolute()))
8887
result = runner.invoke(
8988
app,
9089
[
@@ -96,9 +95,8 @@ def regen_custom_template_golden_record():
9695
)
9796

9897
if result.stdout:
99-
generated_output_path = output_path / "my-test-api-client"
100-
for f in generated_output_path.glob("**/*"): # nb: works for Windows and Unix
101-
relative_to_generated = f.relative_to(generated_output_path)
98+
for f in output_path.glob("**/*"): # nb: works for Windows and Unix
99+
relative_to_generated = f.relative_to(output_path)
102100
gr_file = gr_path / relative_to_generated
103101
if not gr_file.exists():
104102
print(f"{gr_file} does not exist, ignoring")

end_to_end_tests/test-3-1-golden-record/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ requires = ["poetry-core>=1.0.0"]
2121
build-backend = "poetry.core.masonry.api"
2222

2323
[tool.ruff]
24-
select = ["F", "I"]
24+
select = ["F", "I", "UP"]
2525
line-length = 120

end_to_end_tests/test-3-1-golden-record/test_3_1_features_client/api/const/post_const_path.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ def _get_kwargs(
2828

2929
_kwargs: Dict[str, Any] = {
3030
"method": "post",
31-
"url": "/const/{path}".format(
32-
path=path,
33-
),
31+
"url": f"/const/{path}",
3432
"params": params,
3533
}
3634

0 commit comments

Comments
 (0)