swagger-api / swagger-api/swagger-codegen-generators

2 ModuleNotFoundErrors from newly generated python flask app on editor.swagger.io

Open
#870 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Hello. Generated a flask app based off this spec https://w3c-ccg.github.io/vc-http-api/ which I've also attached from editor.swagger.io.

Unzipped and tried to run from the command line and I got

(TrustScience) daidoji@worklaptop:~/TrustScience/UCVDCC/w3c_issuer_verifier_api$ python -m swagger_server
Traceback (most recent call last):
  File "/usr/lib64/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib64/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/daidoji/TrustScience/UCVDCC/w3c_issuer_verifier_api/swagger_server/__main__.py", line 5, in <module>
    from swagger_server import encoder
  File "/home/daidoji/TrustScience/UCVDCC/w3c_issuer_verifier_api/swagger_server/encoder.py", line 1, in <module>
    from connexion.apps.flask_app import FlaskJSONEncoder
ModuleNotFoundError: No module named 'connexion.apps'; 'connexion' is not a package
(TrustScience) daidoji@worklaptop:~/TrustScience/UCVDCC/w3c_issuer_verifier_api$ pip freeze | grep connexion
connexion==2.7.0

As you can see it can't find connexion but the module is installed.

If I try to run the docker image I get the following ModuleNotFound error for aiohttp.

(TrustScience) daidoji@worklaptop:~/TrustScience/UCVDCC/w3c_issuer_verifier_api$ docker build -t swagger_server .
Sending build context to Docker daemon  225.8kB
Step 1/9 : FROM python:3.6-alpine
 ---> 815c1103df84
Step 2/9 : RUN mkdir -p /usr/src/app
 ---> Using cache
 ---> a5c1dde011ee
Step 3/9 : WORKDIR /usr/src/app
 ---> Using cache
 ---> b209ff9a3946
Step 4/9 : COPY requirements.txt /usr/src/app/
 ---> Using cache
 ---> fb28d4e378c7
Step 5/9 : RUN pip3 install --no-cache-dir -r requirements.txt
 ---> Using cache
 ---> b80401c3389c
Step 6/9 : COPY . /usr/src/app
 ---> Using cache
 ---> 91d174e1ef74
Step 7/9 : EXPOSE 8080
 ---> Using cache
 ---> 30369ef0f4d7
Step 8/9 : ENTRYPOINT ["python3"]
 ---> Using cache
 ---> e9dbb9daf49e
Step 9/9 : CMD ["-m", "swagger_server"]
 ---> Using cache
 ---> ffecb8916be4
Successfully built ffecb8916be4
Successfully tagged swagger_server:latest
(TrustScience) daidoji@worklaptop:~/TrustScience/UCVDCC/w3c_issuer_verifier_api$ docker run -p 8080:8080 swagger_server
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/src/app/swagger_server/__main__.py", line 3, in <module>
    import connexion
  File "/usr/src/app/connexion.py", line 8, in <module>
    import aiohttp
ModuleNotFoundError: No module named 'aiohttp'

vc-http-api.yml.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing both commands, python -m swagger_server and docker run, then inspect the generated swagger_server/encoder.py, swagger_server/__main__.py, and requirements.txt. Trace the reported imports and dependency installation paths; done means the generated Flask app starts successfully both locally and in the Docker image.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, flask, python
Domain
api, backend, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.