Skip to content

Commit e9c8eeb

Browse files
committed
Merge branch 'main' into fix/oai-schema-validation-false-positives
# Conflicts: # openapi_python_client/schema/openapi_schema_pydantic/components.py # openapi_python_client/schema/openapi_schema_pydantic/contact.py # openapi_python_client/schema/openapi_schema_pydantic/discriminator.py # openapi_python_client/schema/openapi_schema_pydantic/encoding.py # openapi_python_client/schema/openapi_schema_pydantic/example.py # openapi_python_client/schema/openapi_schema_pydantic/external_documentation.py # openapi_python_client/schema/openapi_schema_pydantic/header.py # openapi_python_client/schema/openapi_schema_pydantic/info.py # openapi_python_client/schema/openapi_schema_pydantic/license.py # openapi_python_client/schema/openapi_schema_pydantic/link.py # openapi_python_client/schema/openapi_schema_pydantic/media_type.py # openapi_python_client/schema/openapi_schema_pydantic/oauth_flow.py # openapi_python_client/schema/openapi_schema_pydantic/oauth_flows.py # openapi_python_client/schema/openapi_schema_pydantic/open_api.py # openapi_python_client/schema/openapi_schema_pydantic/operation.py # openapi_python_client/schema/openapi_schema_pydantic/parameter.py # openapi_python_client/schema/openapi_schema_pydantic/path_item.py # openapi_python_client/schema/openapi_schema_pydantic/reference.py # openapi_python_client/schema/openapi_schema_pydantic/request_body.py # openapi_python_client/schema/openapi_schema_pydantic/response.py # openapi_python_client/schema/openapi_schema_pydantic/schema.py # openapi_python_client/schema/openapi_schema_pydantic/security_scheme.py # openapi_python_client/schema/openapi_schema_pydantic/server.py # openapi_python_client/schema/openapi_schema_pydantic/server_variable.py # openapi_python_client/schema/openapi_schema_pydantic/tag.py # openapi_python_client/schema/openapi_schema_pydantic/xml.py
2 parents e58f790 + 821dac8 commit e9c8eeb

File tree

196 files changed

+9383
-3775
lines changed

Some content is hidden

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

196 files changed

+9383
-3775
lines changed

.github/check_for_changes.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import subprocess
2+
3+
output = subprocess.run(["git", "status", "--porcelain"], capture_output=True, check=True).stdout
4+
5+
if output == b"":
6+
# No changes
7+
exit(0)
8+
9+
print(output)
10+
exit(1)

.github/renovate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": [
3-
"config:base"
3+
"config:base",
4+
":semanticCommitTypeAll(chore)"
45
]
56
}

.github/workflows/checks.yml

Lines changed: 117 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,127 @@ name: Run Checks
22

33
on:
44
push:
5-
branches: ["**"]
5+
branches: [ "main" ]
66
pull_request:
7-
# The branches below must be a subset of the branches above
8-
branches: [main]
9-
schedule:
10-
- cron: '0 23 * * 2'
7+
branches: [ "main" ]
118

129
jobs:
1310
test:
14-
runs-on: ubuntu-latest
1511
strategy:
1612
matrix:
17-
python: [ 3.6, 3.7, 3.8, 3.9 ]
13+
python: [ "3.7", "3.8", "3.9", "3.10" ]
14+
os: [ ubuntu-latest, macos-latest, windows-latest ]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python }}
22+
23+
- name: Get Python Version
24+
id: get_python_version
25+
run: echo "::set-output name=python_version::$(python --version)"
26+
27+
- name: Cache dependencies
28+
uses: actions/cache@v2
29+
with:
30+
path: .venv
31+
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
34+
- name: Install Poetry
35+
run: pip install poetry
36+
37+
- name: Create Virtual Environment
38+
run: python -m venv .venv
39+
40+
- name: Upgrade pip
41+
run: poetry run python -m pip install --upgrade pip
42+
43+
- name: Install Dependencies
44+
run: poetry install
45+
46+
- name: Run Black
47+
run: poetry run black . --check
48+
49+
- name: Run isort
50+
run: poetry run isort . --check
51+
52+
- name: Run flake8
53+
run: poetry run flake8 openapi_python_client
54+
55+
- name: Run safety
56+
run: poetry export -f requirements.txt | poetry run safety check --bare --stdin
57+
58+
- name: Run mypy
59+
run: poetry run mypy --show-error-codes openapi_python_client
60+
61+
- name: Run pylint
62+
run: poetry run pylint openapi_python_client
63+
64+
- name: Run pytest
65+
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
66+
env:
67+
TASKIPY: true
68+
69+
- name: Generate coverage report
70+
shell: bash
71+
run: poetry run coverage xml
72+
73+
- uses: codecov/codecov-action@v2
74+
with:
75+
files: ./coverage.xml
76+
77+
integration:
78+
name: Integration Tests
79+
runs-on: ubuntu-latest
80+
services:
81+
openapi-test-server:
82+
image: ghcr.io/openapi-generators/openapi-test-server:0.0.1
83+
ports:
84+
- "3000:3000"
1885
steps:
19-
- uses: actions/checkout@v2
20-
- name: Set up Python
21-
uses: actions/setup-python@v2
22-
with:
23-
python-version: ${{ matrix.python }}
24-
- name: Cache dependencies
25-
uses: actions/cache@v2
26-
with:
27-
path: .venv
28-
key: ${{ runner.os }}-${{ matrix.python }}-dependencies-${{ hashFiles('**/poetry.lock') }}
29-
restore-keys: |
30-
${{ runner.os }}-${{ matrix.python }}-dependencies-
31-
- name: Install dependencies
32-
uses: triaxtec/github-actions/python/install-and-configure-poetry@main
33-
- name: Run Checks
34-
uses: triaxtec/github-actions/python/run-checks@main
35-
with:
36-
module: openapi_python_client
37-
38-
- name: End to End Tests
39-
run: poetry run pytest --cov=openapi_python_client end_to_end_tests
40-
41-
- name: Generate E2E Coverage
42-
run: poetry run coverage xml -o e2e-coverage.xml
43-
44-
- uses: codecov/codecov-action@v1
45-
with:
46-
files: ./coverage.xml,./e2e-coverage.xml
86+
- uses: actions/checkout@v2
87+
- name: Set up Python
88+
uses: actions/setup-python@v2
89+
with:
90+
python-version: "3.10"
91+
- name: Get Python Version
92+
id: get_python_version
93+
run: echo "::set-output name=python_version::$(python --version)"
94+
- name: Cache dependencies
95+
uses: actions/cache@v2
96+
with:
97+
path: .venv
98+
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies-${{ hashFiles('**/poetry.lock') }}
99+
restore-keys: |
100+
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-dependencies
101+
- name: Install dependencies
102+
run: |
103+
pip install poetry
104+
python -m venv .venv
105+
poetry run python -m pip install --upgrade pip
106+
poetry install
107+
- name: Regenerate Integration Client
108+
run: |
109+
poetry run openapi-python-client update --url http://localhost:3000/openapi.json --config integration-tests-config.yaml
110+
- name: Check for any file changes
111+
run: python .github/check_for_changes.py
112+
- name: Cache Generated Client Dependencies
113+
uses: actions/cache@v2
114+
with:
115+
path: integration-tests/.venv
116+
key: ${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies-${{ hashFiles('**/poetry.lock') }}
117+
restore-keys: |
118+
${{ runner.os }}-${{ steps.get_python_version.outputs.python_version }}-integration-dependencies
119+
- name: Install Integration Dependencies
120+
run: |
121+
cd integration-tests
122+
python -m venv .venv
123+
poetry run python -m pip install --upgrade pip
124+
poetry install
125+
- name: Run Tests
126+
run: |
127+
cd integration-tests
128+
poetry run pytest

CHANGELOG.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,127 @@ 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+
16+
## 0.10.8
17+
18+
### Features
19+
20+
- New and improved docstrings in generated functions and classes [#503, #505, #551]. Thanks @rtaycher!
21+
- Support httpx 0.21.\* (#537)
22+
23+
### Fixes
24+
25+
- Basic types as JSON bodies and responses [#487 & #550]. Thanks @Gelbpunkt!
26+
- Relative paths to config files [#538 & #544]. Thanks to @motybz, @MalteBecker, & @abhinav-cashify!
27+
28+
## 0.10.7
29+
30+
### Fixes
31+
32+
- SSL verify argument to async clients [#533 & #510]. Thanks @fsvenson and @mvaught02!
33+
- Remove unused CHANGELOG from generated setup.py [#529]. Thanks @johnthagen!
34+
35+
## 0.10.6
36+
37+
### Features
38+
39+
- Improve error messages related to invalid arrays and circular or recursive references [#519].
40+
- Add httpx 0.20.\* support [#514].
41+
42+
### Fixes
43+
44+
- Use isort "black" profile in generated clients [#523]. Thanks @johnthagen!
45+
- setup.py should generate importable packages named <project>\_client [#492, #520, #521]. Thanks @tedo-benchling & @Leem0sh!
46+
- Allow None in enum properties [#504, #512, #516]. Thanks @juspence!
47+
- properly support JSON OpenAPI documents and config files [#488, #509, #515]. Thanks @tardyp and @Gelbpunkt!
48+
49+
## 0.10.5
50+
51+
### Features
52+
53+
- Add verify_ssl option to generated Client, allowing users to ignore or customize ssl verification (#497). Thanks @rtaycher!
54+
55+
### Fixes
56+
57+
- Properly label a path template issue as a warning (#494). Thanks @chamini2!
58+
- Don't allow mixed types in enums.
59+
- Don't crash when a null is in an enum (#500). Thanks @juspence!
60+
61+
## 0.10.4
62+
63+
### Features
64+
65+
- Allow customization of post-generation steps with the `post_hooks` config option.
66+
- Allow httpx 0.19.\* (#481)
67+
68+
### Fixes
69+
70+
- Don't crash the generator when one of the post-generation hooks is missing [fixes #479]. Thanks @chamini2 and @karolzlot!
71+
72+
## 0.10.3
73+
74+
### Features
75+
76+
- Expose `python_identifier` and `class_name` functions to custom templates to rename with the same behavior as the parser.
77+
78+
### Fixes
79+
80+
- Treat `true` and `false` as reserved words.
81+
- Prevent generating Python files named the same as reserved / key words.
82+
- Properly replace reserved words in class and module names [#475, #476]. Thanks @mtovts!
83+
84+
## 0.10.2
85+
86+
### Features
87+
88+
- Allow path parameters to be positional args [#429 & #464]. Thanks @tsotnikov!
89+
- Include both `UNSET` and `None` static types for nullable or optional query params [#421, #380, #462]. Thanks @forest-benchling!
90+
- Allow allOf enums to be subsets of one another or their base types [#379, #423, #461]. Thanks @forest-benchling! (#461)
91+
92+
### Fixes
93+
94+
- Parameters from `PathItem` can now be overriden in `Operation` [#458 & #457]. Thanks @mtovts!
95+
96+
## 0.10.1
97+
98+
### Fixes
99+
100+
- Support multipart requests with type: array [#452 & #451]. Thanks @csymeonides-mf @slamora and @dpursehouse
101+
102+
## 0.10.0
103+
104+
### Breaking Changes
105+
106+
- Normalize generated module names to allow more tags [#428 & #448]. Thanks @iamnoah & @forest-benchling!
107+
- Improved the consistency of snake_cased identifiers which will cause some to be renamed [#413 & #432]. Thanks @ramnes!
108+
- Allow more types in multipart payloads by defaulting to JSON for complex types [#372]. Thanks @csymeonides-mf!
109+
110+
### Features
111+
112+
- Allow custom templates for API and endpoint `__init__` files. [#442] Thanks @p1-ra!
113+
114+
### Fixes
115+
116+
- Treat empty schemas like `Any` instead of `None`. Thanks @forest-benchling! [#417 & #445]
117+
118+
## 0.9.2
119+
120+
### Features
121+
122+
- Add option to fail on warning [#427]. Thanks @forest-benchling!
123+
124+
### Fixes
125+
126+
- Properly strip out `UNSET` values from form data [#430]. Thanks @p1-ra!
127+
7128
## 0.9.1
8129

9130
### Features

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
5555
## Enforcement
5656

5757
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at danthony@triaxtec.com. All
58+
reported by [contacting the project maintainer Dylan Anthony](https://github.com/dbanty/). All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
6161
obligated to maintain confidentiality with regard to the reporter of an incident.

CONTRIBUTING.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@
1616
## Writing Code
1717

1818
1. Write some code and make sure it's covered by unit tests. All unit tests are in the `tests` directory and the file structure should mirror the structure of the source code in the `openapi_python_client` directory.
19+
20+
### Run Checks and Tests
21+
1922
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.
20-
3. If you're writing a new feature, try to add it to the end to end test.
23+
24+
### Rework end-to-end tests
25+
26+
3. If you're writing a new feature, try to add it to the end-to-end test.
2127
1. If adding support for a new OpenAPI feature, add it somewhere in `end_to_end_tests/openapi.json`
22-
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.
2329
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.
24-
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+
2532

2633
## Creating a Pull Request
2734

0 commit comments

Comments
 (0)