# Validate the response schema against openapi spec schema

**URL:** <https://community.postman.com/t/validate-the-response-schema-against-openapi-spec-schema/64902>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [August 2, 2024, 3:01am UTC](https://community.postman.com/t/validate-the-response-schema-against-openapi-spec-schema/64902 "2024-08-02T03:01:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![spaceflight-admini11](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@spaceflight-admini11](https://community.postman.com/u/spaceflight-admini11)\
**Post date:** [August 2, 2024, 3:01am UTC](https://community.postman.com/t/validate-the-response-schema-against-openapi-spec-schema/64902/1 "2024-08-02T03:01:01Z")

</div>

Is there a way to validate the response schema against openapi spec schema?

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

```auto
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, can we somehow get it from openapi spec.

---

<div class="post-metadata">

**Author:** ![gbadebo-bello](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/gbadebo-bello/32/12175_2.png) [@gbadebo-bello](https://community.postman.com/u/gbadebo-bello)\
**Post date:** [August 3, 2024, 5:58pm UTC](https://community.postman.com/t/validate-the-response-schema-against-openapi-spec-schema/64902/2 "2024-08-03T17:58:57Z")

</div>

Hi @spaceflight-admini11. Welcome to the Postman Community :postman:.

Currently, this is not possible in Postman. I will recommend that you make a feature request [here](https://github.com/postmanlabs/postman-app-support/issues/new/choose).

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [September 2, 2024, 5:59pm UTC](https://community.postman.com/t/validate-the-response-schema-against-openapi-spec-schema/64902/3 "2024-09-02T17:59:26Z")

</div>

Closed on September 2, 2024, 5:59pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
