Skip to content

Type ["null", "foo"] not converted correctly in "$ref" #27

Open
@janjagusch

Description

@janjagusch

I am trying to find a workaround for #26. This time, I tried creating a "nullable_schema" with type=["null", "object"] and then extending it in a different schema with type="object".

Input

{
    "allOf": [{"$ref": "#/nullable_schema"}, {"type": "object"}],
    "nullable_schema": {
        "type": ["null", "object"],
        "properties": {
            "my_string": {
                "type": "string"
            }
        },
        "required": ["my_string"],
        "additionalProperties": false
    }
}

I expected the output to be somehow like this. The extended schema was supposed to be left untouched and in the nullable schema the "type": "null" should have been casted to "nullable": true.

Expected Output

{
  "allOf": [
    {
      "$ref": "#/nullable_schema"
    },
    {
      "type": "object"
    }
  ],
  "nullable_schema": {
    "type": "object",
    "properties": {
      "my_string": {
        "type": "string"
      }
    },
    "required": [
      "my_string"
    ],
    "additionalProperties": false,
    "nullable": true
  }
}

As opposed to #26, this time the script did not crash. However, in the actual output the "type": "null" was not resolved. It was still "type": ["null", "object"].

Actual Output

{
  "allOf": [
    {
      "$ref": "#/nullable_schema"
    },
    {
      "type": "object"
    }
  ],
  "nullable_schema": {
    "type": [
      "null",
      "object"
    ],
    "properties": {
      "my_string": {
        "type": "string"
      }
    },
    "required": [
      "my_string"
    ],
    "additionalProperties": false
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions