Can anyone please let me know how to do JSON schema validation while API testing in Telerik Test Studio? (I have a given schema)
2 Answers, 1 is accepted
answered on 01 Jun 2021, 12:49 PM
Thank you for contacting us with your question. I will share more details about our product and what it supports.
Test Studio for APIs is designed to help you automate the API of your application. You can send requests and validate the response that is returned by the server. You can find more details and examples in the linked documentation of our product.
Let me get back to your questions. I must say that I am not an expert on JSON schema, but I did some research. I believe that it is not possible to validate the JSON schema within the API project, since it does not exist in the response. I might be misunderstanding your test scenario, so please share more details and examples to help me understand it better.
Thank you for your cooperation in advance.
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
answered on 02 Jun 2021, 09:18 AM
Thank you for sharing additional information about the test scenario.
From what I understand, you want to verify if the returned response has an object that matches the expected JSON schema. Lets look at the example for the Product object here and see what kind of verifications you can use.
In this example, the Product's schema has "productID", "productName', "price" and "tags" properties. In order to verify the schema, you can do a verification for each of those properties and ensure that the object in the response complies with the expected schema. Lets look at the example below.
"description": "A product from Acme's catalog",
"description": "The unique identifier for a product",
"description": "Name of the product",
"required": [ "productId", "productName" ]
Here the "productID" should be an integer and the "productName" should be a string. You can use RegEx to verify that the returned value for "productID" has only characters from 0 to 9 or that the "productName" has a certain string value. That is just one way to check if the returned object matches the expected JSON schema.
I hope the above details and suggestion will be helpful to you.