2

Input

{
    "createResponse": {
        "backResponse": {
            "status": {
                "code": "000",
                "message": "success"
            }
        }
    }
}

or

{
    "updateResponse": {
        "backResponse": {
            "status": {
                "code": "000",
                "message": "success"
            }
        }
    }
}

this is my json schema:

{
    "properties": {
        "backResponse": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "status": {
                    "type": "object",
                    "required": false,
                    "properties": {
                        "code": {
                            "type": "string",
                            "required": false
                        },
                        "message": {
                            "type": "string",
                            "required": false
                        }
                    }
                }
            }
        }
    },
    "anyOf": [{
        "additionalProperties": false,
        "properties": {
            "createResponse": {
                "type": "object",
                "properties": {
                    "$ref": "#/properties/backResponse"
                }
            }
        }
    }, {
        "additionalProperties": false,
        "properties": {
            "updateResponse": {
                "type": "object",
                "properties": {
                    "$ref": "#/properties/backResponse"
                }
            }
        }
    }]
}

getting error with this in datapower as Unexpected value for the property '$ref'. Expected value type: 'object'. Got: '"#/properties/backResponse" ...'.

What wrong am I doing

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
mnvbrtn
  • 558
  • 1
  • 8
  • 27

1 Answers1

1

If you just want enforce updateResponse is of type backResponse you can reference it like this:

"createResponse" : {"$ref" : "#/properties/backResponse"}

JSON Reference resolution is added to DataPower firmware from version 6.0.1. You should check also your version.

Finally I must warn you are using Json-Schema Draft3. required needs an array in Draft4.

jruizaranguren
  • 12,679
  • 7
  • 55
  • 73