openapi-generators / openapi-generators/openapi-python-client
Quotes in Content-Type cause syntax errors
未关闭
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 2k
- 派生
- 293
- 平均合并
- 34 分钟
- 30 天内合并 PR
- 1
描述
Describe the bug
Running openapi-python-client generate --path api.yml on the input file below fails with:
Generating /tmp/example-client
Error(s) encountered while generating, client was not created
ruff failed
example_client/api/default/put_object.py:34:62: SyntaxError: Simple statements must be separated by newlines or semicolons
|
33 | _kwargs["json"] = _body
34 | headers["Content-Type"] = "application/ld+json; profile="https://www.w3.org/ns/activitystreams""
| ^
35 |
36 | _kwargs["headers"] = headers
|
[...]
Quotes in the Content-Type should be escaped so that the generated result is legal Python code.
OpenAPI Spec File
openapi: "3.0.0"
info:
version: 0.0.1
title: example
paths:
/object:
put:
requestBody:
content:
"application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"":
schema:
type: string
responses:
'200':
description: OK
Desktop (please complete the following information):
- OS: Debian 13
- Python Version: 3.12.11
- openapi-python-client version: 0.24.3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 issue 中的 OpenAPI 示例,通过 openapi-python-client generate --path api.yml 重现失败,然后追踪 Content-Type 值变成生成的 headers 赋值的位置。带引号的 Content-Type 参数能够生成合法的 Python,并且生成过程在没有报告的 Ruff 语法错误的情况下完成,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100