Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Conversion from v2 to v3 incorrectly changes additionalProperties: {} into additionalProperties: type: object

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

还没有人认领这个 Issue。

评估

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

调研方向

使用链接的 OpenAPI v2 YAML 运行提供的 swagger-codegen-cli 命令,并检查转换路径中空 additionalProperties 值的处理。完成标准是生成的 OpenAPI v3 YAML 将其保留为 additionalProperties: {} 或 additionalProperties: true,而不是分配 type: object。

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

描述

P3 pull-request-welcome Swagger-Parser
Description

I have an OpenAPI v2 yaml that is being converted to v3 by swagger-codegen-cli, and it ends up changing the behavior of my models from allowing any freeform additional properties of any type, to only allowing properties of type object.

Swagger-codegen version

3.0.61

Swagger declaration file content or url

My openapi v2 yaml includes:

  protobufAny:
    type: object
    properties:
      '@type':
        type: string
    additionalProperties: {}

This is converted by swagger-codegen-api into this yaml:

    protobufAny:
      type: object
      properties:
        '@type':
          type: string
      additionalProperties:
        type: object
Command line used for generation

swagger-codegen-cli generate -i ./openapiv2/gen/awesome.swagger.yaml -l openapi-yaml -o ./openapiv3/gen/

Steps to reproduce

See above

Related issues/PRs

N/A

Suggest a fix/enhancement

This v2 yaml should convert to additionalProperties: {} or additionalProperties: true

主要语言
Mustache
星标
17.8k
派生
6k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

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

swagger-api/swagger-codegen 的其他 Issue

查看 swagger-api/swagger-codegen 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

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