Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

convertTo 3.1 drops nullable on allOf schemas (follow-up to #172)

Aperta
#239 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di thim81/openapi-format

Tutte le issue di thim81/openapi-format

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.