convertTo 3.1 drops nullable on allOf schemas (follow-up to #172)
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, node.js
- Domain
- api
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- JavaScript
- Stars
- 177
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from thim81/openapi-format
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
thim81/openapi-format#238 · 1 comment · 1 assignee ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
thim81/openapi-format#237 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
thim81/openapi-format#232 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
thim81/openapi-format#196 · 3 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
thim81/openapi-format#169 · 2 comments ·
All issues in thim81/openapi-format
Similar issues
-
新讀者走讀回報,照著一篇文章實際操作Opendocumentation good first issue help wanted
Difficulty 1/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
automated issue report
Difficulty 1/5 Under an hour Newbie friendliness 85/100
lirantal/discoprint#29 ·
Maintainers usually reply within 1 day
-
feature-request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
louislam/uptime-kuma#7914 · 1 comment ·
Maintainers usually reply within 1 day
-
Code Cleanup dependencies
Difficulty 1/5 Under an hour Newbie friendliness 68/100
ProjectSidewalk/SidewalkWebpage#5609 ·
Maintainers usually reply within 1 day
-
help wanted javascript
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
OWASP/cornucopia#3538 ·
Maintainers usually reply within 1 day