Description
When setting the response type as type: string and format: binary, the return type is generated as file, even though the documentation states that file is no longer a data type in OpenAPI 3.0, as mentioned here: https://swagger.io/docs/specification/data-models/data-types/#file
format: byte is correctly generated as bytearray.
This becomes a problem for us as we use custom templates to set the return type of functions ({{#returnType}} -> {{.}}{{/returnType}}), which will result in file, which is not valid in python, meaning the resulting generated code does not run.
openapi-generator version
Tested with 4.1.3, as well as these snapshots:
openapi-generator-cli-4.2.1-20191104.150105-22
openapi-generator-cli-5.0.0-20191024.154544-16
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: Python binary response
version: 1.0.0
paths:
"/foo":
post:
responses:
"200":
description: "Success"
content:
application/octet-stream:
schema:
type: string
format: binary
Command line used for generation
java -jar openapi-generator-cli-4.1.3.jar generate -g python-flask -i openapi.yml
Steps to reproduce
- Copy yaml above to
openapi.yml
- Run
java -jar openapi-generator-cli-4.1.3.jar generate -g python-flask -i openapi.yml
openapi_server/controllers/default_controller.py now contains a single function, with :rtype: file
Related issues/PRs
None which I could find
Suggest a fix/enhancement
I am unfamiliar with the code base, but what I could find was that here the type file is declared as a primitive of Python, which I don't think is the case. It also maps file to file. Presumably this should map to something like str or bytearray.
Description
When setting the response type as
type: stringandformat: binary, the return type is generated asfile, even though the documentation states thatfileis no longer a data type in OpenAPI 3.0, as mentioned here: https://swagger.io/docs/specification/data-models/data-types/#fileformat: byteis correctly generated asbytearray.This becomes a problem for us as we use custom templates to set the return type of functions (
{{#returnType}} -> {{.}}{{/returnType}}), which will result infile, which is not valid in python, meaning the resulting generated code does not run.openapi-generator version
Tested with 4.1.3, as well as these snapshots:
openapi-generator-cli-4.2.1-20191104.150105-22
openapi-generator-cli-5.0.0-20191024.154544-16
OpenAPI declaration file content or url
Command line used for generation
java -jar openapi-generator-cli-4.1.3.jar generate -g python-flask -i openapi.ymlSteps to reproduce
openapi.ymljava -jar openapi-generator-cli-4.1.3.jar generate -g python-flask -i openapi.ymlopenapi_server/controllers/default_controller.pynow contains a single function, with:rtype: fileRelated issues/PRs
None which I could find
Suggest a fix/enhancement
I am unfamiliar with the code base, but what I could find was that here the type
fileis declared as a primitive of Python, which I don't think is the case. It also mapsfiletofile. Presumably this should map to something likestrorbytearray.