Fix: Expose endpoint with version/hash#1434
Fix: Expose endpoint with version/hash#1434gabrnavarro wants to merge 1 commit intoPokeAPI:masterfrom
Conversation
|
Hi! Thanks for the quick implementation! I'd like to discuss here even with other people the exposed properties. Do @jemarq04 @PraaneshSelvaraj have any opinions on this? |
|
Does this get translated through Ditto to the production environment? |
|
Yes, it would be an endpoint listed here: https://pokeapi.co/api/v2/ |
| def test_meta_api(self): | ||
| response = self.client.get("{}/meta".format(API_V2)) | ||
| self.assertEqual(response.status_code, status.HTTP_200_OK) | ||
| self.assertIn("deploy_date", response.data) |
There was a problem hiding this comment.
These tests will always pass, because it is looking for the key, which is always there.
I think this would be great to provide in the API! I did a local test build and I don't actually see the 'meta' endpoint at the local version of https://pokeapi.co/api/v2/. Is this expected with how Ditto works? I'm not familiar with how this tool is used in the framework. Navigating to |
|
I expected it to be listed on the root endpoint. We need it to be listed there for Ditto Probably a change is needed for pokemon_v2/urls.py |
What changed
Added a new
GET /api/v2/metaendpoint that returns metadata about the currently deployed version of the API:{ "deploy_date": "2024-01-15T12:34:56+00:00", "hash": "abc123def456...", "tag": "2.7.0" }deploy_date: ISO 8601 timestamp of the latest git commit (null if unavailable)hash: Full git commit hash (null if unavailable)tag: Git tag pointing at HEAD, if any (null if not tagged or unavailable)Why
Exposes version/hash information useful for cache invalidation — clients can check the
hashfield to determine whether to flush their cache after a new deploy.Fixes #1432
Testing
test_meta_apitopokemon_v2/tests.pyverifying the endpoint returns HTTP 200 with the expecteddeploy_date,hash, andtagfields.test_gender_api,test_language_api,test_meta_api) — all pass.