-
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
User error implementing PolymorphicProxySerializer #995
Comments
You should get some rest, it's late 😆 Let's start with what is actually going wrong. I see what you are doing, but not what is going wrong exactly!? I have a few thoughts though.
When trying this out, I think I found a bug, but please elaborate first what your problem is exactly. |
Ahh forgot about that. We run |
Requirements 😂 this API was made before GQL was known to the devs - those devs was me, I didn't know about GQL. The API is a heavily nested object with tons of data per object in the detailed view - it can be stupid big so there's a 'minified' list, a normal list and a detailed view that which some users would die without in the list repsonse.
That makes sense.... lets say we were to introduce a breaking change for the next release to solve code generation what would you recommend for an overall re-architecture, new paths so that each serializer is available but also properly reportable through codegen?
With the above it would seem we would end up having duplicate paths for specific objects |
Well, the query parameter option seems cleaner from an API perspective, though you have to do more work with annotation. Having more endpoints will require almost no extra decoration, I think, because everything is covered by the default behavior. Given your setup, I would probably use
are you using generated clients (python,js)? Then use example: drf-spectacular/tests/test_polymorphic.py Line 25 in 2388a40
|
closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up. |
Hi there - apologies on reopening it but i'm hitting an error attempting to use the PolymorphicSerializer in the Here's a gist of where I am currently. And here is the error I get:
|
I think I'm starting to understand, but I expected a different error. Are you using an old version by any chance? |
I think you are using a version < 0.25.0, as there should be this error instead:
which is regression in this case. You are seeing the actual issue currently, which is a missing feature. You are using this on a If you split your definition and use |
this should fix the issue. I closed the gap where required parameters were lost in the DRF magic. |
allow implicit list expansion of PolymorphicProxySerializer #995
To answer this, the idea is that customers or consumers of our data should be able to generate client code using the schema. Well - I think this looks right, not sure how the client generated code will handle this but that'll be what I start testing. |
You neither confirmed which spectacular version you were using prior nor whether the merged fix solved the issue for you. Instead you chose to answer the the least important side-question from 3 weeks ago. Yes, the schema looks sensible with the limited context I have. Please stay on point, I'm losing interest here. |
My apologies - for the original comment I was using version |
Excellent! Thank you for clarifying. 👍 Planning to do a release soon. |
Describe the bug
Our API uses a query parameter to allow users to swap between three different serializers, this query parameter is not a field of the model or anything of the sort. We then check this in the viewset to see which serializer to use. The schema thats generated seems to only pick the default generator
LaunchSerializerCommon
. I know this is likely a user error of me simply not understanding how this works, i'm sort of lost right now and any push in any direction would be helpful.I've tried setting the @extend_schema as follows:
Expected behavior
This issue reporter RTFM'd and is still confused af, needs more coffee and a helping hand.
The text was updated successfully, but these errors were encountered: