postmanlabs / postman-app-support

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.
https://www.postman.com
5.84k stars 839 forks source link

Validate the response schema against openapi spec schema #13063

Open PriyankaKoparkar opened 2 months ago

PriyankaKoparkar commented 2 months ago

Is there an existing request for this feature?

Is your feature request related to a problem?

no

Describe the solution you'd like

Add a way to validate the response schema against openapi spec schema.

Using Ajv, we can validate the response against schema like this.

var Ajv = require('ajv'), ajv = new Ajv({logger: console}), schema = { "properties": { "errors": { "type": "string" } } };

pm.test('Schema is valid', function() { var error = pm.response.json()['errors']; pm.expect(ajv.validate(schema, {errors: error})).to.be.true; }); But instead of manually defining the schema as shown in above example, it would be good to get it directly from openapi spec.

Describe alternatives you've considered

No response

Additional context

No response

shashankawasthi88 commented 2 months ago

Hi @PriyankaKoparkar - thanks for raising the request. I am one of the product managers dealing with schemas at Postman. We are working on a feature that will help you achieve the above workflow. Can we set up a short call? This will help us understand your workflow better and see if the solution works for you. You can set up a call using this link or mail me at shashank.awasthi@postman.com and I'll reach out to you. Thanks