fix: add pal-park-area schema_field definitions

This commit is contained in:
indyandie 2024-03-03 01:45:46 -06:00
parent e7ea8b2e8c
commit ef97bc6a45
No known key found for this signature in database
GPG key ID: FDB83C1AED3933E1
2 changed files with 81 additions and 5 deletions

View file

@ -5058,8 +5058,29 @@ components:
$ref: '#/components/schemas/MoveChange'
readOnly: true
stat_changes:
type: object
additionalProperties: {}
type: array
items:
type: object
required:
- change
- stat
properties:
change:
type: number
example: 2
stat:
type: object
required:
- name
- url
properties:
name:
type: string
example: attack
url:
type: string
format: uri
example: https://pokeapi.co/api/v2/stat/1/
readOnly: true
super_contest_effect:
$ref: '#/components/schemas/SuperContestEffectSummary'
@ -6575,8 +6596,33 @@ components:
$ref: '#/components/schemas/PalParkAreaName'
readOnly: true
pokemon_encounters:
type: object
additionalProperties: {}
type: array
items:
type: object
required:
- base_score
- pokemon-species
- rate
properties:
base_score:
type: number
example: 50
pokemon-species:
type: object
required:
- name
- url
properties:
name:
type: string
example: bulbasaur
url:
type: string
format: uri
example: https://pokeapi.co/api/v2/pokemon-species/1/
rate:
type: number
example: 30
readOnly: true
required:
- id

View file

@ -3613,7 +3613,37 @@ class PalParkAreaDetailSerializer(serializers.ModelSerializer):
model = PalParkArea
fields = ("id", "name", "names", "pokemon_encounters")
@extend_schema_field(OpenApiTypes.OBJECT)
@extend_schema_field(field={'type': 'array',
'items': {
'type': 'object',
'required': [ 'base_score', 'pokemon-species', 'rate' ],
'properties': {
'base_score': {
'type': 'number',
'example': 50
},
'pokemon-species': {
'type': 'object',
'required': [ 'name', 'url' ],
'properties': {
'name': {
'type': 'string',
'example': 'bulbasaur'
},
'url': {
'type': 'string',
'format': 'uri',
'example': 'https://pokeapi.co/api/v2/pokemon-species/1/'
}
}
},
'rate': {
'type': 'number',
'example': 30
},
}
}
})
def get_encounters(self, obj):
pal_park_objects = PalPark.objects.filter(pal_park_area=obj)
parks = PalParkSerializer(