mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-21 19:03:08 +00:00
fix: add pokeathlon_stat
schema_field definitions
This commit is contained in:
parent
da11f734db
commit
8060b59125
2 changed files with 117 additions and 2 deletions
55
openapi.yml
55
openapi.yml
|
@ -6865,7 +6865,60 @@ components:
|
|||
maxLength: 100
|
||||
affecting_natures:
|
||||
type: object
|
||||
additionalProperties: {}
|
||||
required:
|
||||
- decrease
|
||||
- increase
|
||||
properties:
|
||||
decrease:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- max_change
|
||||
- nature
|
||||
properties:
|
||||
max_change:
|
||||
type: number
|
||||
maximum: -1
|
||||
example: -1
|
||||
nature:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: hardy
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/nature/1/
|
||||
increase:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- max_change
|
||||
- nature
|
||||
properties:
|
||||
max_change:
|
||||
type: number
|
||||
minimum: 1
|
||||
example: 2
|
||||
nature:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: hardy
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/nature/1/
|
||||
readOnly: true
|
||||
names:
|
||||
type: array
|
||||
|
|
|
@ -5753,7 +5753,69 @@ class PokeathlonStatDetailSerializer(serializers.HyperlinkedModelSerializer):
|
|||
model = PokeathlonStat
|
||||
fields = ("id", "name", "affecting_natures", "names")
|
||||
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
@extend_schema_field(field={'type': 'object',
|
||||
'required': [ 'decrease', 'increase' ],
|
||||
'properties': {
|
||||
'decrease': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'max_change', 'nature' ],
|
||||
'properties': {
|
||||
'max_change': {
|
||||
'type': 'number',
|
||||
'maximum': -1,
|
||||
'example': -1
|
||||
},
|
||||
'nature': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'hardy'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/nature/1/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'increase': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'max_change', 'nature' ],
|
||||
'properties': {
|
||||
'max_change': {
|
||||
'type': 'number',
|
||||
'minimum': 1,
|
||||
'example': 2
|
||||
},
|
||||
'nature': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'hardy'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/nature/1/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
def get_natures_that_affect(self, obj):
|
||||
stat_change_objects = NaturePokeathlonStat.objects.filter(pokeathlon_stat=obj)
|
||||
stat_changes = NaturePokeathlonStatSerializer(
|
||||
|
|
Loading…
Reference in a new issue