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

Minor schema validation error: doesn't complain about invalid default for null and file types

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

还没有人认领这个 Issue。

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

描述

Describe the bug
NoneProperty.build and FileProperty.build do have logic to detect if a default other than None was provided for a null property, or if any default was provided for a binary string—and we do have unit tests for those. However, in reality NoneProperty.build and FileProperty.build do not actually get called, because property_from_data just calls the initializers directly instead. Therefore if you do something like this, the default is simply ignored.

OpenAPI Spec File

components:
  schemas:
    MyModel:
      properties:
        myNullProperty:
          type: "null"
          default: "definitely not null"
        myBinaryString:
          type: string
          format: binary
          default: "???"

Desktop (please complete the following information):

  • OS: any
  • Python Version: any
  • openapi-python-client version: 0.21.6

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先跟踪 property_from_data,并将其对 initializer 的直接调用与 NoneProperty.build 和 FileProperty.build 进行比较,后者已经包含验证逻辑。运行这些 builder 的现有单元测试,然后添加测试覆盖,以表明所提供的 OpenAPI schema 中的无效默认值会被拒绝,而不是被忽略。

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

评估

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

把新 issue 发到你的邮箱

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