问题标签 [connexion]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1880 浏览

python - 如何使用烧瓶运行连接/烧瓶应用程序?

我们有一个现有的烧瓶应用程序,我们想转移到连接。应用程序是否仍然可以使用烧瓶运行,例如“烧瓶运行”。我们在希望继续使用的 cli 中使用“管理”插件。

我们尝试修改应用工厂方法以使用连接烧瓶应用。使用“运行烧瓶”我们得到一个错误,“应用程序”不是烧瓶应用程序。

还尝试创建这两个应用程序。

使用第一种方法运行 'flask run' 会给出一个错误,即 'app' 不是有效的烧瓶应用程序:RuntimeError: app is not a valid flask.app.Flask 应用程序实例

第二种方法似乎没有生成 UI,这并不奇怪,因为 connexion_app 没有运行。

这甚至可能吗?

0 投票
1 回答
260 浏览

python - 尝试使用 aiohttp-cors 为异步路由设置 connexion.AioHttpApp() 失败

我正在尝试转换使用connexionCORS 能够处理异步路由的现有 Web 应用程序。

(直接从事件循环中调用异步函数工作正常)

连接配置如下:

我只是希望 connexion 在异步模式下运行并能够处理异步路由。

当前的 cors 设置返回

“AioHttpApp”对象没有属性“路由器”

0 投票
1 回答
2858 浏览

json - 在 swaggerUI 中使 requestBody 字段可选

为我的烧瓶 python 项目使用以下版本:

connexion==2.3.0 swagger-ui-bundle==0.0.5 OAS 3.0

我想让所有 requestBody 字段都是可选的,现在我已经定义了如下所示的 json 并且我假设如果您没有在 requestBody 中提供必填字段,那么它应该被视为 false 并且如果我没有提供任何值在这些字段的招摇 UI 中,它不应该使用带有 -d 选项的字段生成 curl 请求。

但它确实生成没有值,如下所示:

curl -X POST " http://xx.yy.zz.a:8080/api/v1/calls/5454/custom-event " -H "accept: / " -H "Content-Type: application/x-www -form-urlencoded" -d "event1=&event2=&document="

我不确定如何使 requestBody 字段/元素在 swagger UI 中显示为可选

0 投票
1 回答
191 浏览

json - 在 OAS 3.0 中,作为 url 编码表单数据的 requestBody 中的 anyOf 不会在 swagger UI 中呈现明显的输入

connexion==2.3.0 swagger-ui-bundle==0.0.5 OAS 3.0

开放式 APi 规范中的“anyOf”不会向 requestBody 中的字段/元素呈现任何有用的输入。生成的 curl 请求使用了错误的 key:values

当我想从 swagger UI 中尝试 curl 命令时生成的 Curl 请求:

curl -X POST " http://xx.yy.zz.ee:8080/api/v1/calls/54544/js " -H "accept: / " -H "Content-Type: application/x-www-form -urlencoded" -d "0='&1=I&2=n&3=t&4=e&5=r&6=r&7=u&8=p&9=t&10='&11=%3D&12='&13=t&14=r&15=u&16=e&17='"

Swagger UI 示例截图:

0 投票
1 回答
4175 浏览

python - 对象数组大摇大摆的问题:验证错误:无不是“数组”类型

我正在尝试使用 connexion 制作 REST API,但无法弄清楚如何设置使用对象数组的 get 操作。最后,我需要一次获取有关多个项目的信息。

使用 Python 3.7、connexion-2.3.0 和 Swagger 以及 OpenAPI 规范版本。2.

我的招摇文件:

我的带有测试功能的 Python 文件:

尝试通过 Swagger UI 传递 JSON:

我的测试功能的预期响应:

实际反应:

0 投票
0 回答
1416 浏览

python - 用于字符串类型的请求正文中的 url 编码表单数据的 swagger UI 生成带有 ascii 值的 curl 命令

为我的烧瓶 python 项目使用以下版本: connexion==2.3.0 swagger-ui-bundle==0.0.5 OAS 3.0

