Skip to content

Commit 370c66b

Browse files
committed
Merge branch 'main' into fix-multipart-body-file-array
# Conflicts: # end_to_end_tests/golden-record/my_test_api_client/models/model_with_additional_properties_refed.py # end_to_end_tests/golden-record/my_test_api_client/models/model_with_any_json_properties.py # end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_a.py # end_to_end_tests/golden-record/my_test_api_client/models/model_with_circular_ref_in_additional_properties_b.py # end_to_end_tests/golden-record/my_test_api_client/models/model_with_primitive_additional_properties_a_date_holder.py # end_to_end_tests/golden-record/my_test_api_client/models/model_with_recursive_ref_in_additional_properties.py # openapi_python_client/templates/model.py.jinja
2 parents 2c3ab6b + eeb1326 commit 370c66b

File tree

59 files changed

+1099
-455
lines changed

Some content is hidden

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

59 files changed

+1099
-455
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
default: patch
3+
---
4+
5+
# Allow parameters with names differing only by case
6+
7+
If you have two parameters to an endpoint named `mixedCase` and `mixed_case`, previously, this was a conflict and the endpoint would not be generated.
8+
Now, the generator will skip snake-casing the parameters and use the names as-is. Note that this means if neither of the parameters _was_ snake case, neither _will be_ in the generated code.
9+
10+
Fixes #922 reported by @macmoritz & @benedikt-bartscher.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
default: patch
3+
---
4+
5+
# Fix naming conflicts with properties in models with mixed casing
6+
7+
If you had an object with two properties, where the names differed only by case, conflicting properties would be generated in the model, which then failed the linting step (when using default config). For example, this:
8+
9+
```yaml
10+
type: "object"
11+
properties:
12+
MixedCase:
13+
type: "string"
14+
mixedCase:
15+
type: "string"
16+
```
17+
18+
Would generate a class like this:
19+
20+
```python
21+
class MyModel:
22+
mixed_case: str
23+
mixed_case: str
24+
```
25+
26+
Now, neither of the properties will be forced into snake case, and the generated code will look like this:
27+
28+
```python
29+
class MyModel:
30+
MixedCase: str
31+
mixedCase: str
32+
```
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
default: major
3+
---
4+
5+
# For custom templates, changed type of endpoint parameters
6+
7+
**This does not affect projects that are not using `--custom-template-path`**
8+
9+
The type of these properties on `Endpoint` has been changed from `Dict[str, Property]` to `List[Property]`:
10+
11+
- `path_parameters`
12+
- `query_parameters`
13+
- `header_parameters`
14+
- `cookie_parameters`
15+
16+
If your templates are very close to the default templates, you can probably just remove `.values()` anywhere it appears.
17+
18+
The type of `iter_all_parameters()` is also different, you probably want `list_all_parameters()` instead.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
default: major
3+
---
4+
5+
# Updated generated config for Ruff v0.2
6+
7+
This only affects projects using the `generate` command, not the `update` command. The `pyproject.toml` file generated which configures Ruff for linting and formatting has been updated to the 0.2 syntax, which means it will no longer work with Ruff 0.1.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
default: major
3+
---
4+
5+
# Updated naming strategy for conflicting properties
6+
7+
While fixing #922, some naming strategies were updated. These should mostly be backwards compatible, but there may be
8+
some small differences in generated code. Make sure to check your diffs before pushing updates to consumers!

.github/workflows/checks.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
if: matrix.os == 'ubuntu-latest'
6868

6969
- name: Store coverage report
70-
uses: actions/upload-artifact@v4.3.0
70+
uses: actions/upload-artifact@v4.3.1
7171
if: matrix.os == 'ubuntu-latest'
7272
with:
7373
name: coverage-${{ matrix.python }}
@@ -84,7 +84,7 @@ jobs:
8484
with:
8585
python-version: "3.12"
8686
- name: Download coverage reports
87-
uses: actions/download-artifact@v4.1.1
87+
uses: actions/download-artifact@v4.1.2
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.0
112+
uses: actions/upload-artifact@v4.3.1
113113
with:
114114
name: html-report
115115
path: htmlcov

