Files
swagger-ui/src/main/coffeescript/view/StatusCodeView.coffee
Mohsen Azimi 7006e86fa5 Remove global references to swaggerUi object
By passing parent view as an option to child views, child views can
access parent views and eventually can access model of MainView

There is alos a new domEl option available for SwaggerUI constructor.
User can send domEl instead of dom_id to specifiy which element they
want to render to
2015-03-10 11:16:08 -07:00

26 lines
813 B
CoffeeScript

class StatusCodeView extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
models = this.options.parent.options.parent.options.parent.model.models
if models.hasOwnProperty @model.responseModel
models = this.options.parent.options.parent.options.parent.model.models
responseModel =
sampleJSON: JSON.stringify(models[@model.responseModel].createJSONSample(), null, 2)
isParam: false
signature: models[@model.responseModel].getMockSignature()
responseModelView = new SignatureView({model: responseModel, tagName: 'div'})
$('.model-signature', @$el).append responseModelView.render().el
else
$('.model-signature', @$el).html ''
@
template: ->
Handlebars.templates.status_code