openapi-generators / openapi-generators/openapi-python-client

Using dictionary in query param

未关闭
#1,064 1 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
2k
派生
293
平均合并
34 分钟
30 天内合并 PR
1

描述

Describe the bug
I have an endpoint that takes in a dictionary as a query param:

- name: metadata
          in: query
          required: false
          style: deepObject
          explode: true
          schema:
            type: object
            additionalProperties:
              type: string

note this:

          style: deepObject
          explode: true

The openapi generator generates same code whether I have

          style: deepObject
          explode: true

present or not. I am using version 0.19.1.

The URL generated is like:

http://localhost:8080/foo?author=Joshua%20Bloch&publisher=Pearson%20Addison-Wesley

When

          style: deepObject
          explode: true

is present, the URL should be like:

http://localhost:8080/foo?metadata[author]=Joshua%20Bloch&metadata[publisher]=Pearson%20Addison-Wesley

refer: https://swagger.io/docs/specification/serialization/

OpenAPI Spec File
see above

Desktop (please complete the following information):

  • OS: [e.g. macOS 10.15.1] macOS ventura (13)
  • Python Version: [e.g. 3.8.0]
  • openapi-python-client version [e.g. 0.1.0] 0.19.0

Additional context
Add any other context about the problem here.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 openapi-python-client 0.19.0,复现提供的具有 style deepObject 和 explode true 的 OpenAPI 查询参数,然后跟踪生成请求的查询序列化过程。通过检查字典键是否在 URL 中生成 metadata[author] 和 metadata[publisher] 来确认修复,并为此行为添加或更新回归测试。

由索引模型根据 Issue 内容生成。

评估

技术栈
openapi, python
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
38/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。