OpenAPITools / OpenAPITools/openapi-generator
[BUG][python-flask] file as primitive
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hi everyone,
I'm using openapi generator to generate python-flask server for a few weeks, and I have had some concerns since I start using multipart/form-data with a blob. It seems to generate this kind of things :
@property
def profile_image(self) -> file:
'file' is not defined, but yeah I never seen this kind of type in Python? Is that normal that 'file' is considered as a primitive type even in documentation?
I will update the issue if it's a real concern, I'm not sure about it.
Thanks a lot
test.yaml:
openapi: 3.1.0
info:
title: Webhook Example
version: 1.0.0
servers:
- url: /
paths:
/somes:
post:
operationId: somes_post
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/Something'
description: Somes something
responses:
"200":
description: Return a 200 status to indicate that the data was received
successfully
x-openapi-router-controller: openapi_server.controllers.default_controller
components:
schemas:
Something:
properties:
id:
format: uuid
type: string
address:
$ref: '#/components/schemas/Something_address'
profileImage:
format: binary
type: string
Something_address:
properties:
street:
title: street
type: string
city:
title: city
type: string
title: Something_address
Generation command:
openapi-generator_7.2.0.sh generate -i ./api/v1/test.yaml -g python-flask -o src/test --global-property skipFormModel=false
Run command:
python3 -m openapi_server
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied test.yaml and the python-flask generator invoked by the generation command, then inspect the generated model containing profile_image. Run the generated server with python3 -m openapi_server and determine whether the file annotation is invalid or only a documentation issue. Done means the generated Python output handles the multipart binary field correctly and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, java, openapi, python
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100