mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +00:00
fix: add pokemon_encounters
200
response
This commit is contained in:
parent
8198fae37a
commit
5c9a73d795
3 changed files with 213 additions and 8 deletions
98
openapi.yml
98
openapi.yml
|
@ -2518,7 +2518,103 @@ paths:
|
|||
- {}
|
||||
responses:
|
||||
'200':
|
||||
description: No response body
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- location_area
|
||||
- version_details
|
||||
properties:
|
||||
location_area:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: cerulean-city-area
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/location-area/281/
|
||||
version_details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- encounter_details
|
||||
- max_chance
|
||||
- version
|
||||
properties:
|
||||
encounter_details:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- chance
|
||||
- condition_values
|
||||
- max_level
|
||||
- method
|
||||
- min_level
|
||||
properties:
|
||||
chance:
|
||||
type: number
|
||||
example: 100
|
||||
condition_values:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: story-progress-beat-red
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/encounter-condition-value/55/
|
||||
max_level:
|
||||
type: number
|
||||
example: 10
|
||||
method:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: gift
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/encounter-method/18/
|
||||
min_level:
|
||||
type: number
|
||||
example: 10
|
||||
max_chance:
|
||||
type: number
|
||||
example: 100
|
||||
version:
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
- url
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: red
|
||||
url:
|
||||
type: string
|
||||
format: uri
|
||||
example: https://pokeapi.co/api/v2/version/1/
|
||||
description: ''
|
||||
/api/v2/region/:
|
||||
get:
|
||||
operationId: region_list
|
||||
|
|
|
@ -837,12 +837,123 @@ class VersionGroupResource(PokeapiCommonViewset):
|
|||
description='Handles Pokemon Encounters as a sub-resource.',
|
||||
summary='Get pokemon encounter',
|
||||
tags=[ 'encounters' ],
|
||||
responses={'200': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'location_area', 'version_details' ],
|
||||
'properties': {
|
||||
'location_area': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'cerulean-city-area'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/location-area/281/'
|
||||
}
|
||||
}
|
||||
},
|
||||
'version_details': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [
|
||||
'encounter_details',
|
||||
'max_chance',
|
||||
'version'
|
||||
],
|
||||
'properties': {
|
||||
'encounter_details': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [
|
||||
'chance',
|
||||
'condition_values',
|
||||
'max_level',
|
||||
'method',
|
||||
'min_level'
|
||||
],
|
||||
'properties': {
|
||||
'chance': {
|
||||
'type': 'number',
|
||||
'example': 100
|
||||
},
|
||||
'condition_values': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'story-progress-beat-red'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/encounter-condition-value/55/'
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'max_level': {
|
||||
'type': 'number',
|
||||
'example': 10
|
||||
},
|
||||
'method': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'gift'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/encounter-method/18/'
|
||||
}
|
||||
}
|
||||
},
|
||||
'min_level': {
|
||||
'type': 'number',
|
||||
'example': 10
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'max_chance': {
|
||||
'type': 'number',
|
||||
'example': 100
|
||||
},
|
||||
'version': {
|
||||
'type': 'object',
|
||||
'required': [ 'name', 'url' ],
|
||||
'properties': {
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'example': 'red'
|
||||
},
|
||||
'url': {
|
||||
'type': 'string',
|
||||
'format': 'uri',
|
||||
'example': 'https://pokeapi.co/api/v2/version/1/'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}}
|
||||
)
|
||||
@extend_schema_view(
|
||||
list=extend_schema(
|
||||
summary='List pokemon encounters',
|
||||
)
|
||||
)
|
||||
class PokemonEncounterView(APIView):
|
||||
|
||||
def get(self, request, pokemon_id):
|
||||
|
|
|
@ -926,8 +926,6 @@ class EncounterDetailSerializer(serializers.ModelSerializer):
|
|||
"condition_values",
|
||||
)
|
||||
|
||||
# no response at the moment
|
||||
@extend_schema_field(OpenApiTypes.OBJECT)
|
||||
def get_encounter_conditions(self, obj):
|
||||
condition_values = EncounterConditionValueMap.objects.filter(encounter=obj)
|
||||
data = EncounterConditionValueMapSerializer(
|
||||
|
|
Loading…
Reference in a new issue