You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When you use the python sever generation for fastapi and declare a binary output in your OpenAPI-Spec, the generator produces invalid type hints. There is no file type in python 3 AFAIK, and if there is the import is missing.
openapi: 3.1.3info:
title: File Demo - OpenAPI 3.0version: 0.0.1servers:
- url: http://localhost:8080paths:
/coverletter/{asset_id}:
get:
summary: Download a pdfoperationId: download_pdfparameters:
- name: asset_idin: pathdescription: ID of asset to getrequired: trueschema:
type: stringresponses:
"200":
description: PDF binarycontent:
application/pdf:
schema:
type: stringformat: binary"401":
description: Authorization information is missing or invalid."404":
description: A document with the specified ID was not found.
But this might not be the right type for file. There is no file type in python (AFAIK), only a File type that is part of FastAPI, see or a FileResponsesee
If the File type from FastApi is meant here, the first letter must be upper case and it is missing the import in
Bug Report Checklist
Description
When you use the python sever generation for fastapi and declare a binary output in your OpenAPI-Spec, the generator produces invalid type hints. There is no
file
type in python 3 AFAIK, and if there is the import is missing.openapi-generator version
OpenAPI declaration file content or url
Generation Details
The code was generated with:
Steps to reproduce
Related issues/PRs
None
Suggest a fix
The python types are declared here:
openapi-generator/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java
Lines 100 to 101 in 70df117
But this might not be the right type for
file
. There is nofile
type in python (AFAIK), only aFile
type that is part of FastAPI, see or aFileResponse
seeIf the
File
type from FastApi is meant here, the first letter must be upper case and it is missing the import inopenapi-generator/modules/openapi-generator/src/main/resources/python-fastapi/api.mustache
Lines 10 to 15 in 70df117
Screenshot of the error:

The text was updated successfully, but these errors were encountered: