fastapi-cache icon indicating copy to clipboard operation
fastapi-cache copied to clipboard

Response model is missing in the OpenAPI spec and Swagger for @cache decorated endpoints

Open arseniiarsenii opened this issue 1 year ago • 2 comments

I've noticed, that response model is missing in the OpenAPI spec and Swagger for @cache decorated endpoints unless response_model is specified explicitly in the endpoint handler decorator, which is optional for newer versions of FastAPI. Specifying return type annotation of a handler function should be enough.

Versions (from pyproject.toml):

  • fastapi-cache2 = {git = "https://github.com/long2ice/fastapi-cache.git", extras = ["redis"]}
  • fastapi = "^0.101.0"

arseniiarsenii avatar Jan 24 '24 09:01 arseniiarsenii

Thank you for your feedback, I will try to fix it.

mkdir700 avatar Feb 02 '24 03:02 mkdir700

I also noticed that, as a workaround I added response model to route:

@router.get("/{package_name}", response_model=FetchEntitiesPartitions)

but this is code repetition..

elad-aharon avatar Jul 30 '24 13:07 elad-aharon