diff --git a/lib/swagger.js b/lib/swagger.js index 456f652e..c4ee5ed3 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -445,6 +445,7 @@ } if (this.responseClass != null) { this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models); + this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models); } this.errorResponses = this.errorResponses || []; _ref1 = this.parameters; diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee index 17e693cb..4cc3da60 100644 --- a/src/main/coffeescript/view/OperationView.coffee +++ b/src/main/coffeescript/view/OperationView.coffee @@ -14,6 +14,18 @@ class OperationView extends Backbone.View $(@el).html(Handlebars.templates.operation(@model)) + if @model.responseClassSignature and @model.responseClassSignature != 'string' + signatureModel = + sampleJSON: @model.responseSampleJSON + isParam: false + signature: @model.responseClassSignature + + responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'}) + $('.model-signature', $(@el)).append responseSignatureView.render().el + else + $('.model-signature', $(@el)).html(@model.responseClass) + + # Render each parameter @addParameter param for param in @model.parameters diff --git a/src/main/coffeescript/view/ParameterView.coffee b/src/main/coffeescript/view/ParameterView.coffee index 69f12e20..c4d75d87 100644 --- a/src/main/coffeescript/view/ParameterView.coffee +++ b/src/main/coffeescript/view/ParameterView.coffee @@ -8,8 +8,13 @@ class ParameterView extends Backbone.View template = @template() $(@el).html(template(@model)) + signatureModel = + sampleJSON: @model.sampleJSON + isParam: true + signature: @model.signature + if @model.sampleJSON - signatureView = new SignatureView({model: @model, tagName: 'div'}) + signatureView = new SignatureView({model: signatureModel, tagName: 'div'}) $('.model-signature', $(@el)).append signatureView.render().el else $('.model-signature', $(@el)).html(@model.signature) diff --git a/src/main/coffeescript/view/SignatureView.coffee b/src/main/coffeescript/view/SignatureView.coffee index c867b960..578f99eb 100644 --- a/src/main/coffeescript/view/SignatureView.coffee +++ b/src/main/coffeescript/view/SignatureView.coffee @@ -13,6 +13,11 @@ class SignatureView extends Backbone.View @switchToDescription() + @isParam = @model.isParam + + if @isParam + $('.notice', $(@el)).text('Click to set as parameter value') + @ template: -> @@ -36,8 +41,11 @@ class SignatureView extends Backbone.View # handler for snippet to text area snippetToTextArea: (e) -> - e?.preventDefault() - textArea = $('textarea', $(@el.parentNode.parentNode.parentNode)) - if $.trim(textArea.val()) == '' + if @isParam + e?.preventDefault() + textArea = $('textarea', $(@el.parentNode.parentNode.parentNode)) + if $.trim(textArea.val()) == '' textArea.val(@model.sampleJSON) + + diff --git a/src/main/template/operation.handlebars b/src/main/template/operation.handlebars index f0049d5b..e623dc2a 100644 --- a/src/main/template/operation.handlebars +++ b/src/main/template/operation.handlebars @@ -22,12 +22,8 @@

{{{notes}}}

{{/if}} {{#if responseClass}} -

Response Class

- {{#if responseClassSignature}} -

{{{responseClassSignature}}}

- {{else}} -

{{{responseClass}}}

- {{/if}} +

Response Model

+ {{/if}}
diff --git a/src/main/template/signature.handlebars b/src/main/template/signature.handlebars index b90200c1..53d0785d 100644 --- a/src/main/template/signature.handlebars +++ b/src/main/template/signature.handlebars @@ -12,7 +12,7 @@
{{sampleJSON}}
- Click to set as parameter value +