fix: add nature schema_field definitions

This commit is contained in:
indyandie 2024-03-03 01:03:33 -06:00
parent 3c9d27bf46
commit 928507938a
No known key found for this signature in database
GPG key ID: FDB83C1AED3933E1
2 changed files with 50 additions and 3 deletions

View file

@ -5531,8 +5531,29 @@ components:
$ref: '#/components/schemas/BerrySummary'
readOnly: true
pokeathlon_stat_changes:
type: object
additionalProperties: {}
type: array
items:
type: object
required:
- max_change
- pokeathlon_stat
properties:
max_change:
type: number
example: 1
pokeathlon_stat:
type: object
required:
- name
- url
properties:
name:
type: string
example: power
url:
type: string
format: uri
example: https://pokeapi.co/api/v2/pokeathlon-stat/2/
readOnly: true
move_battle_style_preferences:
type: array

View file

@ -2025,7 +2025,33 @@ class NatureDetailSerializer(serializers.ModelSerializer):
"names",
)
@extend_schema_field(OpenApiTypes.OBJECT)
@extend_schema_field(field={'type': 'array',
'items': {
'type': 'object',
'required': [ 'max_change', 'pokeathlon_stat' ],
'properties': {
'max_change': {
'type': 'number',
'example': 1
},
'pokeathlon_stat': {
'type': 'object',
'required': [ 'name', 'url' ],
'properties': {
'name': {
'type': 'string',
'example': 'power'
},
'url': {
'type': 'string',
'format': 'uri',
'example': 'https://pokeapi.co/api/v2/pokeathlon-stat/2/'
}
}
}
}
}
})
def get_pokeathlon_stats(self, obj):
pokeathlon_stat_objects = NaturePokeathlonStat.objects.filter(nature=obj)
pokeathlon_stats = NaturePokeathlonStatSerializer(