Skip to content

Commit 6a2c525

Browse files
committed
Merge branch 'main' into issue1120-nullable-enum
2 parents f741fec + a61a741 commit 6a2c525

Some content is hidden

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

66 files changed

+2381
-729
lines changed

Diff for: .github/workflows/checks.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- uses: actions/[email protected]
1919
- name: Set up Python
20-
uses: actions/setup-python@v5.1.1
20+
uses: actions/setup-python@v5.2.0
2121
with:
2222
python-version: ${{ matrix.python }}
2323

@@ -64,12 +64,13 @@ jobs:
6464
if: matrix.os == 'ubuntu-latest'
6565

6666
- name: Store coverage report
67-
uses: actions/upload-artifact@v4.3.6
67+
uses: actions/upload-artifact@v4.4.0
6868
if: matrix.os == 'ubuntu-latest'
6969
with:
7070
name: coverage-${{ matrix.python }}
7171
path: .coverage.${{ matrix.python }}
7272
if-no-files-found: error
73+
include-hidden-files: true
7374

7475
coverage:
7576
name: Combine & check coverage
@@ -106,7 +107,7 @@ jobs:
106107
.venv/bin/python -m coverage report --fail-under=100
107108
108109
- name: Upload HTML report if check failed.
109-
uses: actions/upload-artifact@v4.3.6
110+
uses: actions/upload-artifact@v4.4.0
110111
with:
111112
name: html-report
112113
path: htmlcov
@@ -128,7 +129,7 @@ jobs:
128129
steps:
129130
- uses: actions/[email protected]
130131
- name: Set up Python
131-
uses: actions/setup-python@v5.1.1
132+
uses: actions/setup-python@v5.2.0
132133
with:
133134
python-version: "3.8"
134135
- name: Get Python Version

Diff for: .github/workflows/preview_release_pr.yml

-24
This file was deleted.

Diff for: .github/workflows/release-dry-run.yml

-17
This file was deleted.

Diff for: .github/workflows/release.yml

+4-13
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,17 @@ on:
77

88
jobs:
99
release:
10-
if: github.head_ref == 'release' && github.event.pull_request.merged == true
10+
if: github.head_ref == 'knope/release' && github.event.pull_request.merged == true
1111
runs-on: ubuntu-latest
1212
permissions:
1313
id-token: write
1414
steps:
1515
- uses: actions/[email protected]
16-
with:
17-
fetch-depth: 0
18-
token: ${{ secrets.PAT }}
19-
- name: Install Knope
20-
uses: knope-dev/[email protected]
21-
with:
22-
version: 0.17.0
2316
- name: Install Hatchling
2417
run: pip install --upgrade hatchling
2518
- name: Build
2619
run: hatchling build
2720
- name: Push to PyPI
28-
uses: pypa/[email protected]
29-
- name: Create GitHub Release
30-
run: knope release
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.PAT }}
21+
uses: pypa/[email protected]
22+
with:
23+
attestations: true

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ dmypy.json
2424
# JetBrains
2525
.idea/
2626

27+
# Visual Studio Code
28+
.vscode/
29+
2730
test-reports/
2831

2932
/coverage.xml

Diff for: CHANGELOG.md

