Skip to content

Commit e6d2b1a

Browse files
authored
Merge branch 'main' into fix-multipart-body-file-array
2 parents bfd1d52 + 9cbca04 commit e6d2b1a

File tree

75 files changed

+1365
-638
lines changed

Some content is hidden

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

75 files changed

+1365
-638
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
default: major
3+
---
4+
5+
# `const` values in responses are now validated at runtime
6+
7+
Prior to this version, `const` values returned from servers were assumed to always be correct. Now, if a server returns
8+
an unexpected value, the client will raise a `ValueError`. This should enable better usage with `oneOf`.
9+
10+
PR #1024. Thanks @peter-greenatlas!
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
default: major
3+
---
4+
5+
# Switch YAML parsing to 1.2
6+
7+
This change switches the YAML parsing library to `ruamel.yaml` which follows the YAML 1.2 specification.
8+
[There are breaking changes](https://yaml.readthedocs.io/en/latest/pyyaml/#defaulting-to-yaml-12-support) from YAML 1.1 to 1.2,
9+
though they will not affect most use cases.
10+
11+
PR #1042 fixes #1041. Thanks @rtaycher!

.github/workflows/checks.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
os: [ ubuntu-latest, macos-latest, windows-latest ]
1616
runs-on: ${{ matrix.os }}
1717
steps:
18-
- uses: actions/checkout@v4.1.1
18+
- uses: actions/checkout@v4.1.6
1919
- name: Set up Python
20-
uses: actions/setup-python@v5.0.0
20+
uses: actions/setup-python@v5.1.0
2121
with:
2222
python-version: ${{ matrix.python }}
2323

@@ -67,7 +67,7 @@ jobs:
6767
if: matrix.os == 'ubuntu-latest'
6868

6969
- name: Store coverage report
70-
uses: actions/upload-artifact@v4.3.1
70+
uses: actions/upload-artifact@v4.3.3
7171
if: matrix.os == 'ubuntu-latest'
7272
with:
7373
name: coverage-${{ matrix.python }}
@@ -79,12 +79,12 @@ jobs:
7979
needs: test
8080
runs-on: ubuntu-latest
8181
steps:
82-
- uses: actions/checkout@v4.1.1
82+
- uses: actions/checkout@v4.1.6
8383
- uses: actions/setup-python@v5
8484
with:
8585
python-version: "3.12"
8686
- name: Download coverage reports
87-
uses: actions/download-artifact@v4.1.2
87+
uses: actions/download-artifact@v4.1.7
8888
with:
8989
merge-multiple: true
9090

@@ -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.3.1
112+
uses: actions/upload-artifact@v4.3.3
113113
with:
114114
name: html-report
115115
path: htmlcov
@@ -129,9 +129,9 @@ jobs:
129129
ports:
130130
- "3000:3000"
131131
steps:
132-
- uses: actions/checkout@v4.1.1
132+
- uses: actions/checkout@v4.1.6
133133
- name: Set up Python
134-
uses: actions/setup-python@v5.0.0
134+
uses: actions/setup-python@v5.1.0
135135
with:
136136
python-version: "3.8"
137137
- name: Get Python Version

.github/workflows/preview_release_pr.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ jobs:
77
if: "!contains(github.event.head_commit.message, 'chore: prepare release')" # Skip merges from releases
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v4.1.1
10+
- uses: actions/checkout@v4.1.6
1111
with:
1212
fetch-depth: 0
1313
token: ${{ secrets.PAT }}
1414
- name: Configure Git
1515
run: |
1616
git config --global user.name GitHub Actions
1717
git config user.email github-actions@github.com
18-
- uses: knope-dev/action@v2.0.0
18+
- uses: knope-dev/action@v2.1.0
1919
with:
20-
version: 0.14.0
20+
version: 0.16.2
2121
- run: knope prepare-release --verbose
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.PAT }}

.github/workflows/release-dry-run.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
release:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v4.1.1
9+
- uses: actions/checkout@v4.1.6
1010
with:
1111
fetch-depth: 0
1212
token: ${{ secrets.GITHUB_TOKEN }}
1313
- name: Install Knope
14-
uses: knope-dev/action@v2.0.0
14+
uses: knope-dev/action@v2.1.0
1515
with:
16-
version: 0.14.0
16+
version: 0.16.2
1717
- run: knope prepare-release --dry-run

