PokeAPI/ditto

Add support for named resources

tdmalone opened this issue · 15 comments

From PokeAPI/pokeapi#369.

Ditto needs to produce named files - eg /pokemon/bulbasaur - in the transform step.

Does it duplicate the files? One for bulbasaur and one for 1?

We could try symlinks

Is there a timeline for this going live?

Side note: There are a few other named resource end points that were not covered for example
https://pokeapi.co/api/v2/move/{name}/
https://pokeapi.co/api/v2/pokemon-species/{name}
etc.

This hasn't gone live yet; we've hit a snag with Netlify. We have a workaround in place just for pokemon, but this will work for all endpoints once it's live.

@sargunv If we can build api-data, we can get it live on DO - ie that’s not affected by the Netlify build timeout. But we can’t rebuild api-data because of the issue affecting the Django install, right?

The named resources aren't dependent on rebuilding API data. They're generated from the api-data we already have using ditto transform --base-url="$BASE_URL" --src-dir='data' --dest-dir='_dist' from the api-data repo.

But yeah, there are issues with rebuilding api-data atm.

As this particular feature has been added to ditto, the downstream parts of this issue are now located:

Released v0.6.1

I think this fix is making eg. pokemon/ditto/ work, but is preventing it from serving requests without the trailing slash, eg. pokemon/ditto or pokemon/1

Are you having this problem with all resources, or just those particular URLs?

Ach, I mis-diagnosed this - it actually returns a 301, which confuses things that don't follow redirects (including the example search at https://pokeapi.co/, which helpfully reports "TypeError: Network request failed")

Yeah, that the API explorer requires trailing slashes is a known problem (the cryptic error messages don't help either). The website just got a rewrite in anticipation of the move to static hosting, so there are still a few kinks to work out.

Ideally, requests both with and without a trailing slash will be accepted and return 200 responses, and that's the way it will be once the move to static hosting is complete.