Using union type with null in nested ref (without an enum), fails schema validation

Hi,

when trying to set fields as optional in the API, I noticed that some valid schemas are rejected.

For example:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "additionalProperties": false,
  "required": ["A"],
  "properties": {
    "A": {
      "$ref": "#/definitions/A"
    }
  },
  "definitions": {
    "A": {
      "type": "object",
      "additionalProperties": false,
      "required": ["B"],
      "properties": {
        "B": {
          "$ref": "#/definitions/B"
        }
      }
    },
    "B": {
      "type": "object",
      "additionalProperties": false,
      "required": ["C"],
      "properties": {
        "C": {
          "type": ["integer", "null"]
        }
      }
    }
  }
}

Using this schema in a request fails with the following message:
Invalid schema for response_format 'Schema'. Please ensure it is a valid JSON Schema.

When using one layer less of nesting, or when specifying enum values for the ā€œCā€ property, the request works.

1 Like