Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New JSON Validator Needed #3199

Closed
jon49 opened this issue Jun 22, 2017 · 14 comments
Closed

New JSON Validator Needed #3199

jon49 opened this issue Jun 22, 2017 · 14 comments
Assignees
Labels

Comments

@jon49
Copy link

jon49 commented Jun 22, 2017

Since it doesn't appear that tv4 is being actively maintained I think this issue needs to stop being punted down the road. Not only is tv4 not maintained, but neither is it standard compliant with the JSON Schema standards.

As you can see there hasn't been any work done of on the source code for 2 years - https://github.com/geraintluff/tv4.

If you look at the issues you can see that they are not responded to by the original author:
https://github.com/geraintluff/tv4/issues

I think Postman owes it to its users to investigate and use a standards compliant library that is actively maintained.

A wrapper around the new library can be used so that the old tv4 API can still work properly while still displaying the new API of whatever library Postman chooses to use.

Here are previous issues on the subject:

Open
#2788

Closed
#3173
#3138
#2574

Thanks in advance!

@sdnts
Copy link

sdnts commented Jun 23, 2017

@jon49 We will definitely look into this. As you said, we'll need to add a new library in order to keep previous tv4 scripts working.
@shamasis @kunagpal Can we look into this for postman-runtime?

@tlemons
Copy link

tlemons commented Jul 3, 2017

Hi - thanks for being so receptive about looking into this. Being unable to perform JSON response validation is a big 'hole' for us right now. I'd like my team to focus on Postman for our testing, but we'll need to look for alternates for the JSON response validation soon. Could you share your timeline for adding functional JSON validation? Thanks!

@sdnts
Copy link

sdnts commented Jul 4, 2017

Hey! Our public roadmap is available here: https://trello.com/b/4N7PnHAz/postman-roadmap-for-developers so you can watch that.

@tlemons
Copy link

tlemons commented Jul 5, 2017

Thanks for this pointer; I'll follow this from now on. So, it appears that addressing JSON validation is not even a planning-level card, so this issue won't be addressed in the foreseeable future; is that correct? Thanks.

@sdnts
Copy link

sdnts commented Jul 5, 2017

Indeed, but since this is a new issue, we'll look into this in detail and update the roadmap accordingly :)

@tlemons
Copy link

tlemons commented Jul 5, 2017

Ah. thanks.

@jvkaam
Copy link

jvkaam commented Jul 7, 2017

To motivate an upvoting I would suggest that having a full CI and CD environment in which you generate Postman collections you definitely want to validate it against its own schema.

@tlemons
Copy link

tlemons commented Oct 19, 2017

I would like to motivate upvoting of this feature, but don't know how to accomplish what jvkaam suggested. That said, is this feature being considered for a future release? Thanks!

@imranismail
Copy link

Any update on this?

@shamasis
Copy link
Member

shamasis commented Sep 18, 2018

Thinking of adding Ajv -> https://www.npmjs.com/package/ajv - does that sound good?

@kamalaknn
Copy link
Member

kamalaknn commented Jan 13, 2019

We've added ajv library to the sandbox scripts. This should be available in Postman native apps starting from 6.7.1.

@king4sam
Copy link

Did anyone use ajv successfully on postman native app v6.7.1? ( on MacOS )
I followed instructions here to require ajv in test script, but I got error as below

var Ajv = require('ajv');
var ajv = new Ajv();  // ReferenceError: console is not defined

Is there somebody met the same issue or I require ajv in the wrong way?

@codenirvana
Copy link
Member

codenirvana commented Jan 17, 2019

@king4sam You can refer the example given here.

You either have to use {logger: console} option or {logger: false} to avoid the ReferenceError.

Example:

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

pm.test('Schema is valid', function() {
    pm.expect(ajv.validate(schema, {alpha: true})).to.be.true;
    pm.expect(ajv.validate(schema, {alpha: 123})).to.be.false;
});

This is because console is not directly available(inside sandbox) to Ajv and when logger option is missing, Ajv will assign console by default and throws ReferenceError.

@king4sam
Copy link

@codenirvana thank you!

shamasis added a commit to shamasis/ajv that referenced this issue Feb 18, 2019
Ajv assumes console to be present in the environment. It is an acceptable for all normal use cases. But we use AJV within Node VM module and that is sandboxed to not have console.

The following line https://github.com/epoberezkin/ajv/blob/master/lib/ajv.js#L488 assumes console to be present. This results in issues such as [postmanlabs/postman-app-support#3199](postmanlabs/postman-app-support#3199) and requires to have a longer boilerplate code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants