Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
janjagusch opened this issue Mar 30, 2020 · 0 comments
Open

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

janjagusch opened this issue Mar 30, 2020 · 0 comments

Comments

@janjagusch
Copy link

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
  }
}
@janjagusch janjagusch changed the title Type ["null", "foo"] not correctly converted in "$ref"s Type ["null", "foo"] not correctly converted in "$ref" Mar 30, 2020
@janjagusch janjagusch changed the title Type ["null", "foo"] not correctly converted in "$ref" Type ["null", "foo"] not converted correctly in "$ref" Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant