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.
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!
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.
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?
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
@@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
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.
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.
@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.
👉 Want to learn more about Postman? Check my Postman online course.
www.udemy.com/course/postman-the-complete-guide/?referralCode=4E8B90BA4B5EE8DA9237
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.
@@stefanrhys1838 See the next tutorial. It deals with more advanced use-cases.
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.
Glad it was helpful!
I'm starting to use Postman at work and your tips are incredibly valuable. Thank You very much!
Great to hear! You are welcome. Thank you for leaving a comment.
The tutorial was very useful for me. I have not understood how schema validation works until I watch this video. Thank you, Valentin!
You are welcome!
Thanks a lot! I moved from not even knowing what a schema is to being able to build a basic one and test it.
Glad I could help!
Thanks for creating these tutorials.
Honestly, I've learned a lot from your UDEMY course and these tutorials.
You're very welcome! Thanks for watching my content and for taking the course.
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.
Thanks you so much for this amazing comment and your support. I really appreciate it.
This basic json schema validation help me a lot! Thank you very much Valentin!
Thanks for letting me know 👍
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!
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....
It depends if you expect it to pass or not. I guess the concept of required properties is something you need to be aware of.
@@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.
@@vdespa that explains, btw nice job on the udemy course, its a really good starting point in the API testing world, keep up the good work man!!!
@@nenadtrajanovski2824 Thanks, much appreciated!
Hi there, How we can validate a json schema which is dynamically changing?
Great video! Nice and clear! Straight to the point!
I am glad it helped! Thanks.
Thank you Valentin.. ! It was very helpful at right time of testing.
Great to hear that. Thanks!
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?
Creating a mock server is useful. See json-schema.org/
what if "type": "string" but sometimes it can be null (nullable)
string and null are essentially two data types. Use can use "type": ["string", "null"]
@@vdespa i seee thank you!
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
So you want to make city optional, right?
@@vdespa yes, "city" is not always present in response body
@@satinderpal9393 Have you tried not making it required?
Awesome explanation!! 🏆
Thank you, Danny!
@@vdespa Thank you, Valentin! Really useful! :) Please make another video about other assertion cases ^_^
@@on3p3301 Thank you. Which assertions cases are you referring to?
@@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
Extremely helpfull this video, I've looking for something to improve my tests in API beyond the status code, body and header....thanks a lot!
Glad it was helpful! Thanks for watching.
What is the rationale of assuming every property is option unless specified otherwise? That seems designed to give false negatives.
How to validate request/response schema validation based on Swagger/Open API
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.
Your videos are so useful! Thank you :)
Thank you for watching and for your comment. I appreciate it.
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!
@@vdespa what wlll be the url of schema , can you give some live example
@@saimatabassum3660 the URL will be the URL where the schema can be found. You need an external server to host this.
starts at 3:30
Thank you for pointing this out. I think it is good to know also what not to do.
How to check the schema of request body and also if that request body comes from a external data file?
Join the Facebook community (see link in the description) and ask your question there. Consider adding more details, including screenshots. Thanks for understanding.
@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.
Thanks for your comment. This blank value is a string with a length 0.
{ "Value": {"type":"string", "minLength":0, "maxLength":0}}
Thank you! that was very helpful ! :-)
Glad it was helpful! You are welcome. Thank you for leaving a comment.
Thanks for sharing this tip!
You are welcome, thank you for your comment!
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.
Thanks man :D
You are welcome 😁