MCPcopy Index your code
hub / github.com/PokeAPI/pokeapi / NatureDetailSerializer

Class NatureDetailSerializer

pokemon_v2/serializers.py:2026–2092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2024
2025
2026class NatureDetailSerializer(serializers.ModelSerializer):
2027 names = NatureNameSerializer(many=True, read_only=True, source="naturename")
2028 decreased_stat = StatSummarySerializer()
2029 increased_stat = StatSummarySerializer()
2030 likes_flavor = BerryFlavorSummarySerializer()
2031 hates_flavor = BerryFlavorSummarySerializer()
2032 berries = BerrySummarySerializer(many=True, read_only=True, source="berry")
2033 pokeathlon_stat_changes = serializers.SerializerMethodField("get_pokeathlon_stats")
2034 move_battle_style_preferences = NatureBattleStylePreferenceSerializer(
2035 many=True, read_only=True, source="naturebattlestylepreference"
2036 )
2037
2038 class Meta:
2039 model = Nature
2040 fields = (
2041 "id",
2042 "name",
2043 "decreased_stat",
2044 "increased_stat",
2045 "likes_flavor",
2046 "hates_flavor",
2047 "berries",
2048 "pokeathlon_stat_changes",
2049 "move_battle_style_preferences",
2050 "names",
2051 )
2052
2053 @extend_schema_field(
2054 field={
2055 "type": "array",
2056 "items": {
2057 "type": "object",
2058 "required": ["max_change", "pokeathlon_stat"],
2059 "properties": {
2060 "max_change": {
2061 "type": "integer",
2062 "format": "int32",
2063 "examples": [1],
2064 },
2065 "pokeathlon_stat": {
2066 "type": "object",
2067 "required": ["name", "url"],
2068 "properties": {
2069 "name": {"type": "string", "examples": ["power"]},
2070 "url": {
2071 "type": "string",
2072 "format": "uri",
2073 "examples": [
2074 "https://pokeapi.co/api/v2/pokeathlon-stat/2/"
2075 ],
2076 },
2077 },
2078 },
2079 },
2080 },
2081 }
2082 )
2083 def get_pokeathlon_stats(self, obj):

Callers

nothing calls this directly

Tested by

no test coverage detected