mlemesle / rustemon

A wrapper library for PokeApi, written in Rust
MIT License
26 stars 10 forks source link

Can't get all evolution chains due to missing field #27

Open AnActualEmerald opened 4 months ago

AnActualEmerald commented 4 months ago

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

mlemesle commented 4 months ago

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

AnActualEmerald commented 4 months ago

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.

mlemesle commented 4 months ago

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

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