jikan-me / jikan-rest

The REST API for Jikan
https://docs.api.jikan.moe/
MIT License
428 stars 270 forks source link

🐛 Micro caching middleware includes omitted pagination attributes #519

Open pushrbx opened 7 months ago

pushrbx commented 7 months ago

Is there an existing issue for this?

Current Behavior

When requesting an endpoint which has pagination, e.g. /v4/top/manga?limit=8&page=1 and if you request it again, then laravel's built in pagination attributes get added.

E.g. first response is:

{
  "pagination": {...}
  "data": [...]
}

When this is not cached.

Second response is:

{
  "pagination": {...}
  "data": [...],
  "meta": {...},
  "links": {...}
}

Expected Behavior

In every response the "links" and "meta" attributes should be omitted. All the resource classes currently explicitly exclude the "meta" and "links" attributes and explicitly set "data" and "pagination" attributes for the json response. The caching middlewares should do the same.

Steps To Reproduce

  1. Enable microcaching and caching in the .env file
  2. Startup a jikan instance via containers or simply with php dev server
  3. Make a request to an endpoint with pagination and set the limit parameter to a smaller number than 25.
  4. E.g. http://localhost:8091/v4/top/anime?limit=8&page=1
  5. Refresh several times and check for the attribute names in the root json object of the response.

Environment

- Self-hosting
- Microcaching and caching enabled
- Container environment
- Using roadrunner

Anything else?

No response