This is the solution:
You need to paste your expected response to this tool that the kind developers of jsonschema have provided and create a JSON Schema in the right side. Paste the code from the right side in your variable (schema) and pass that variable for validating:
pm.test(“JSON Schema validation”, () => {
pm.response.to.have.jsonSchema(schema);
});
response is a variable in which we keep the response body:
let response = pm.response.json();