Skip to content
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

Implement dynamic field serialization on endpoints that lack it #314

Merged
merged 6 commits into from
Aug 7, 2023

Conversation

greshdev
Copy link
Contributor

@greshdev greshdev commented Aug 5, 2023

In order to fix #300, changed CharClassSerializer (as well as other serializers that do not currently support dynamic field serialization) to inherit from DynamicFieldsModelSerializer. Did so by creating an abstract base class called DynamicFieldsHyperlinkedModelSerializer (hate how long that name is, but it is technically the most correct name for it) that inherits from both DynamicFieldsModelSerializer and serializers.HyperlinkedModelSerializer and modified all serializer classes that inherited from both of those classes individually, as well as all serializers that inherited from only serializers.HyperlinkedModelSerializer to inherit from this new abstract class.

As a part of this change, also modifed DynamicFieldsModelSerializer to use the line

if 'request' in self.context:

instead of

if self.context['request']:

as the latter caused a bug when the SubraceSerializer inherited from the DFMS, as SubraceSerializer can be called from within RaceSerializer, in which case the request key does not exist, and an error is thrown.

Gresh added 6 commits August 5, 2023 12:38
inherited from both DFMS and HMS, as well as classes that only
inherited from HMS, in order to provide dynamic field serialization
on those classes.
inherited from both DFMS and HMS, as well as classes that only
inherited from HMS, in order to provide dynamic field serialization
on those classes.
Subrace is left out due to a bug in the DFHMS, which will be fixed in the following commit.
@augustjohnson augustjohnson merged commit c042ff0 into open5e:staging Aug 7, 2023
2 checks passed
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.

Bug: cannot filter return fields of /classes endpoint
2 participants