Closed BigMrSunshine closed 8 years ago
I did add some logging in swagger-validator when the validation fails:
`
if (isModel) {
if (_.isString(val)) {
try {
val = JSON.parse(val);
} catch (err) {
console.log("Petty - val: " + val);
console.log("Petty - err: " + err);
err.failedValidation = true;
err.message = 'Value expected to be an array/object but is not';
throw err;
}
}`
Petty - val: Hello, Scott!
Petty - err: SyntaxError: Unexpected token H
Thanks
@BigMrSunshine -
It looks like the template is actually wrong and some new validation logic in a library picked it up. Quick fix, change your swagger.yaml to have this:
definitions:
HelloWorldResponse:
type: string
Instead of this:
definitions:
HelloWorldResponse:
required:
- message
properties:
message:
type: string
That worked! I don't know the etiquette around this stuff. Should I close it? Fork and submit pull request. I'm kind of new to the github community. Thanks
If you find something wrong with the doc and want to fix it, then yeah, submitting a PR would be greatly appreciated.
@theganyo Thank you! This worked perfectly.
@theganyo The pattern, of describing a simple string response as a message object is used several places in several templates. Are we sure this new validation logic is valid and the templates should be changed (via a PR) as you described above?
updated the templates
Thanks!
I followed the instructions on the quick start page, selecting express as the framework.
When I hit the endpoint with curl, I get a truncated json response message:
{"message":"Res
The error below shows up on the console.
Thanks!