.github/workflows/preview_release_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
git config user.email github-actions@github.com
1818
- uses: knope-dev/action@v2.0.0
1919
with:
20-
version: 0.13.4
20+
version: 0.14.0
2121
- run: knope prepare-release --verbose
2222
env:
2323
GITHUB_TOKEN: ${{ secrets.PAT }}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ jobs:
1313
- name: Install Knope
1414
uses: knope-dev/action@v2.0.0
1515
with:
16-
version: 0.13.4
16+
version: 0.14.0
1717
- run: knope prepare-release --dry-run

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Install Knope
2020
uses: knope-dev/action@v2.0.0
2121
with:
22-
version: 0.13.4
22+
version: 0.14.0
2323
- name: Install Hatchling
2424
run: pip install --upgrade hatchling
2525
- name: Build

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ 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.3 (2024-02-20)
17+
18+
### Fixes
19+
20+
#### Remove spurious field_dict.update({}) for types without properties (#969)
21+
22+
#### Fix invalid type check for nested unions
23+
24+
Nested union types (unions of unions) were generating `isinstance()` checks that were not valid (at least for Python 3.9).
25+
26+
Thanks to @codebutler for PR #959 which fixes #958 and #967.
27+
1628
## 0.17.2 (2024-01-15)
1729

1830
### Features

