mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +00:00
fix: add version-group
schema_field definitions
This commit is contained in:
parent
807fbc1869
commit
8198fae37a
2 changed files with 98 additions and 9 deletions
48
openapi.yml
48
openapi.yml
|
@ -8682,16 +8682,52 @@ components:
|
|||
generation:
|
||||
$ref: '#/components/schemas/GenerationSummary'
|
||||
move_learn_methods:
|
||||
type: object
|
||||
additionalProperties: {}
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: level-up
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/move-learn-method/1/
|
||||
readOnly: true
|
||||
pokedexes:
|
||||
type: object
|
||||
additionalProperties: {}
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: kanto
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/pokedex/2/
|
||||
readOnly: true
|
||||
regions:
|
||||
type: object
|
||||
additionalProperties: {}
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: kanto
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/region/1/
|
||||
readOnly: true
|
||||
versions:
|
||||
type: array
|
||||
|
|
|
@ -5991,7 +5991,24 @@ class VersionGroupDetailSerializer(serializers.ModelSerializer):
|
|||
"versions",
|
||||
)
|
||||
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
@extend_schema_field(field={
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'kanto'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/region/1/'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
def get_version_group_regions(self, obj):
|
||||
vg_regions = VersionGroupRegion.objects.filter(version_group=obj)
|
||||
data = VersionGroupRegionSerializer(
|
||||
|
@ -6004,7 +6021,26 @@ class VersionGroupDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
return regions
|
||||
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
# "name": "level-up",
|
||||
# "url": "https://pokeapi.co/api/v2/move-learn-method/1/"
|
||||
@extend_schema_field(field={
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'level-up'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/move-learn-method/1/'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
def get_learn_methods(self, obj):
|
||||
learn_method_objects = VersionGroupMoveLearnMethod.objects.filter(
|
||||
version_group=obj
|
||||
|
@ -6019,7 +6055,24 @@ class VersionGroupDetailSerializer(serializers.ModelSerializer):
|
|||
|
||||
return methods
|
||||
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
@extend_schema_field(field={
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'kanto'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/pokedex/2/'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
def get_version_groups_pokedexes(self, obj):
|
||||
dex_group_objects = PokedexVersionGroup.objects.filter(version_group=obj)
|
||||
dex_groups = PokedexVersionGroupSerializer(
|
||||
|
|
Loading…
Reference in a new issue