OpenAPITools / OpenAPITools/openapi-generator
[BUG][PYTHON-FLASK] Generated flask server missing arguments
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
-> OpenAPI file provided by this project - Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
Generating a flask pet store server and trying to place order with the default GUI does not work. Placing an order does not seem to require a login (no lock shows in the web interface), even if it did, error 500 wouldn't be appropriate.
openapi-generator version
master 9170e103
OpenAPI declaration file content or url
Generation Details
In this repository's root:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g python-flask -o /var/tmp/flask_api_client
Steps to reproduce
- Generate the flask server with the petstore yaml, as described above.
- create, activate, populate a virtual environment (
cd /var/tmp/flask_api_client && virtualenv -p python3 venv && . venv/bin/activate && pip install -r requirements.txt) - start the server (
python3 -m openapi_server) - open the web page URL
http://localhost:8080/v2/ui/. The server shows successful requests (200) - test the endpoint
/store/orderwith the default json structure.
Expected result: do some magic!
Actual result:
{
"detail": "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.",
"status": 500,
"title": "Internal Server Error",
"type": "about:blank"
}
Server log:
[2023-09-14 16:50:30,501] ERROR in app: Exception on /v2/store/order [POST]
Traceback (most recent call last):
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/flask/app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/flask/app.py", line 1525, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
rv = self.dispatch_request()
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/connexion/decorators/decorator.py", line 68, in wrapper
response = function(request)
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/connexion/decorators/uri_parsing.py", line 149, in wrapper
response = function(request)
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/connexion/decorators/validation.py", line 196, in wrapper
response = function(request)
File "/var/tmp/flask_api_client/venv/lib/python3.10/site-packages/connexion/decorators/parameter.py", line 120, in wrapper
return function(**kwargs)
TypeError: place_order() missing 1 required positional argument: 'order'
127.0.0.1 - - [14/Sep/2023 16:50:30] "POST /v2/store/order HTTP/1.1" 500 -
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/3345
https://github.com/OpenAPITools/openapi-generator/issues/1666
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
Generate the server from the referenced petstore.yaml, then start it with python3 -m openapi_server and reproduce the POST to /v2/store/order using the default JSON structure. Start from the generated place_order() entry point and the traceback showing its missing order argument. Done means the request no longer returns HTTP 500 and produces the expected do some magic! result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100