-
Notifications
You must be signed in to change notification settings - Fork 270
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
overrides on django filters only work the first request #950
Comments
Hi @wgiddens good catch, but this all happens for a reason.
Sure, this could all be written differently but we usually start from a scratch schema that gets refined along the way. I think the actual issue is that we break isolation by not making a copy here. All other branches start from a fresh (and isolated) schema object.
Note however that by decorating a raw schema, you essentially throw away the inferred type information. Raw schema means: "Get out of the way, I know what I am doing." In that case we just do some trimming, nothing more. |
That makes sense. Copying the annotation here fixes it. I opened a PR here: #951 |
added a test case that checks for the modification. thanks @wgiddens for the PR |
Describe the bug
When using extend_schema_field to override the description on a django_filter filter, the overridden description only works for the first request.
To Reproduce
Create a custom filter and override description.
For example:
View the schema multiple times. It will show overridden description only on the 1st request.
Expected behavior
It should always use the overridden schema.
I think this is because the description gets popped from the schema object in resolve_filter_field. Unless there is a use case I'm not thinking of, that should probably be a schema.get().
It looks like enum and readOnly get popped as well. They probably have the same issue.
The text was updated successfully, but these errors were encountered: