swagger-api / swagger-api/swagger-codegen

[python-flask] ImportError: No module named byte_array

Open
#7,255 3 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: Python
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Getting the following error while trying to run generated server stub for kubernetes apiserver with python flask:

python -m swagger_server
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/i312386/Workspace/apiserver_stub/apiserver-stub/swagger_server/__main__.py", line 5, in <module>
    from swagger_server import encoder
  File "swagger_server/encoder.py", line 4, in <module>
    from swagger_server.models.base_model_ import Model
  File "swagger_server/models/__init__.py", line 28, in <module>
    from swagger_server.models.io_k8s_apimachinery_pkg_apis_meta_v1_watch_event import IoK8sApimachineryPkgApisMetaV1WatchEvent
  File "swagger_server/models/io_k8s_apimachinery_pkg_apis_meta_v1_watch_event.py", line 9, in <module>
    from swagger_server.models.io_k8s_apimachinery_pkg_runtime_raw_extension import IoK8sApimachineryPkgRuntimeRawExtension  # noqa: F401,E501
  File "swagger_server/models/io_k8s_apimachinery_pkg_runtime_raw_extension.py", line 9, in <module>
    from swagger_server.models.byte_array import ByteArray  # noqa: F401,E501
ImportError: No module named byte_array
Swagger-codegen version

2.3.0

Swagger declaration file content or url

https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json

Command line used for generation
java -jar swagger-codegen-cli.jar generate \
-i https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json \
-l python-flask \
-o apiserver-stub \
-D supportPython2=true
Steps to reproduce
  1. Generate server stub for python-flask
  2. Follow the steps in readme to run the server
Related issues/PRs
Suggest a fix/enhancement

What I understand is there should be a file named byte_array.py under swagger_server/models/ defining ByteArray type. But there is no such a file.

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

Run the documented java -jar swagger-codegen-cli.jar generation command against the Kubernetes Swagger file, then follow the generated README steps. Inspect swagger_server/models/init.py and swagger_server/models/io_k8s_apimachinery_pkg_runtime_raw_extension.py around the missing byte_array import. Done means the generated Python Flask stub imports and starts with python -m swagger_server.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.