Error generating Swagger server (Python Flask) from Swagger editor


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.py I 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


share|improve this question

asked Apr 5 at 3:36

tw1742

117211

 

1                                                                                  

Please open a ticket via github.com/swagger-api/swagger-codegen/issues for tracking.                     – wing328                 Apr 6 at 4:45                                                                            

add a comment |                      

1 Answer                                 1

active         oldest         votes


         up 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__.py file 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.

时间: 2024-10-07 05:45:13

Error generating Swagger server (Python Flask) from Swagger editor的相关文章

利用swagger模块开发flask的api接口帮助文档

swagger官网称其为世界最流行的api工具.用过的都说好.我已经深有体会. 附上官网编辑页面.只需要拷贝相应的文件就可以实现效果 swagger在线编辑器 下面主要讲解一下在python的flask框架下,如何使用这款屌炸天的应用. 1.安装flasgger 项目地址https://github.com/rochacbruno/flasgger pip install flasgger 2.写一个简单的web例子. 以下是简写代码 #coding:utf8 import sys reload

python urllib2导出elasticsearch数据时 返回 &quot;urllib2.HTTPError: HTTP Error 500: Internal Server Error&quot;

0.业务场景 将ES中某个index的某个字段的所有数据,导出到文件中 1.ES数据导出方法简述 ES数据导出方法,我主要找到了以下几个方面,欢迎大家补充: ES官方API:snapshot and restore module The snapshot and restore module allows to create snapshots of individual indices or an entire cluster into a remote repository like sha

SQL Server 2008 installation fails There was an error generating the XML document. Error code 0x84B10001.

SQL Server 2008 installation fails There was an error generating the XML document. Error code 0x84B10001. 在windows2008R2上用Administrator用房安装mssqlserver2008 时起到最后一步安装时出现错误: 生成XML错误,Error code 0x84B10001 百度搜索了一堆网站后,都不成功,后来查询了微软官方论坛也不靠谱啊...https://social

AFNetworking+Python+Flask+pyOpenSSL构建iOS HTTPS客户端&amp;服务器端

对于HTTPS我在网上找了一堆资料看了下, 各种协议和证书已经有点晕了 最后我现有的感觉是, 在HTTP服务器上放一个证书, 在原本的HTTP访问之前客户端先检查证书是否正确 如果客户端证书检查正确, 说明对 这个服务器就是我要连接的那个server 不对, 就说明这个server是个假冒的 同样也可以在客户端放一个证书, 服务器端检查客户端传来的证书 如果服务器检查证书正确, 就说明这个客户端是我的小弟 我允许他连接进来 不对, 就说明这个客户端是"卧底", 不能放他进来 好了 不扯

项目实战_Python.利用Python+Flask编写一个高性能实时主动监控平台?

项目简介: 说明: 主要用于Redis实例集中化实时主动监控,后端采用Python+Flask实现,具体实现代码请阅读代码 项目思路: 项目结构: xmzoomeye-redis ├── app │   ├── conf │   │   ├── config.py │   │   ├── config.pyc │   │   ├── __init__.py │   │   ├── __init__.pyc │   │   └── rdsdata.db │   ├── __init__.py │ 

[Python][flask][flask-login]关于flask-login中各种API使用实例

本篇博文跟上一篇[Python][flask][flask-wtf]关于flask-wtf中API使用实例教程有莫大的关系. 简介:Flask-Login 为 Flask 提供了用户会话管理.它处理了日常的登入,登出并且长时间记住用户的会话. 直白的讲,flask-login包为用户管理了涉及到用户登录相关的缓存(Session)管理. Posted by Alima | cnblogs. 一.安装(Install) PC环境:Windows 7,Python 3.5.2. PS:此次配置环境阶

Python+Flask+MysqL的web建设技术过程

前言 本人在一学期时间实现了Python+Flask+MysqL的web建设,页面具有简单的登录注册发布文章搜索文章等功能. 这篇文章总结了我最近一段时间的学习成果:使用Flask框架搭建一个web service,并在其中加上一些简单的css,js,html等.在本文中以实际的用户模块为例.之所以写这篇文章是因为想要总结自己一学期的学习成果并且与大家分享.由于是新手如有错漏请见谅. 一.使用工具 python3.5 实现此页面所有的static文件.templates文件与py文件 二.完成基

python Flask篇(一)

MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* BLOCKS =============================================================================*/ p, blockquote, ul, ol, dl, table, pre { marg

Python Flask+Bootstrap+Jinja2 构建轻量级企业内部系统平台框架

1.最近公司运维需求,学习python flask 满足环境治理系统的开发;入门如下;    环境类型:      Python 2.7.5         获取地址:https://www.python.org/downloads/       Flask  1.0.2               pip 安装使用模快如下:           flask==1.0.2           request==1.0.2           Jinja2==2.10           Flas