I ran into an issue upgrading swagger-node-runner to the latest version and found an issue in your params parser (more specially in the convertValue of the helpers file).
I use an API like this:
/api/path?ids=111111111111111111111111
In my swagger definition ids is an array of string (the given id in my test is the simplest mongodb ObjectId possible which is 24 hexadecimal chars)
In your code you are doing this to know if the given parameter is a valid array:
// Attempt to parse the string as JSON if the type is array or object
if (['array', 'object'].indexOf(type) > -1) {
try {
value = JSON.parse(value);
} catch (err) {
// Nothing to do here, just fall through
}
}
Which is bad in my case because JSON.parse("111111111111111111111111") does not fail but respond 111111111111111111111111
The rest of the code fails because the value has changed from a string to a Number and the API respond a Validation Error despite the fact that the parameter is good.
Hi,
I ran into an issue upgrading swagger-node-runner to the latest version and found an issue in your params parser (more specially in the convertValue of the helpers file).
I use an API like this:
In my swagger definition ids is an array of string (the given id in my test is the simplest mongodb ObjectId possible which is 24 hexadecimal chars)
In your code you are doing this to know if the given parameter is a valid array:
Which is bad in my case because
JSON.parse("111111111111111111111111")
does not fail but respond111111111111111111111111
The rest of the code fails because the value has changed from a string to a Number and the API respond a Validation Error despite the fact that the parameter is good.
Best regards, David