Skip to content

Commit 2e3e739

Browse files
committed
feat: Allow customization of post-generation steps with the post_hooks config option.
1 parent 93bd834 commit 2e3e739

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,13 @@ using it (Python developers).
2929

3030
## Installation
3131

32-
I recommend you install with [pipx](https://pipxproject.github.io/pipx/) so you don't conflict with any other packages
33-
you might have: `pipx install openapi-python-client`.
32+
I recommend you install with [pipx](https://pipxproject.github.io/pipx/) so you don't conflict with any other packages you might have: `pipx install openapi-python-client --include-deps`.
3433

35-
Better yet, use `pipx run openapi-python-client <normal params / options>` to always use the latest version of the generator.
34+
> Note the `--include-deps` option which will also make `black`, `isort`, and `autoflake` available in your path so that `openapi-python-client` can use them to clean up the generated code.
3635
37-
You can install with normal pip if you want to though: `pip install openapi-python-client`
36+
**If you use `pipx run` then the post-generation hooks will not be available unless you install them manually.**
37+
38+
You can also install with normal pip: `pip install openapi-python-client`
3839

3940
Then, if you want tab completion: `openapi-python-client --install-completion`
4041

@@ -114,8 +115,7 @@ class_overrides:
114115
module_name: short_name
115116
```
116117
117-
The easiest way to find what needs to be overridden is probably to generate your client and go look at everything in the
118-
models folder.
118+
The easiest way to find what needs to be overridden is probably to generate your client and go look at everything in the models folder.
119119
120120
### project_name_override and package_name_override
121121
@@ -150,5 +150,16 @@ Example:
150150
package_version_override: 1.2.3
151151
```
152152

153+
### post_hooks
154+
155+
In the config file, there's an easy way to tell `openapi-python-client` to run additional commands after generation. Here's an example showing the default commands that will run if you don't override them in config:
156+
157+
```yaml
158+
post_hooks:
159+
- "autoflake -i -r --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports ."
160+
- "isort ."
161+
- "black ."
162+
```
163+
153164
[changelog.md]: CHANGELOG.md
154165
[poetry]: https://python-poetry.org/

0 commit comments

Comments
 (0)