diff --git a/openapi.yml b/openapi.yml index ebc0cbb1..dc0df517 100644 --- a/openapi.yml +++ b/openapi.yml @@ -5204,8 +5204,20 @@ components: $ref: '#/components/schemas/MoveLearnMethodDescription' readOnly: true version_groups: - type: object - additionalProperties: {} + type: array + items: + type: object + required: + - name + - url + properties: + name: + type: string + example: red-blue + url: + type: string + format: uri + example: https://pokeapi.co/api/v2/version-group/1/ readOnly: true required: - descriptions diff --git a/pokemon_v2/serializers.py b/pokemon_v2/serializers.py index 5f1e8d58..edc1fff7 100644 --- a/pokemon_v2/serializers.py +++ b/pokemon_v2/serializers.py @@ -3952,7 +3952,28 @@ class MoveLearnMethodDetailSerializer(serializers.ModelSerializer): model = MoveLearnMethod fields = ("id", "name", "names", "descriptions", "version_groups") - @extend_schema_field(OpenApiTypes.OBJECT) + # "version_groups": [ + # { + # "name": "red-blue", + # "url": "https://pokeapi.co/api/v2/version-group/1/" + # }, + @extend_schema_field(field={'type': 'array', + 'items': { + 'type': 'object', + 'required': [ 'name', 'url' ], + 'properties': { + 'name': { + 'type': 'string', + 'example': 'red-blue' + }, + 'url': { + 'type': 'string', + 'format': 'uri', + 'example': 'https://pokeapi.co/api/v2/version-group/1/' + } + } + } + }) def get_method_version_groups(self, obj): version_group_objects = VersionGroupMoveLearnMethod.objects.filter( move_learn_method=obj