end_to_end_tests/baseline_openapi_3.0.json

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@
850850
}
851851
}
852852
}
853-
},
853+
},
854854
"/enum/int": {
855855
"post": {
856856
"tags": [
@@ -1462,6 +1462,50 @@
14621462
}
14631463
}
14641464
},
1465+
"/naming/mixed-case": {
1466+
"get": {
1467+
"tags": ["naming"],
1468+
"operationId": "mixed_case",
1469+
"parameters": [
1470+
{
1471+
"name": "mixed_case",
1472+
"in": "query",
1473+
"required": true,
1474+
"schema": {
1475+
"type": "string"
1476+
}
1477+
},
1478+
{
1479+
"name": "mixedCase",
1480+
"in": "query",
1481+
"required": true,
1482+
"schema": {
1483+
"type": "string"
1484+
}
1485+
}
1486+
],
1487+
"responses": {
1488+
"200": {
1489+
"description": "Successful response",
1490+
"content": {
1491+
"application/json": {
1492+
"schema": {
1493+
"type": "object",
1494+
"properties": {
1495+
"mixed_case": {
1496+
"type": "string"
1497+
},
1498+
"mixedCase": {
1499+
"type": "string"
1500+
}
1501+
}
1502+
}
1503+
}
1504+
}
1505+
}
1506+
}
1507+
}
1508+
},
14651509
"/parameter-references/{path_param}": {
14661510
"get": {
14671511
"tags": [
@@ -2580,6 +2624,53 @@
25802624
"ModelWithBackslashInDescription": {
25812625
"type": "object",
25822626
"description": "Description with special character: \\"
2627+
},
2628+
"ModelWithDiscriminatedUnion": {
2629+
"type": "object",
2630+
"properties": {
2631+
"discriminated_union": {
2632+
"allOf": [
2633+
{
2634+
"$ref": "#/components/schemas/ADiscriminatedUnion"
2635+
}
2636+
],
2637+
"nullable": true
2638+
}
2639+
}
2640+
},
2641+
"ADiscriminatedUnion": {
2642+
"type": "object",
2643+
"discriminator": {
2644+
"propertyName": "modelType",
2645+
"mapping": {
2646+
"type1": "#/components/schemas/ADiscriminatedUnionType1",
2647+
"type2": "#/components/schemas/ADiscriminatedUnionType2"
2648+
}
2649+
},
2650+
"oneOf": [
2651+
{
2652+
"$ref": "#/components/schemas/ADiscriminatedUnionType1"
2653+
},
2654+
{
2655+
"$ref": "#/components/schemas/ADiscriminatedUnionType2"
2656+
}
2657+
]
2658+
},
2659+
"ADiscriminatedUnionType1": {
2660+
"type": "object",
2661+
"properties": {
2662+
"modelType": {
2663+
"type": "string"
2664+
}
2665+
}
2666+
},
2667+
"ADiscriminatedUnionType2": {
2668+
"type": "object",
2669+
"properties": {
2670+
"modelType": {
2671+
"type": "string"
2672+
}
2673+
}
25832674
}
25842675
},
25852676
"parameters": {

end_to_end_tests/baseline_openapi_3.1.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,50 @@ info:
14561456
}
14571457
}
14581458
},
1459+
"/naming/mixed-case": {
1460+
"get": {
1461+
"tags": [ "naming" ],
1462+
"operationId": "mixed_case",
1463+
"parameters": [
1464+
{
1465+
"name": "mixed_case",
1466+
"in": "query",
1467+
"required": true,
1468+
"schema": {
1469+
"type": "string"
1470+
}
1471+
},
1472+
{
1473+
"name": "mixedCase",
1474+
"in": "query",
1475+
"required": true,
1476+
"schema": {
1477+
"type": "string"
1478+
}
1479+
}
1480+
],
1481+
"responses": {
1482+
"200": {
1483+
"description": "Successful response",
1484+
"content": {
1485+
"application/json": {
1486+
"schema": {
1487+
"type": "object",
1488+
"properties": {
1489+
"mixed_case": {
1490+
"type": "string"
1491+
},
1492+
"mixedCase": {
1493+
"type": "string"
1494+
}
1495+
}
1496+
}
1497+
}
1498+
}
1499+
}
1500+
}
1501+
}
1502+
},
14591503
"/parameter-references/{path_param}": {
14601504
"get": {
14611505
"tags": [
@@ -2592,6 +2636,55 @@ info:
25922636
"ModelWithBackslashInDescription": {
25932637
"type": "object",
25942638
"description": "Description with special character: \\"
2639+
},
2640+
"ModelWithDiscriminatedUnion": {
2641+
"type": "object",
2642+
"properties": {
2643+
"discriminated_union": {
2644+
"oneOf": [
2645+
{
2646+
"$ref": "#/components/schemas/ADiscriminatedUnion"
2647+
},
2648+
{
2649+
"type": "null"
2650+
}
2651+
],
2652+
}
2653+
}
2654+
},
2655+
"ADiscriminatedUnion": {
2656+
"type": "object",
2657+
"discriminator": {
2658+
"propertyName": "modelType",
2659+
"mapping": {
2660+
"type1": "#/components/schemas/ADiscriminatedUnionType1",
2661+
"type2": "#/components/schemas/ADiscriminatedUnionType2"
2662+
}
2663+
},
2664+
"oneOf": [
2665+
{
2666+
"$ref": "#/components/schemas/ADiscriminatedUnionType1"
2667+
},
2668+
{
2669+
"$ref": "#/components/schemas/ADiscriminatedUnionType2"
2670+
}
2671+
]
2672+
},
2673+
"ADiscriminatedUnionType1": {
2674+
"type": "object",
2675+
"properties": {
2676+
"modelType": {
2677+
"type": "string"
2678+
}
2679+
}
2680+
},
2681+
"ADiscriminatedUnionType2": {
2682+
"type": "object",
2683+
"properties": {
2684+
"modelType": {
2685+
"type": "string"
2686+
}
2687+
}
25952688
}
25962689
},
25972690
"parameters": {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33
import types
44

5-
from . import post_naming_property_conflict_with_import
5+
from . import mixed_case, post_naming_property_conflict_with_import
66

77

88
class NamingEndpoints:
99
@classmethod
1010
def post_naming_property_conflict_with_import(cls) -> types.ModuleType:
1111
return post_naming_property_conflict_with_import
12+
13+
@classmethod
14+
def mixed_case(cls) -> types.ModuleType:
15+
return mixed_case

0 commit comments

Comments
 (0)