rustemon icon indicating copy to clipboard operation
rustemon copied to clipboard

Can't get all evolution chains due to missing field

Open AnActualEmerald opened this issue 1 year ago • 3 comments

The generated function for evolution_chain::get_all_entries expects to get a list of NamedApiResource<EvolutionChain>, but PokeAPI doesn't give a name for evolution chains:

curl https://pokeapi.co/api/v2/evolution-chain?limit=3 | jq

outputs

{
  "count": 541,
  "next": "https://pokeapi.co/api/v2/evolution-chain?offset=3&limit=3",
  "previous": null,
  "results": [
    {
      "url": "https://pokeapi.co/api/v2/evolution-chain/1/"
    },
    {
      "url": "https://pokeapi.co/api/v2/evolution-chain/2/"
    },
    {
      "url": "https://pokeapi.co/api/v2/evolution-chain/3/"
    },
  ]
}

Which causes reqwest to return a decode error for the missing name field

AnActualEmerald avatar Apr 02 '24 00:04 AnActualEmerald

Hello @AnActualEmerald ! Thanks for using rustemon and for reaching out ! Good catch !

I reproduced the error. I also looked at PokeAPI docs and the evolution_chain::get_all_entries function do respect the specs under Resource Lists/Pagination at https://pokeapi.co/docs/v2.

So if I'm not missing something here, it looks like there a delta between PokeAPI format and the actual data send.

I think PokeAPI should resolve this first and then rustemon should be modified if needed.

Do you want to handle this or you rather prefer me to contact them ? Please let me know

mlemesle avatar Apr 02 '24 09:04 mlemesle

I opened an issue there as well, https://github.com/PokeAPI/pokeapi/issues/1063. I have a fix in my fork that adds a branch to the endpoint macro for unnamed resources, assuming that his is intentional just not documented, https://github.com/AnActualEmerald/rustemon/commit/876859c9d224a3f6e21624aea81b805c98d84bb7. Depending on what pokeapi's response is there may be other endpoints that would affected by this too.

AnActualEmerald avatar Apr 02 '24 19:04 AnActualEmerald

I agree! Let's wait for their answer and we'll proceed accordingly.

In the meantime, thanks again for your work and patience!

mlemesle avatar Apr 02 '24 22:04 mlemesle

@AnActualEmerald Hey there !

Is it still an issue ?

mlemesle avatar Dec 11 '24 15:12 mlemesle

Yes, and it looks like the PokeAPI docs have been updated with the corrected info (as discussed in https://github.com/PokeAPI/pokeapi/issues/1063) https://pokeapi.co/docs/v2#resource-listspagination-section.

AnActualEmerald avatar Dec 12 '24 02:12 AnActualEmerald

Oh cool ! Do you want to contribute and make the changes yourself or you rather prefer me to do it ?

mlemesle avatar Dec 12 '24 14:12 mlemesle