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

this is the global context in function call, leading to an undefined error #1903

Closed
jasongrout opened this issue Jan 21, 2016 · 3 comments
Closed
Milestone

Comments

@jasongrout
Copy link

Swagger throws an error when trying to render http://petstore.swagger.io/?url=https://raw.githubusercontent.com/minrk/notebook/swagger-doc/notebook/services/api/api.yaml. The error is

Uncaught TypeError: Cannot read property '0' of undefinedSwaggerUi.partials.signature.getInlineModel @ swagger-ui.js:26334
SwaggerUi.partials.signature.createParameterJSONSample @ swagger-ui.js:26928
SwaggerUi.Views.ParameterView.Backbone.View.extend.render @ swagger-ui.js:26177
SwaggerUi.Views.OperationView.Backbone.View.extend.addParameter @ swagger-ui.js:25609
SwaggerUi.Views.OperationView.Backbone.View.extend.render @ swagger-ui.js:25539
SwaggerUi.Views.ResourceView.Backbone.View.extend.addOperation @ swagger-ui.js:27264
SwaggerUi.Views.ResourceView.Backbone.View.extend.render @ swagger-ui.js:27240
SwaggerUi.Views.MainView.Backbone.View.extend.addResource @ swagger-ui.js:25290
SwaggerUi.Views.MainView.Backbone.View.extend.render @ swagger-ui.js:25262
window.SwaggerUi.Backbone.Router.extend.render @ swagger-ui.js:24835
window.SwaggerUi.Backbone.Router.extend.initialize.options.options.success @ swagger-ui.js:247533
.SwaggerClient.buildFromSpec @ swagger-ui.js:15676.Resolver.finish @ swagger-ui.js:2456
(anonymous function) @ swagger-ui.js:23206.Resolver.resolve @ swagger-ui.js:23613
.SwaggerClient.build.obj.on.response @ swagger-ui.js:13315
.SwaggerHttp.execute.responseInterceptor @ swagger-ui.js:18225
.SwaggerHttp.execute.obj.on.response @ swagger-ui.js:1826(anonymous function) @ swagger-ui.js:2042162
.Request.callback @ swagger-ui.js:24191(anonymous function) @ swagger-ui.js:23821163.Emitter.emit @ swagger-ui.js:24633162.Request.end.xhr.onreadystatechange @ swagger-ui.js:24268XMLHttpRequest.send (async)162.Request.end @ swagger-ui.js:243325.SuperagentHttpClient.execute @ swagger-ui.js:19855.SwaggerHttp.execute @ swagger-ui.js:18423.SwaggerClient.build @ swagger-ui.js:13613.SwaggerClient.initialize @ swagger-ui.js:12863.module.exports @ swagger-ui.js:1235window.SwaggerUi.Backbone.Router.extend.load @ swagger-ui.js:24808(anonymous function) @ ?url=https://raw.githubusercontent.com/minrk/notebook/swagger-doc/notebook/services/api/api.yaml:80k @ jquery-1.8.0.min.js:2l.fireWith @ jquery-1.8.0.min.js:2p.extend.ready @ jquery-1.8.0.min.js:2D @ jquery-1.8.0.min.js:2
?url=https://raw.githubusercontent.com/minrk/notebook/swagger-doc/notebook/services/api/api.yaml:1 Failed to decode downloaded font: http://petstore.swagger.io/fonts/DroidSans-Bold.ttf

Looking into it, it appears that getInlineModel uses this (

var model = this.inlineModels[id];
), but is called in a global context (
} else if (getInlineModel(type)) {
), so this is actually the window object, which of course doesn't have an inlineModels attribute.

@jasongrout jasongrout changed the title undefined this context in function call this is the global context in function call Jan 21, 2016
@jasongrout jasongrout changed the title this is the global context in function call this is the global context in function call, leading to an undefined error Jan 21, 2016
@sujithvaddi
Copy link

Any Update on this? I see the same exact error when loading my Swagger.json in the Swagger-UI.

TypeError: this.inlineModels is undefined
Line:21121 Swagger-ui.js

@sujithvaddi
Copy link

Looks like this is fixed with the latest changes in the master.

@fehguy
Copy link
Contributor

fehguy commented May 3, 2016

great, thanks for confirming.

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