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

Properly handle JSON String values for object type #48

Closed
krivin opened this issue Dec 12, 2015 · 6 comments
Closed

Properly handle JSON String values for object type #48

krivin opened this issue Dec 12, 2015 · 6 comments

Comments

@krivin
Copy link

krivin commented Dec 12, 2015

When doing type conversion for strings when the expected type is object and the string contains a JSON encoded object, it is not converted to object.

This breaks response validation in swagger-restify, which sets up connect middleware, which passes the body of the response to the validator as a string: https://github.com/theganyo/swagger-node-runner/blob/master/lib/connect_middleware.js#L162. I can't see what else it can do, and it would have worked before 473c6db.

@whitlockjc
Copy link
Member

Ironically, the reason this feature was removed was because of swagger-node-runner. What version of swagger-node-runner are you running? If it's not the latest, do you mind upgrading and trying with sway as-is? Let me know what you find out.

@krivin
Copy link
Author

krivin commented Dec 12, 2015

It is the latest. Just spent the day fixing npm update issues :-)

─┬ swagger-restify-mw@0.6.0
└─┬ swagger-node-runner@0.6.13
├─┬ sway@0.6.0

@whitlockjc
Copy link
Member

Okay. I don't see why we can't just add this back and resurrect its tests but I'd love to let @theganyo chime in first.

@whitlockjc
Copy link
Member

Also, if you don't mind could you create an issue in swagger-node-runner for this as well, for posterity? Link this issue in the issue description so that @theganyo has context.

@theganyo
Copy link

I don't recall any specific reason from prior discussions why this feature was removed. The only discussions I'm remembering were around not parsing when the type was indeterminate. But maybe I'm forgetting something?

@whitlockjc
Copy link
Member

Could be. Maybe too much was removed. I'll add it back so that when we know the type is object and the value is a string, we try to parse it. We should do the same for arrays.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants