Hello Valentine, I do love watch your videos as it had helped a lot. And this video was much needed. But I have a issue, I noticed your only changing the body that is the response. What if and this does happen alot more then I would want. But if the type is changed. For example we know the type is object but let's say you have a property that is a type string that may change to a type number. The type has changed but not the body. How does ajv get around this. This maybe good for more advance topics of not changing the body of the response.
After providing required, change the attribute name in the properties and send the request. postman will fail in that case. Example : in you schema, you have mentioned code in both "properties" and in "required". now, change the name "code" to "id(some other name)" postman cannot validate that. the test will be a pass
I'm about to start creating my first RESTful API, and I have to say that this video alone is going to allow me to focus more on writing the code than the documentation etc. Thank you, keep up the good work Valentin.
You are just the greatest teacher! How do you find so simple words to explain complex things, I just don't get it... But thank you very much for your hard work! Bought your excellent Postman course on Udemy and several friends did the same after my advice. Again, thank you! Waiting for the new videos about JSON-Schema from you.
Hi Valentin Despa, Thank you for sharing such valuable educational videos. Could you please share the link where did you learn this from. Is there a need to create a mock server for the testing purposes?
Hey Valentin, thanks for this video! I just finished your Udemy course but I struggle a bit to follow up with this one here, are there any video/documentation that I should be aware maybe before watching the Schema? Thanks a lot!
@valentin Despa. I am finding your videos USEFUL. Thank you for sharing your knowledge with the world. One question: { "Value": ""} ---let's say this is the response body. What can I write in "properties": { "Value": {"type": ......What should be the type here?.....}}. I am expecting blank value. Thank you.
Question 2: {"Value": "Yes"} ---let's say this is the response body. I can write in "properties": {"Value": {"type":"string"} }. What if I want to check that the string is equal to "Yes" doing schema-validation-way. Thank you. I guess the ANSWER would be the use of enum as shown below: "properties":{"Value": {"enum": "Yes"}
It is hard to know what the problem is in this case. Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
AFAIK, there is not automated way to do this. You can use the API feature in Postman and link an API to a collection. You can the manually check if the collection follows the API spec.
@@vdespa I mean - are there any best practices in assertions with Schema Validation approach ? I mean cases with too much nesting in response. Also, how many types we can validate with S. validation approach - I mean - how to check "date", "array", "img" etc. ?
@@on3p3301 Great question. I will add some additional tutorials explaining how to do that, especially with nested objects, arrays and other types (date). If you have a concrete example response, send me an email at valentin@vdespa.com
Hi Valentin. Thank You very much for sharing all of this tips! I have a question : it's possible to retrive the schemas from external sources (for example from files or somewhere in the cloud) without write maybe long variables in the Postman code? Thank you!
Thank you for your comment, Andrea. Yes, this is possible. Here is a very simple example: pm.sendRequest("your.schema", function (err, response) { pm.test("Validate schema", () => { pm.response.to.have.jsonSchema(response.json()); }); });
@@vdespa Hi Valentin! Thanks for the lesson! I wonder if an external file can be entirely used for my body on sending a POST request for example? Thank you in advance!
Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
Hi, schema of my response body is dynamic i.e... Sometimes response body is {"address": xyz street, "zip code": 12345, "city": ABCD}. Sometimes it's {"address": xyz street, "zip code": 12345}. How can i code"required" in the Tests in such a scenario. Thanks
Hi Valentin. I still dont understand the point of why the test should NOT pass on the initial schema when we send {} - empty object??? its on 3:30 on the video. If i send an empty object to the simple schema that you wrote it will pass as well....
@@vdespa But there is NOT any required property in the frist schema in your video, thats why I am confused between 3:27 and 3:40 you are saying: "The empty object is coming back but the schema is valid. So what is going on here? This person thought that this particular test and this particular schema will work just fine..." sorry for the big quotation.. So.. we don't have any required properties... why do we expect this test to fail when sending an empty object to this particular schema ?
@@nenadtrajanovski2824 some people don't think they need to add required properties and expect that this example will fail, if needed. Sorry for not being more explicit.