Generates SyntaxError if a path parameter without a default value follows another that has a default value
还没有人认领这个 Issue。
评估
调研方向
使用报告中的最小 OpenAPI 规范重现该问题,并检查构建路径参数的生成 _get_kwargs 签名的生成器路径。通过成功生成客户端,并验证必需的路径参数可以位于具有默认值的参数之后且不会产生 Python SyntaxError,来确认修复有效。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Fails to generate client when a path parameter without a default value follows another one that has a default value.
Message:
Error(s) encountered while generating, client was not created
ruff failed
SyntaxError: Parameter without a default cannot follow a parameter with a default
OpenAPI Spec File
Motivating api: https://avaandmed.keskkonnaportaal.ee/swagger/index.html ("File of document")
Minimum example:
openapi: 3.0.0
info:
title: Minimal Repro for Parameter Order Bug
version: 1.0.0
paths:
/test/{has_default}/{no_default}:
get:
summary: Test endpoint with required path params, some with defaults
parameters:
- name: has_default
in: path
required: true
schema:
type: string
default: default_value
description: Required path param with default
- name: no_default
in: path
required: true
schema:
type: integer
description: Required path param, no default
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
result:
type: string
Desktop (please complete the following information):
- OS: Ubuntu 22.04.5 LTS
- Python Version: 3.10.12
- openapi-python-client version 0.25.2
Additional context
The generated function signature for _get_kwargs looks like this:
def _get_kwargs(
has_default: str = 'default_value',
no_default: int,
) -> dict[str, Any]:
The issue does not occur for query parameters, as the generator emits keyword-only arguments (*) for them. It only occurs for path parameters, which are emitted as positional-or-keyword arguments.
- 主要语言
- Python
- 星标
- 2k
- 派生
- 293
- 平均合并
- 34 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openapi-generators/openapi-python-client 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 3/5 1-2 天 新手友好度 72/100
openapi-generators/openapi-python-client#1451 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 52/100
-
难度 3/5 1-2 天 新手友好度 64/100
openapi-generators/openapi-python-client#1435 · 1 条评论 ·
查看 openapi-generators/openapi-python-client 的全部 Issue
相似的 Issue
-
🐛 Bug 🔔 Pending processing
难度 2/5 1-3 小时 新手友好度 84/100
jumpserver/jumpserver#17584 ·
-
link-check link-check:sphinx-theme
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 90/100
modelscope/DiffSynth-Studio#1702 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
难度 2/5 1-3 小时 新手友好度 88/100
OpenHands/extensions#626 · 1 条评论 ·