Forum Discussion

patilawaken's avatar
patilawaken
Occasional Contributor
6 years ago
Solved

Assertions: Json Schema complaince

I want to use the Json schema complaince assertion in Ready API for API  response schema validation.

While adding assetion, Its required to add the Schema URL,

  • What is this URL?
  • What does this URL consists of?
  • I dont have any schema URL, I have only json schema stored in a file.
  • This url can be any normal url link which contains JSON schemas.

     

    For example - http://example.com/docs/path/employee.json

     

    Which contains the schemas like this:-

    {
      "$id": "https://example.com/person.schema.json",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "title": "Person",
      "type": "object",
      "properties": {
        "firstName": {
          "type": "string",
          "description": "The person's first name."
        },
        "lastName": {
          "type": "string",
          "description": "The person's last name."
        },
        "age": {
          "description": "Age in years which must be equal to or greater than zero.",
          "type": "integer",
          "minimum": 0
        }
      }
    }

    So, in your case, I guess, you cannot use this JSON Schema complaince. Since, you don't have the urls.

    You can use JSON Path Assertions.

3 Replies

  • avidCoder's avatar
    avidCoder
    Super Contributor

    This url can be any normal url link which contains JSON schemas.

     

    For example - http://example.com/docs/path/employee.json

     

    Which contains the schemas like this:-

    {
      "$id": "https://example.com/person.schema.json",
      "$schema": "http://json-schema.org/draft-07/schema#",
      "title": "Person",
      "type": "object",
      "properties": {
        "firstName": {
          "type": "string",
          "description": "The person's first name."
        },
        "lastName": {
          "type": "string",
          "description": "The person's last name."
        },
        "age": {
          "description": "Age in years which must be equal to or greater than zero.",
          "type": "integer",
          "minimum": 0
        }
      }
    }

    So, in your case, I guess, you cannot use this JSON Schema complaince. Since, you don't have the urls.

    You can use JSON Path Assertions.

    • patilawaken's avatar
      patilawaken
      Occasional Contributor

       Thanks