convertTo 3.1 drops nullable on allOf schemas (follow-up to #172)
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- api
调研方向
Start at the openapiConvertVersion entry point and reproduce the issue with the provided 3.0.3 document, comparing the allOf and oneOf conversions. Done means nullable allOf schemas preserve null acceptance through an anyOf-style representation while the existing oneOf behavior remains correct.
由索引模型根据 Issue 内容生成。
描述
Converting 3.0 → 3.1 with convertTo: '3.1' drops nullable: true when the schema has allOf and no type. The converted schema then rejects null, which the original allowed. #172 fixed this for anyOf and oneOf, but allOf is still affected.
The pattern is common in GitHub's REST API description. For example, label.archived_by is { nullable: true, allOf: [{ $ref: '#/components/schemas/simple-user' }] }.
Reproduction (openapi-format 1.33.7, Node 24):
import { openapiConvertVersion } from 'openapi-format';
const doc = {
openapi: '3.0.3',
info: { title: 't', version: '1' },
paths: {},
components: {
schemas: {
User: { type: 'object', properties: { login: { type: 'string' } } },
Label: {
type: 'object',
properties: {
archived_by: { nullable: true, allOf: [{ $ref: '#/components/schemas/User' }] },
milestone: { nullable: true, oneOf: [{ type: 'string' }, { type: 'integer' }] },
},
},
},
},
};
const { data } = await openapiConvertVersion(doc, { convertTo: '3.1' });
console.log(JSON.stringify(data.components.schemas.Label.properties, null, 2));
Actual:
{
"archived_by": { "allOf": [{ "$ref": "#/components/schemas/User" }] },
"milestone": { "oneOf": [{ "type": "string" }, { "type": "integer" }, { "type": "null" }] }
}
milestone (oneOf) is converted correctly. archived_by (allOf) loses nullable entirely.
Expected, for example:
"archived_by": {
"anyOf": [
{ "allOf": [{ "$ref": "#/components/schemas/User" }] },
{ "type": "null" }
]
}
Adding { "type": "null" } to the allOf list itself wouldn't work, since a value can't match both a User and null. The null has to sit alongside the allOf, for example in an anyOf.
- 主要语言
- JavaScript
- 星标
- 177
- 派生
- 30
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
thim81/openapi-format 的其他 Issue
-
inverseOperationIds removes schema properties named after HTTP methods (e.g. head)可能已有人在做 @thim81 于 2 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
thim81/openapi-format#238 · 1 条评论 · 已指派 1 人 ·
-
难度 2/5 1-3 小时 新手友好度 25/100
thim81/openapi-format#237 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
thim81/openapi-format#232 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
thim81/openapi-format#196 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
thim81/openapi-format#169 · 2 条评论 ·
查看 thim81/openapi-format 的全部 Issue
相似的 Issue
-
documentation good first issue help wanted
难度 1/5 1-3 小时 新手友好度 92/100
维护者通常 1 天内回复
-
automated issue report
难度 1/5 1 小时以内 新手友好度 85/100
lirantal/discoprint#29 ·
维护者通常 1 天内回复
-
feature-request
难度 2/5 1-3 小时 新手友好度 68/100
louislam/uptime-kuma#7914 · 1 条评论 ·
维护者通常 1 天内回复
-
Code Cleanup dependencies
难度 1/5 1 小时以内 新手友好度 68/100
ProjectSidewalk/SidewalkWebpage#5609 ·
维护者通常 1 天内回复
-
help wanted javascript
难度 2/5 1-3 小时 新手友好度 68/100
OWASP/cornucopia#3538 ·
维护者通常 1 天内回复