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

Bugfix (API V2): Added missing Serializers to CreatureSerializer #603

Conversation

calumbell
Copy link
Contributor

This PR fixes a bug where the environments and languages fields of the /creatures endpoint could not be filtered via query parameter.

eg. v2/creature/?environment__fields=name and v2/creature/?languages__field=name had no effect on the API response.

This was because the LanguageSerializer and EnvironmentSerializer were not included on the CreatureSerializer, so these fields did not correctly inherit the logic defined in the GameContentSerializer abstract class for managing filtering nested fields.

Now, the query parameters for a creature of the form /?fields=languages,environments&languages__fields=name&environments__fields=name will generate a response of the form:

{
    "languages": [
        {
            "name": "Common"
        },
        {
            "name": "Draconic"
        },
        ...
     ],
    "environments": [
        {
            "name": "Arctic or Tundra"
        },
        {
            "name": "Caves"
        },
        ...
    ],

@calumbell
Copy link
Contributor Author

Ah looks like, this is failing tests. To be expected, as it does change what is returned by the API when no parameters are provided. Should be a simply a case of updating the tests to match the new schema

@calumbell
Copy link
Contributor Author

(Tested updated and passing, good to go!)

@augustjohnson augustjohnson merged commit a218d78 into open5e:staging Nov 13, 2024
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.

2 participants