Repository navigation
Fix attribution source enum colliding with reading list enum in OpenAPI schema - #655
Merged
Merged
Conversation
The ENUM_NAME_OVERRIDES entry added for resource attribution sources used the name AttributionSourceEnum. drf-spectacular already generates that name for the reading list's attribution_source field, so the override took it over. The reading list's writable attribution_source ended up referencing the Marvel/Wikipedia/GCD/DC choices instead of CBRO/CMRO/etc., and spectacular gave no warning. Rename the resource attribution enum to ResourceAttributionSourceEnum and fix the reading list enum to its original name so a future override can't silently take it. Extend the schema test to check both enums.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#654 added an
ENUM_NAME_OVERRIDESentry that named the resource attributionsourcechoicesAttributionSourceEnum. drf-spectacular already generates that name for the reading list'sattribution_sourcefield, so the override took it over. In the generated schema, the reading list's writableattribution_sourcefield now lists the Marvel / Wikipedia / Grand Comics Database / DC choices instead of CBRO / CMRO / CBH / etc. Spectacular gives no warning, because the override hides the collision. Mokkari caught it while being updated for the new API fields.Changes
ResourceAttributionSourceEnum.AttributionSourceEnum) with an explicit override, so a future override can't silently take it.test_schema_names_attribution_source_enumto check that both enums exist with their own choices. The old test only checked the attribution enum, so it passed even though the schema was wrong.Impact
Schema only. API responses are unchanged. The reading list enum is back to its pre-#654 name and values. The resource attribution enum has a new component name, which only matters to clients generated from the schema since #654 merged.