Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#239 1 comment 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from thim81/openapi-format

All issues in thim81/openapi-format

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.