+55
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,61 @@ 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.21.5 (2024-09-07)
17+
18+
### Features
19+
20+
#### Improved property-merging behavior with `allOf`
21+
22+
When using `allOf` to extend a base object type, `openapi-python-client` is now able to handle some kinds of modifications to an existing property that would have previously caused an error:
23+
24+
- Overriding attributes that do not affect validation, such as `description`.
25+
- Combining properties that this generator ignores, like `maxLength` or `pattern`.
26+
- Combining a generic numeric type with `int` (resulting in `int`).
27+
- Adding a `format` to a string.
28+
- Combining `any` with a specific type (resulting in that specific type).
29+
- Adding or overriding a `default`
30+
31+
> [!NOTE]
32+
> `pattern` and `max_length` are no longer fields on `StringProperty`, which may impact custom templates.
33+
34+
This also fixes a bug where properties of inline objects (as opposed to references) were not using the
35+
merge logic, but were simply overwriting previous definitions of the same property.
36+
37+
### Fixes
38+
39+
- Allow default values for properties of `Any` type
40+
41+
#### Produce valid code for an object that has no properties at all
42+
43+
Fixed by PR #1109. Thanks @eli-bl!
44+
45+
## 0.21.4 (2024-08-25)
46+
47+
### Fixes
48+
49+
#### Allow OpenAPI 3.1-style `exclusiveMinimum` and `exclusiveMaximum`
50+
51+
Fixed by PR #1092. Thanks @mikkelam!
52+
53+
#### Add missing `cast` import when using `const`
54+
55+
Fixed by PR #1072. Thanks @dorcohe!
56+
57+
#### Correctly resolve references to a type that is itself just a single allOf reference
58+
59+
PR #1103 fixed issue #1091. Thanks @eli-bl!
60+
61+
#### Support `const` booleans and floats
62+
63+
Fixed in PR #1086. Thanks @flxdot!
64+
65+
## 0.21.3 (2024-08-18)
66+
67+
### Features
68+
69+
- update Ruff to >=0.2,<0.7 (#1097)
70+
1671
## 0.21.2 (2024-07-20)
1772

1873
### Features

Diff for: end_to_end_tests/baseline_openapi_3.0.json

+120-1
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,16 @@
596596
"name": "float_prop",
597597
"in": "query"
598598
},
599+
{
600+
"required": true,
601+
"schema": {
602+
"title": "Float with int default",
603+
"type": "number",
604+
"default": 3
605+
},
606+
"name": "float_with_int",
607+
"in": "query"
608+
},
599609
{
600610
"required": true,
601611
"schema": {
@@ -1629,6 +1639,33 @@
16291639
}
16301640
}
16311641
}
1642+
},
1643+
"/models/allof": {
1644+
"get": {
1645+
"responses": {
1646+
"200": {
1647+
"description": "OK",
1648+
"content": {
1649+
"application/json": {
1650+
"schema": {
1651+
"type": "object",
1652+
"properties": {
1653+
"aliased": {
1654+
"$ref": "#/components/schemas/Aliased"
1655+
},
1656+
"extended": {
1657+
"$ref": "#/components/schemas/Extended"
1658+
},
1659+
"model": {
1660+
"$ref": "#/components/schemas/AModel"
1661+
}
1662+
}
1663+
}
1664+
}
1665+
}
1666+
}
1667+
}
1668+
}
16321669
}
16331670
},
16341671
"components": {
@@ -1647,6 +1684,28 @@
16471684
"an_required_field"
16481685
]
16491686
},
1687+
"Aliased": {
1688+
"allOf": [
1689+
{
1690+
"$ref": "#/components/schemas/AModel"
1691+
}
1692+
]
1693+
},
1694+
"Extended": {
1695+
"allOf": [
1696+
{
1697+
"$ref": "#/components/schemas/Aliased"
1698+
},
1699+
{
1700+
"type": "object",
1701+
"properties": {
1702+
"fromExtended": {
1703+
"type": "string"
1704+
}
1705+
}
1706+
}
1707+
]
1708+
},
16501709
"AModel": {
16511710
"title": "AModel",
16521711
"required": [
@@ -1666,7 +1725,9 @@
16661725
],
16671726
"type": "object",
16681727
"properties": {
1669-
"any_value": {},
1728+
"any_value": {
1729+
"default": "default"
1730+
},
16701731
"an_enum_value": {
16711732
"$ref": "#/components/schemas/AnEnum"
16721733
},
@@ -2119,6 +2180,59 @@
21192180
"additionalProperties": {}
21202181
}
21212182
},
2183+
"ModelWithMergedProperties": {
2184+
"title": "ModelWithMergedProperties",
2185+
"allOf": [
2186+
{
2187+
"type": "object",
2188+
"properties": {
2189+
"simpleString": {
2190+
"type": "string",
2191+
"description": "base simpleString description"
2192+
},
2193+
"stringToEnum": {
2194+
"type": "string",
2195+
"default": "a"
2196+
},
2197+
"stringToDate": {
2198+
"type": "string"
2199+
},
2200+
"numberToInt": {
2201+
"type": "number"
2202+
},
2203+
"anyToString": {}
2204+
}
2205+
},
2206+
{
2207+
"type": "object",
2208+
"properties": {
2209+
"simpleString": {
2210+
"type": "string",
2211+
"description": "extended simpleString description",
2212+
"default": "new default"
2213+
},
2214+
"stringToEnum": {
2215+
"type": "string",
2216+
"enum": [
2217+
"a",
2218+
"b"
2219+
]
2220+
},
2221+
"stringToDate": {
2222+
"type": "string",
2223+
"format": "date"
2224+
},
2225+
"numberToInt": {
2226+
"type": "integer"
2227+
},
2228+
"anyToString": {
2229+
"type": "string",
2230+
"default": "x"
2231+
}
2232+
}
2233+
}
2234+
]
2235+
},
21222236
"ModelWithPrimitiveAdditionalProperties": {
21232237
"title": "ModelWithPrimitiveAdditionalProperties",
21242238
"type": "object",
@@ -2186,6 +2300,11 @@
21862300
}
21872301
]
21882302
},
2303+
"ModelWithNoProperties": {
2304+
"type": "object",
2305+
"properties": {},
2306+
"additionalProperties": false
2307+
},
21892308
"AllOfSubModel": {
21902309
"title": "AllOfSubModel",
21912310
"type": "object",

0 commit comments

Comments
 (0)