I'm stuck with what seems like it should be a reasonably simple problem.
I have DRF application, and I use drf-spectacular to generate OpenAPI schema.
In my app, I have a class, let's call it Foo
, which is fairly deep in the hierarchy of a serialized response. The problem is that for historical reasons I need to keep calling it Foo
in the code but in the schema I need to refer to it as Bar
.
There don't appear to be any explicit ways (e.g. decorators) for that, and I haven't figured out how do "override the name" with the general-purpose pre- or post-process hooks. Any suggestions will be appreciated!
It would be more helpful to include an example of your code, from what I understand you're trying to override a serialiser's name that is used in a hierarchy of a serialized response, to do that you can decorate your
Foo
serializer with@extend_schema_serializer
. Your code will look like this: