-
Notifications
You must be signed in to change notification settings - Fork 259
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
False positive duplicate Serializer warning when DataclassSerializer
used both as top level Serializer and nested within another dataclass
#1288
Comments
DataclassSerializer
used both as top level and nested SerializerDataclassSerializer
used both as top level Serialized and nested within another dataclass
DataclassSerializer
used both as top level Serialized and nested within another dataclassDataclassSerializer
used both as top level Serializer and nested within another dataclass
Hi @johnthagen, I see the problem. In the beginning when we had only actual serializers this made perfect sense. If you have a different serializer class under the same name that is likely gonna be an issue. Here, The object check in the registry would need to compare the |
parametrize component registry identity #1288
Describe the bug
For code reuse, it's often useful to expose endpoints for the same data at different layers within the overall tree of data. If a
DataclassSerializer
is used for both a parent@dataclass
and a child@dataclass
a warning is printed.To Reproduce
Results in a warning when the OpenAPI spec is queried:
But, in this case, we do want to represent the same original
@dataclass
in both endpoints and have them generate the samePerson
object in the OpenAPI spec (i.e. we wouldn't want to generate two types in the API when really we mean a single type that we want clients to use interchangeably).Also, as far as I can tell, the actual OpenAPI spec is generated correctly, the warning is the only issue. But of course if this is not documented/tested behavior of
drf-spectacular
that would give me pause, thus why I wanted to report the issue.The code in question is located at
drf-spectacular/drf_spectacular/plumbing.py
Lines 756 to 761 in 2b4d5ab
Expected behavior
No warning printed.
Environment
The text was updated successfully, but these errors were encountered: