Skip to content

Convert optional references to oneOf type with null #13

Open
@sandrokeil

Description

@sandrokeil

If null is provided as data, then the JSON schema validation will fail, if we don't allow type of null for optional references. The reference object must allow null to pass JSON schema validation, which is wrong.

The shorthand syntax of:

{
  "shorthand": true,
  "schema": {
    "customerId": "/Customer/CustomerId",
    "externalId?": "/Acme/ExternalId"
  }
}

should be translated into

{
    "type": "object",
    "properties": {
        "customerId": {
            "$ref": "#/definitions/Customer/CustomerId",
            "namespace": "/Customer"
        },
        "externalId": {
            "oneOf": [
                {"type": "null"},
                {"$ref": "#/definitions/Acme/ExternalId"}
            ],
            "namespace": "/Acme"
        }
    },
    "required": [
        "customerId"
    ],
    "additionalProperties": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions