- Report bugs via issues
- Request features via discussions
- Contribute code via pull request
A bug is one of:
- You get an exception when running the generator
- The generated code is invalid or incorrect
- An error message is unclear or incorrect
- Something which used to work no longer works, except:
- Intentional breaking changes, which are documented in the changelog
- Breaking changes to unstable features, like custom templates
If your issue does not fall under one of the above, it is not a bug; check out "Requesting a feature.
A bug report must have an OpenAPI document that can be used to replicate the bug. Reports without a valid document will be closed.
A feature is usually:
- An improvement to the way the generated code works
- A feature of the generator itself which makes its use easier (e.g., a new config option)
- Support for part of the OpenAPI spec; this generate does not yet support every OpenAPI feature, these missing features are not bugs.
To request a feature:
- Search through discussions to see if the feature you want has already been requested. If it has:
- Upvote it with the little arrow on the original post. This enables code contributors to prioritize the most-demanded features.
- Optionally leave a comment describing why you want the feature, if no existing thread already covers your use-case
- If a relevant discussion does not already exist, create a new one. If you are not requesting support for part of the OpenAPI spec, you must describe why you want the feature. What real-world use-case does it improve? For example, "raise exceptions for invalid responses" might have a description of "it's not worth the effort to check every error case by hand for the one-off scripts I'm writing".
- Make sure you have Poetry installed and up to date.
- Make sure you have a supported Python version (e.g. 3.8) installed and accessible to Poetry (e.g. with pyenv).
- Use
poetry install
in the project directory to create a virtual environment with the relevant dependencies. - Enter a
poetry shell
to make running commands easier.
- 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 theopenapi_python_client
directory.
- When in a Poetry shell (
poetry shell
) runtask 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.
- If you're writing a new feature, try to add it to the end-to-end test.
- If adding support for a new OpenAPI feature, add it somewhere in
end_to_end_tests/openapi.json
- Regenerate the "golden records" with
task regen
. This client is generated from the OpenAPI document used for end-to-end testing. - 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.
- If adding support for a new OpenAPI feature, add it somewhere in
- If you added a test above OR modified the templates: Run the end-to-end tests with
task e2e
. This will generate clients againstend_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 intask 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 runtask regen
and check the diffs. You can also usetask re
which will runregen
ande2e
in that order.
Once you've written the code and run the checks, the next step is to create a pull request against the main
branch of this repository. This repository uses conventional commits squashed on each PR, then uses Knope to auto-generate CHANGELOG.md entries for release. So the title of your PR should be in the format of a conventional commit written in plain english as it will end up in the CHANGELOG. Some example PR titles:
- feat: Support for
allOf
in OpenAPI documents (closes #123). - refactor!: Removed support for Python 3.5
- fix: Data can now be passed to multipart bodies along with files.
Once your PR is created, a series of automated checks should run. If any of them fail, try your best to fix them.
As soon as possible, your PR will be reviewed. If there are any changes requested there will likely be a bit of back and forth. Once this process is done, your changes will be merged into main and included in the next release. If you need your changes available on PyPI by a certain time, please mention it in the PR, and we'll do our best to accommodate.