.github/workflows/release.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ jobs:
1212
permissions:
1313
id-token: write
1414
steps:
15-
- uses: actions/checkout@v4.1.1
15+
- uses: actions/checkout@v4.1.6
1616
with:
1717
fetch-depth: 0
1818
token: ${{ secrets.PAT }}
1919
- name: Install Knope
20-
uses: knope-dev/action@v2.0.0
20+
uses: knope-dev/action@v2.1.0
2121
with:
22-
version: 0.14.0
22+
version: 0.16.2
2323
- name: Install Hatchling
2424
run: pip install --upgrade hatchling
2525
- name: Build
2626
run: hatchling build
2727
- name: Push to PyPI
28-
uses: pypa/gh-action-pypi-publish@v1.8.11
28+
uses: pypa/gh-action-pypi-publish@v1.8.14
2929
- name: Create GitHub Release
3030
run: knope release
3131
env:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ build/
44
dist/
55
*.egg-info/
66
.pytest_cache/
7+
.ruff_cache
78

89
# macOS
910
.DS_Store

CHANGELOG.md

+56
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,62 @@ 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.19.1 (2024-03-27)
17+
18+
### Features
19+
20+
#### Add config option to override content types
21+
22+
You can now define a `content_type_overrides` field in your `config.yml`:
23+
24+
```yaml
25+
content_type_overrides:
26+
application/zip: application/octet-stream
27+
```
28+
29+
This allows `openapi-python-client` to generate code for content types it doesn't recognize.
30+
31+
PR #1010 closes #810. Thanks @gaarutyunov!
32+
33+
### Fixes
34+
35+
#### Add aliases to `Client` for pyright
36+
37+
This should resolve incompatibilities between the generated `Client` class and the pyright type checker.
38+
39+
PR #1009 closes #909. Thanks @patrick91!
40+
41+
## 0.19.0 (2024-03-06)
42+
43+
### Breaking Changes
44+
45+
#### Update PDM metadata syntax
46+
47+
Metadata generated for PDM will now use the new `distribution = true` syntax instead of `package-type = "library"`.
48+
New packages generated with `--meta pdm` will require PDM `2.12.0` or later to build.
49+
50+
### Features
51+
52+
#### Add response content to `UnexpectedStatus` exception
53+
54+
The error message for `UnexpectedStatus` exceptions will now include the UTF-8 decoded (ignoring errors) body of the response.
55+
56+
PR #989 implements #840. Thanks @harabat!
57+
58+
### Fixes
59+
60+
#### Allow hyphens in path parameters
61+
62+
Before now, path parameters which were invalid Python identifiers were not allowed, and would fail generation with an
63+
"Incorrect path templating" error. In particular, this meant that path parameters with hyphens were not allowed.
64+
This has now been fixed!
65+
66+
PR #986 fixed issue #976. Thanks @harabat!
67+
68+
> [!WARNING]
69+
> This change may break custom templates, see [this diff](https://github.com/openapi-generators/openapi-python-client/pull/986/files#diff-0de8437b26075d8fe8454cf47d8d95d4835c7f827fa87328e03f690412be803e)
70+
> if you have trouble upgrading.
71+
1672
## 0.18.0 (2024-02-22)
1773

1874
### Breaking Changes

README.md

+10
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ If this option results in conflicts, you will need to manually override class na
156156

157157
By default, the timeout for retrieving the schema file via HTTP is 5 seconds. In case there is an error when retrieving the schema, you might try and increase this setting to a higher value.
158158

159+
### content_type_overrides
160+
161+
Normally, `openapi-python-client` will skip any bodies or responses that it doesn't recognize the content type for.
162+
This config tells the generator to treat a given content type like another.
163+
164+
```yaml
165+
content_type_overrides:
166+
application/zip: application/octet-stream
167+
```
168+
159169
[changelog.md]: CHANGELOG.md
160170
[poetry]: https://python-poetry.org/
161171
[PDM]: https://pdm-project.org/latest/

end_to_end_tests/baseline_openapi_3.0.json

+51
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,27 @@
15081508
}
15091509
}
15101510
},
1511+
"/naming/{hyphen-in-path}": {
1512+
"get": {
1513+
"tags": ["naming"],
1514+
"operationId": "hyphen_in_path",
1515+
"parameters": [
1516+
{
1517+
"name": "hyphen-in-path",
1518+
"in": "path",
1519+
"required": true,
1520+
"schema": {
1521+
"type": "string"
1522+
}
1523+
}
1524+
],
1525+
"responses": {
1526+
"200": {
1527+
"description": "Successful response"
1528+
}
1529+
}
1530+
}
1531+
},
15111532
"/parameter-references/{path_param}": {
15121533
"get": {
15131534
"tags": [
@@ -1608,6 +1629,36 @@
16081629
}
16091630
}
16101631
}
1632+
},
1633+
"/config/content-type-override": {
1634+
"post": {
1635+
"tags": [
1636+
"config"
1637+
],
1638+
"summary": "Content Type Override",
1639+
"operationId": "content_type_override",
1640+
"requestBody": {
1641+
"content": {
1642+
"openapi/python/client": {
1643+
"schema": {
1644+
"type": "string"
1645+
}
1646+
}
1647+
}
1648+
},
1649+
"responses": {
1650+
"200": {
1651+
"description": "Successful Response",
1652+
"content": {
1653+
"openapi/python/client": {
1654+
"schema": {
1655+
"type": "string"
1656+
}
1657+
}
1658+
}
1659+
}
1660+
}
1661+
}
16111662
}
16121663
},
16131664
"components": {

end_to_end_tests/baseline_openapi_3.1.yaml

+51
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,27 @@ info:
15021502
}
15031503
}
15041504
},
1505+
"/naming/{hyphen-in-path}": {
1506+
"get": {
1507+
"tags": [ "naming" ],
1508+
"operationId": "hyphen_in_path",
1509+
"parameters": [
1510+
{
1511+
"name": "hyphen-in-path",
1512+
"in": "path",
1513+
"required": true,
1514+
"schema": {
1515+
"type": "string"
1516+
}
1517+
}
1518+
],
1519+
"responses": {
1520+
"200": {
1521+
"description": "Successful response"
1522+
}
1523+
}
1524+
}
1525+
},
15051526
"/parameter-references/{path_param}": {
15061527
"get": {
15071528
"tags": [
@@ -1602,6 +1623,36 @@ info:
16021623
}
16031624
}
16041625
}
1626+
},
1627+
"/config/content-type-override": {
1628+
"post": {
1629+
"tags": [
1630+
"config"
1631+
],
1632+
"summary": "Content Type Override",
1633+
"operationId": "content_type_override",
1634+
"requestBody": {
1635+
"content": {
1636+
"openapi/python/client": {
1637+
"schema": {
1638+
"type": "string"
1639+
}
1640+
}
1641+
}
1642+
},
1643+
"responses": {
1644+
"200": {
1645+
"description": "Successful Response",
1646+
"content": {
1647+
"openapi/python/client": {
1648+
"schema": {
1649+
"type": "string"
1650+
}
1651+
}
1652+
}
1653+
}
1654+
}
1655+
}
16051656
}
16061657
}
16071658
"components": {

end_to_end_tests/config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ class_overrides:
99
class_name: AnEnumValue
1010
module_name: an_enum_value
1111
field_prefix: attr_
12+
content_type_overrides:
13+
openapi/python/client: application/json

end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
""" Contains methods for accessing the API """
1+
"""Contains methods for accessing the API"""
22

33
from typing import Type
44

55
from .bodies import BodiesEndpoints
6+
from .config import ConfigEndpoints
67
from .default import DefaultEndpoints
78
from .defaults import DefaultsEndpoints
89
from .enums import EnumsEndpoints
@@ -64,3 +65,7 @@ def naming(cls) -> Type[NamingEndpoints]:
6465
@classmethod
6566
def parameter_references(cls) -> Type[ParameterReferencesEndpoints]:
6667
return ParameterReferencesEndpoints
68+
69+
@classmethod
70+
def config(cls) -> Type[ConfigEndpoints]:
71+
return ConfigEndpoints

end_to_end_tests/custom-templates-golden-record/my_test_api_client/api/bodies/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Contains methods for accessing the API Endpoints """
1+
"""Contains methods for accessing the API Endpoints"""
22

33
import types
44

0 commit comments

Comments
 (0)