swagger-api / swagger-api/swagger-codegen
Error generating python code for server
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Hello everybody I have faced the problem while generating python Flask server from Swagger Editor online.
I have downloaded this project and opened it in Visual Studio Code .
Here are all mine requirements:
flask==1.1.1
werkzeug==0.16.0
connexion==2.6.0
That are installed into virtual inviroments folder. I do not understand what is inccorrect, because I have followed all instaructions given in README file.
(.venv) C:\Users\Fedor\Documents\python\projects\python-flask-server-generated\python-flask-server>python -m swagger_server
Traceback (most recent call last):
File "C:\Users\Fedor\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Fedor\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Fedor\Documents\python\projects\python-flask-server-generated\python-flask-server\swagger_server\__main__.py", line 5, in <module>
from swagger_server import encoder
File "C:\Users\Fedor\Documents\python\projects\python-flask-server-generated\python-flask-server\swagger_server\encoder.py", line 4, in <module>
from swagger_server.models.base_model_ import Model
File "C:\Users\Fedor\Documents\python\projects\python-flask-server-generated\python-flask-server\swagger_server\models\__init__.py", line 9, in <module>
from swagger_server.models.pet import Pet
File "C:\Users\Fedor\Documents\python\projects\python-flask-server-generated\python-flask-server\swagger_server\models\pet.py", line 12, in <module>
class Pet(Model):
File "C:\Users\Fedor\Documents\python\projects\python-flask-server-generated\python-flask-server\swagger_server\models\pet.py", line 18, in Pet
def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): # noqa: E501
NameError: name 'Category' is not defined
The project structure is given with a screenschot
What have I done not correct? Why do I see this traceback?
Thanks in advance!
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 by following the README in the downloaded Python Flask server project and reproduce the traceback with python -m swagger_server. Inspect swagger_server/models/pet.py, swagger_server/models/__init__.py, and the generated model files around the undefined Category reference. Done means the generated server starts without this NameError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100