这是我的 swagger.json

根据 OAS 3.0 规范,我已将编码属性设置为 allowReserved=true,

但我仍然看到在 swagger UI -> tryOut 选项中显示的 curl 命令输出,其中括号和双引号的 ascii 值如下:

实际结果是这样的: curl -X POST " http://v-jay-hvp-install:8080/api/hvp/v1/calls/fdfd/js " -H "accept: / " -H "Content-Type:应用程序/x-www-form-urlencoded" -d "应用程序=sss&document=%7B%22Property1%22%3A%22value1%22%7D"

预期结果是这样的: curl -X POST " http://v-jay-hvp-install:8080/api/hvp/v1/calls/fdfd/js " -H "accept: / " -H "Content-Type: application/x-www-form-urlencoded" -d "application=sss&document={"Property1":"value1"}

我在 swagger.json 中缺少什么

0 投票
0 回答
352 浏览

python-3.x - Python web App 多处理/多线程连接[swagger-ui]

connexion[swagger-ui]在我的my_app.py文件中使用 , 定义了一个 Python Web 应用程序:

现在,我有另一个 python 文件,test.py它总是调用 API 来获取一些数据:

两者都在同一个项目上。现在,我正在尝试一些方法作为multiprocessing package,让这些任务在不相互阻塞的情况下运行,但没有成功。有什么建议或最佳方法来实现这一点吗?

0 投票
1 回答
1307 浏览

python-3.x - 将 Prometheus 与 Connexion 一起使用 - ValueError:CollectorRegistry 中的时间序列重复

使用 python3.6/3.7 将 prometheus 与 connexion 一起使用时,我收到以下错误消息:

ValueError:CollectorRegistry 中的重复时间序列:{'app_request_processing_seconds_sum'、'app_request_processing_seconds_count'、'app_request_processing_seconds_created'、'app_request_processing_seconds'}

有一个 swagger.yaml 等同于: https ://github.com/hjacobs/connexion-example-redis-kubernetes/blob/master/swagger.yaml

任何帮助都会很棒

0 投票
0 回答
628 浏览

python - 使用 OpenAPI 接收多部分消息中的文件

我有一个在 Flask/Connexion 上运行的 API。API 是用 OpenAPI 3 为 Swagger 编写的。我通过 multipart/form-data 将数据发送到端点,除了上传的文件之外,一切都通过了。我将从分享我的 OpenAPI YAML 文件开始。对于我引用的有关如何指定架构的文档的文件。

submit.submit操作调用以下 Python 代码:

Python 打印的是:

所以不存在“内容”。但我知道数据正在发送,因为我在浏览器中将其捕获到出站:

我应该对 Connexion 进行额外的调试,它会告诉我是否/为什么它没有传递“内容”文件?

0 投票
0 回答
838 浏览

python - How to generate complex ORM code and REST API with swagger-codegen?

swagger-editor is with codegen tool built in, so I can generate server side code with it. I try the pet store example, and it works. Then my next try is to think about data persistence. I google around, and I often use Python/Java, so I focus on this 2 languages.

First I would like to try python.

In the swagger-codegen tool, it depends on flask/connexion/flask-swagg and so on, so I think connexion is a good start for me. However when I read the generated code, I found that swagger-codegen inherits swagger data Model itself, and I can use connexion with SQLAlchemy to implement db ORM. For example Connexion-Example. Also I found SAFRS a good place to go, with this I can easily expose all the DB models as REST API, so that I don't need to create duplicate ORM code myself. So I try to find some suggestions, which can help me out, because now I am stuck.

I want to create a API specification file(yaml or json in swagger-editor), and also the DB model. Then generate server side code, including DB model with SQLAlchemy, with all the DB CRUD ops as REST API. My first thinking is to modify swagger template in swagger-codegen, to use SAFRS or connexion. But I would like to discuss here to get some advise on how you manage to do this kind of work?

Thanks.

Andes