mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-24 20:33:04 +00:00
fix: add pokedex
schema_field definitions
This commit is contained in:
parent
8060b59125
commit
807fbc1869
2 changed files with 81 additions and 6 deletions
41
openapi.yml
41
openapi.yml
|
@ -6986,14 +6986,47 @@ components:
|
|||
$ref: '#/components/schemas/PokedexName'
|
||||
readOnly: true
|
||||
pokemon_entries:
|
||||
type: object
|
||||
additionalProperties: {}
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- entry_number
|
||||
- pokemon_species
|
||||
properties:
|
||||
entry_number:
|
||||
type: number
|
||||
example: 1
|
||||
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/
|
||||
readOnly: true
|
||||
region:
|
||||
$ref: '#/components/schemas/RegionSummary'
|
||||
version_groups:
|
||||
type: object
|
||||
additionalProperties: {}
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: the-teal-mask
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/version-group/26/
|
||||
readOnly: true
|
||||
required:
|
||||
- descriptions
|
||||
|
|
|
@ -5874,7 +5874,33 @@ class PokedexDetailSerializer(serializers.ModelSerializer):
|
|||
"version_groups",
|
||||
)
|
||||
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
@extend_schema_field(field={'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'entry_number', 'pokemon_species' ],
|
||||
'properties': {
|
||||
'entry_number': {
|
||||
'type': 'number',
|
||||
'example': 1
|
||||
},
|
||||
'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/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
def get_pokedex_entries(self, obj):
|
||||
results = PokemonDexNumber.objects.filter(pokedex=obj).order_by(
|
||||
"pokedex_number"
|
||||
|
@ -5889,7 +5915,23 @@ class PokedexDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
return data
|
||||
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
@extend_schema_field(field={'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'the-teal-mask'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/version-group/26/'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
def get_pokedex_version_groups(self, obj):
|
||||
dex_group_objects = PokedexVersionGroup.objects.filter(pokedex=obj)
|
||||
dex_groups = PokedexVersionGroupSerializer(
|
||||
|
|
Loading…
Reference in a new issue