convertTo 3.1 drops nullable on allOf schemas (follow-up to #172)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, node.js
- Ambito
- api
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- JavaScript
- Stelle
- 177
- Fork
- 30
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di thim81/openapi-format
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
thim81/openapi-format#238 · 1 commento · 1 assegnatario ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
thim81/openapi-format#237 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
thim81/openapi-format#232 · 3 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
thim81/openapi-format#196 · 3 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
thim81/openapi-format#169 · 2 commenti ·
Tutte le issue di thim81/openapi-format
Issue simili
-
refactor
Difficoltà 2/5 Mezza giornata Idoneità per principianti 84/100
I maintainer di solito rispondono entro 5 giorni
-
translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
ciderapp/translations#87 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 1 giorno
-
component: split-view platform: windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
zen-browser/desktop#15616 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno