-
-
Notifications
You must be signed in to change notification settings - Fork 228
Add response data to template data #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add response data to template data #767
Conversation
I don't understand what this does or why it's useful 😓. Is there something that this enables you to do via custom templates? |
@dbanty it allows to add custom attributes to the response object - and then use those attributes inside a custom template in my case i used it to mark whether a response is a success response of a failed response so this allows me to mark the correct behavior for the endpoints that behave differently than the default |
I did some tweaking to set the data more consistently and add the appropriate type hints—I think this is still doing what you intended, though! |
This PR was created by Knope. Merging it will create a new release ### Features #### Add `--meta=pdm` option for generating PEP621 + PDM metadata The default metadata is still `--meta=poetry`, which generates a `pyproject.toml` file with Poetry-specific metadata. This change adds the `--meta=pdm` option which includes [PDM](https://pdm-project.org/latest/)-specific metadata, but also standard [PEP621](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#writing-pyproject-toml) metadata. This may be useful as a starting point for other dependency managers & build tools (like Hatch). #### Add original OpenAPI `data` attribute to `Response` object PR #767 In custom templates, you can now access a `response.data` attribute that contains the original OpenAPI definition of the response (Response Object or Reference Object). #### Include the `UP` rule for generated Ruff config This enables [pyupgrade-like improvements](https://docs.astral.sh/ruff/rules/#pyupgrade-up) which should replace some `.format()` calls with f-strings. ### Fixes #### Fix Ruff formatting for `--meta=none` PR #940 fixes issue #939. Thanks @satwell! Due to the lack of `pyproject.toml`, Ruff was not getting configured properly when `--meta=none`. As a result, it didn't clean up common generation issues like duplicate imports, which would then cause errors from linters. This is now fixed by changing the default `post_hook` to `ruff check . --fix --extend-select=I` when `--meta=none`. Using `generate --meta=none` should now be almost identical to the code generated by `update`. Co-authored-by: GitHub <[email protected]>
No description provided.