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

swagger.js: consumes/produces vars are leaked into global namespace #107

Closed
raymondfeng opened this issue Aug 4, 2014 · 4 comments
Closed

Comments

@raymondfeng
Copy link

We found the following issues while troubleshooting strongloop/loopback#432.

  1. Variables consumes abd produces at https://github.com/wordnik/swagger-js/blob/master/lib/swagger.js#L324 are leaked into global namespace. As a result, the logic at https://github.com/wordnik/swagger-js/blob/master/lib/swagger.js#L1236 doesn't make sense. this.operation.consumes.indexOf(consumes) === -1 will always return -1 because consumes is an array. The operation.consumes will be written into the global consumes.
  2. Even worse, if the api spec doesn't specify a default consumes, the default value is [] and it throws TypeError at https://github.com/wordnik/swagger-js/blob/master/lib/shred/content.js#L112.
@fehguy
Copy link
Contributor

fehguy commented Aug 4, 2014

somehow the declaration for consumes was removed. It should default to application/json I believe

@raymondfeng
Copy link
Author

Shouldn't consumes/produces be instance vars for SwaggerResource?

I assume https://github.com/wordnik/swagger-js/blob/master/lib/swagger.js#L1191 should have its own declaration of consumes/produces too.

@fehguy
Copy link
Contributor

fehguy commented Aug 4, 2014

Yes, to both. It wasn't implemented at the top-level resource for swagger.js it appears.

@fehguy
Copy link
Contributor

fehguy commented Aug 6, 2014

pls reopen if you're still seeing this

@fehguy fehguy closed this as completed Aug 6, 2014
fehguy added a commit to swagger-api/swagger-ui that referenced this issue Aug 6, 2014
Alexgalinier pushed a commit to INTENT-TECHNOLOGIES/swagger-ui that referenced this issue Nov 17, 2014
jessekoska pushed a commit to jessekoska/SwaggerLume that referenced this issue Aug 7, 2016
vincent-zurczak pushed a commit to roboconf/swagger-ui that referenced this issue Aug 18, 2016
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

2 participants