fastapi-code-generator icon indicating copy to clipboard operation
fastapi-code-generator copied to clipboard

Empty `response_model` gets typehinted to `Any`, which is not imported

Open UKnowWhoIm opened this issue 3 years ago • 1 comments

How to reproduce:

  • Omit the response_model in the router decorator
  • Run this on the openapi.json file
  • The result's main.py would have used Any for the empty response model and type hint without importing it.

Why does this happen?

My take is that the datamodel-code-generator you use to create schemas and resolve imports won't create this schema as its empty. Therefore its imports won't have Any thus creating an unresolved import.

UKnowWhoIm avatar Oct 16 '21 13:10 UKnowWhoIm

Is this what you meant by #114?

UKnowWhoIm avatar Oct 16 '21 13:10 UKnowWhoIm