Skip to content

Conversation

@lee-elenbaas
Copy link
Contributor

No description provided.

@dbanty
Copy link
Collaborator

dbanty commented Jul 23, 2023

I don't understand what this does or why it's useful 😓. Is there something that this enables you to do via custom templates?

@lee-elenbaas
Copy link
Contributor Author

@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
there are endpoints that their success is not 200 - but instead 301 or 302
while other endpoints 301 is a failed response

so this allows me to mark the correct behavior for the endpoints that behave differently than the default

@dbanty
Copy link
Collaborator

dbanty commented Jan 5, 2024

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!

@dbanty dbanty added this pull request to the merge queue Jan 5, 2024
Merged via the queue into openapi-generators:main with commit 90a1ddf Jan 5, 2024
dbanty added a commit that referenced this pull request Jan 15, 2024
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 <github-actions@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants