fix: add move_learn_method schema_field definitions

This commit is contained in:
indyandie 2024-03-03 14:46:20 -06:00
parent 3bb60381f0
commit fe9c1fa98d
No known key found for this signature in database
GPG key ID: FDB83C1AED3933E1
2 changed files with 36 additions and 3 deletions

View file

@ -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

View file

@ -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