Skip to content

Commit 7516792

Browse files
committed
fix: Allow null for Region.main_generation in serializer
Some regions (e.g. Hisui) have no main_generation, so the API returns null for this field. Adding allow_null=True to the serializer field so the generated OpenAPI spec correctly marks it as nullable. Fixes #1397
1 parent 24b8ee9 commit 7516792

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

openapi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8607,7 +8607,6 @@ components:
86078607
allOf:
86088608
- $ref: '#/components/schemas/GenerationSummary'
86098609
readOnly: true
8610-
nullable: true
86118610
names:
86128611
type: array
86138612
items:
@@ -8639,6 +8638,7 @@ components:
86398638
required:
86408639
- id
86418640
- locations
8641+
- main_generation
86428642
- name
86438643
- names
86448644
- pokedexes

pokemon_v2/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class RegionDetailSerializer(serializers.ModelSerializer):
605605
locations = LocationSummarySerializer(many=True, read_only=True, source="location")
606606
version_groups = serializers.SerializerMethodField("get_region_version_groups")
607607
pokedexes = PokedexSummarySerializer(many=True, read_only=True, source="pokedex")
608-
main_generation = GenerationSummarySerializer(read_only=True, source="generation")
608+
main_generation = GenerationSummarySerializer(read_only=True, source="generation", allow_null=True)
609609

610610
class Meta:
611611
model = Region

0 commit comments

Comments
 (0)