Layer7 API Management

 View Only
  • 1.  JSON Schema Assertion Unexpected behaviour

    Posted Nov 30, 2017 09:53 AM

    Hi all

     

    I have problem defining optional field in a JSON Schema. The API Gateway JSON Schema validation Assertion does not interpret the JSON Schema as expected. According to the standard the "LegacyKeys" should be optional but the assertions thinks otherwise

     

    We are currently on CA API Gateway 9.1


    Can anyone clarify or suggest a workaround?

     

    My Schema:

     

     {

      "type": "object",

      "properties": {

        "VEName": {

          "type": "string",

          "minLength": 1

        },

        "PeriDBSequence": {

          "type": "string",

          "pattern": "^(\\d*)$"

        },

        "LegacyKeys": {

          "type": "string",

          "pattern": "^((\\d*)(,\\d+)*)$",

          "minLength": 1

        }

      },

      "required" : [ "VEName", "PeriDBSequence"]

    }

     

    Input json:

    {

                    "VEName": "TownOfA",

                    "PeriDBSequence": "3318673"

    }

     

    Unexpected fault: 

    $.LegacyKeys: is missing and it is not optional

     

    Kind regards
    Samuel



  • 2.  Re: JSON Schema Assertion Unexpected behaviour
    Best Answer

    Broadcom Employee
    Posted Nov 30, 2017 10:56 AM

    Hi Samuel,

     

    This appears to be using schema v4 which we do not currently support. We do have an enhancement request/idea opened to address this in a future release if you would like to vote on the idea it can be found here:

     

    JSON schema V4 specification support 

     

     

    Regards,

    Joe 



  • 3.  Re: JSON Schema Assertion Unexpected behaviour

    Broadcom Employee
    Posted Nov 30, 2017 11:36 AM

    Just to add to this if you declare that your schema was written against a specific version of the JSON Schema standard, and not just the latest version, you should see a similar failure in other validators.

     

    {
    "$schema":"http://json-schema.org/draft-03/schema#",
    "type": "object",
    "properties": {
    "VEName": {
    "type": "string",
    "minLength": 1
    },
    "PeriDBSequence": {
    "type": "string",
    "pattern": "^(\\d*)$"
    },
    "LegacyKeys": {
    "type": "string",
    "pattern": "^((\\d*)(,\\d+)*)$",
    "minLength": 1
    }
    },
    "required" : [ "VEName", "PeriDBSequence"]
    }



  • 4.  Re: JSON Schema Assertion Unexpected behaviour

    Posted Dec 01, 2017 03:59 AM

    Hi Joe (dasjo02)

     

    Thx for the quick response and clarification!

     

    What are the current supported version(s) of JSON Schema in API Gateway (and in particular on 9.1). That info is not provided in the doc page at Validate JSON Schema Assertion (Message Validation/Transformation) - CA API Gateway - 9.1 - CA Technologies Documentatio… 

     

    In the assertion there is no way to select the version of the JSON Schema validator to be used, so is not possible to define the validator to be used or will it dynamically choose the validator based on the "$schema" field in the JSON schema itself?

     

    Kind regards
    Samuel

     

     



  • 5.  Re: JSON Schema Assertion Unexpected behaviour

    Posted Dec 01, 2017 04:27 AM

    Hi Samuel Vandecasteele,

     

    The gateway version 9.2 supports json schema Draft 2. From 9.3 onwards, You can specify the JSON Schema Version (v2 or v4) to verify the payload against.

     

    Use the following url to check the draft version. JSON Schema Validator - Newtonsoft 

     

    Regards

    Seenu Mathew