Error generating Swagger server (Python Flask) from Swagger editor
2016-05-24 06:24
489 查看
1down votefavorite | http://stackoverflow.com/questions/36416679/error-generating-swagger-server-python-flask-from-swagger-editor I've used the Swagger Editor to manually generate my Swagger spec file and generated the files for a Python Flask server. Following the README I installed connexion, but when I run python app.pyI get the error: ValueError: need more than 1 value to unpack. Any ideas? Full stack trace below: No handlers could be found for logger "connexion.api" Traceback (most recent call last): File "app.py", line 5, in <module> app.add_api('swagger.yaml') File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/app.py", line 144, in add_api debug=self.debug) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/api.py", line 127, in __init__ self.add_paths() File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/api.py", line 198, in add_paths six.reraise(*sys.exc_info()) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/api.py", line 187, in add_paths self.add_operation(method, path, endpoint, path_parameters) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/api.py", line 160, in add_operation resolver=self.resolver) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/operation.py", line 168, in __init__ resolution = resolver.resolve(self) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/resolver.py", line 50, in resolve return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/resolver.py", line 71, in resolve_function_from_operation_id return self.function_resolver(operation_id) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/connexion/utils.py", line 106, in get_function_from_name module_name, attr_path1 = module_name.rsplit('.', 1) ValueError: need more than 1 value to unpack python flask swagger
| ||||
|
1 Answer 1
active oldest votesup vote3down voteaccepted | I ran into this as well. From what I see, the generated code from Swagger seems to assume you're using Python 3. While connexion supports both Python 2.7 & 3.4+, it does need a __init__.pyfile in the generated python-flask-server/base directory as well as inside the controllers/subdirectory to work for Python 2.7 (Implicit Namespace Packages were introduced in Python 3.3). If you create those 2 empty files after generating the code, things should work. If the Swagger generator wants to support Python 2.7 (since connexion allows for it), it would just need to provide those files as well. |
相关文章推荐
- python 磁力链接搜索器
- win7 64 安装mysql-python:_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
- python爬虫:案例三:去哪儿酒店价格信息
- 关于 Python Iterator 协议的一点思考
- Python 正则表达式里面 贪婪模式和非贪婪模式的区别
- 决策树原理-python实现
- 1.python的第一步
- Python实现二叉树结构与进行二叉树遍历的方法详解
- 用Python写一个无界面的2048小游戏
- Python的for和break循环结构中使用else语句的技巧
- python自动化运维的相关模块
- Python核心编程-第六章
- Python读取PDF内容
- Python使用zipfile库压缩打包文件实例
- python操作mysql-通讯录
- python 练习 8
- python 练习 7
- python 练习 6
- python 练习 5
- python 练习 4