@@ -11,6 +11,7 @@ sourceFiles = [ | |||||
'view/StatusCodeView' | 'view/StatusCodeView' | ||||
'view/ParameterView' | 'view/ParameterView' | ||||
'view/SignatureView' | 'view/SignatureView' | ||||
'view/ContentTypeView' | |||||
] | ] | ||||
@@ -255,7 +255,7 @@ | |||||
_results = []; | _results = []; | ||||
for (_i = 0, _len = ops.length; _i < _len; _i++) { | for (_i = 0, _len = ops.length; _i < _len; _i++) { | ||||
o = ops[_i]; | o = ops[_i]; | ||||
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this); | |||||
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.supportedContentTypes); | |||||
this.operations[op.nickname] = op; | this.operations[op.nickname] = op; | ||||
_results.push(this.operationsArray.push(op)); | _results.push(this.operationsArray.push(op)); | ||||
} | } | ||||
@@ -413,7 +413,7 @@ | |||||
SwaggerOperation = (function() { | SwaggerOperation = (function() { | ||||
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource) { | |||||
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, supportedContentTypes) { | |||||
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2, | var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2, | ||||
_this = this; | _this = this; | ||||
this.nickname = nickname; | this.nickname = nickname; | ||||
@@ -425,6 +425,7 @@ | |||||
this.responseClass = responseClass; | this.responseClass = responseClass; | ||||
this.errorResponses = errorResponses; | this.errorResponses = errorResponses; | ||||
this.resource = resource; | this.resource = resource; | ||||
this.supportedContentTypes = supportedContentTypes; | |||||
this["do"] = __bind(this["do"], this); | this["do"] = __bind(this["do"], this); | ||||
if (this.nickname == null) { | if (this.nickname == null) { | ||||
@@ -24,7 +24,13 @@ class OperationView extends Backbone.View | |||||
$('.model-signature', $(@el)).append responseSignatureView.render().el | $('.model-signature', $(@el)).append responseSignatureView.render().el | ||||
else | else | ||||
$('.model-signature', $(@el)).html(@model.responseClass) | $('.model-signature', $(@el)).html(@model.responseClass) | ||||
contentTypeModel = | |||||
isParam: false | |||||
supportedContentTypes: @model.supportedContentTypes | |||||
contentTypeView = new ContentTypeView({model: contentTypeModel}) | |||||
$('.content-type', $(@el)).append contentTypeView.render().el | |||||
# Render each parameter | # Render each parameter | ||||
@addParameter param for param in @model.parameters | @addParameter param for param in @model.parameters | ||||
@@ -118,6 +124,14 @@ class OperationView extends Backbone.View | |||||
obj.contentType = "application/json" if (obj.type.toLowerCase() == "post" or obj.type.toLowerCase() == "put" or obj.type.toLowerCase() == "patch") | obj.contentType = "application/json" if (obj.type.toLowerCase() == "post" or obj.type.toLowerCase() == "put" or obj.type.toLowerCase() == "patch") | ||||
obj.contentType = false if isFileUpload | obj.contentType = false if isFileUpload | ||||
paramContentTypeField = $("td select[name=contentType]", $(@el)).val() | |||||
if paramContentTypeField | |||||
obj.contentType = paramContentTypeField | |||||
responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(@el)).val() | |||||
if responseContentTypeField | |||||
obj.headers.accept = responseContentTypeField | |||||
jQuery.ajax(obj) | jQuery.ajax(obj) | ||||
false | false | ||||
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r) | # $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r) | ||||
@@ -158,5 +172,5 @@ class OperationView extends Backbone.View | |||||
hljs.highlightBlock($('.response_body', $(@el))[0]) | hljs.highlightBlock($('.response_body', $(@el))[0]) | ||||
toggleOperationContent: -> | toggleOperationContent: -> | ||||
elem = $('#' + @model.resourceName + "_" + @model.nickname + "_" + @model.httpMethod + "_" + @model.number + "_content"); | |||||
elem = $('#' + @model.resourceName + "_" + @model.nickname + "_" + @model.httpMethod + "_content"); | |||||
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem) | if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem) |
@@ -9,15 +9,22 @@ class ParameterView extends Backbone.View | |||||
$(@el).html(template(@model)) | $(@el).html(template(@model)) | ||||
signatureModel = | signatureModel = | ||||
sampleJSON: @model.sampleJSON | |||||
isParam: true | |||||
signature: @model.signature | |||||
sampleJSON: @model.sampleJSON | |||||
isParam: true | |||||
signature: @model.signature | |||||
if @model.sampleJSON | if @model.sampleJSON | ||||
signatureView = new SignatureView({model: signatureModel, tagName: 'div'}) | |||||
$('.model-signature', $(@el)).append signatureView.render().el | |||||
signatureView = new SignatureView({model: signatureModel, tagName: 'div'}) | |||||
$('.model-signature', $(@el)).append signatureView.render().el | |||||
else | else | ||||
$('.model-signature', $(@el)).html(@model.signature) | |||||
$('.model-signature', $(@el)).html(@model.signature) | |||||
contentTypeModel = | |||||
isParam: true | |||||
supportedContentTypes: @model.supportedContentTypes | |||||
contentTypeView = new ContentTypeView({model: contentTypeModel}) | |||||
$('.content-type', $(@el)).append contentTypeView.render().el | |||||
@ | @ | ||||
@@ -4,18 +4,11 @@ class ResourceView extends Backbone.View | |||||
render: -> | render: -> | ||||
$(@el).html(Handlebars.templates.resource(@model)) | $(@el).html(Handlebars.templates.resource(@model)) | ||||
@number = 0 | |||||
# Render each operation | # Render each operation | ||||
@addOperation operation for operation in @model.operationsArray | @addOperation operation for operation in @model.operationsArray | ||||
@ | @ | ||||
addOperation: (operation) -> | addOperation: (operation) -> | ||||
operation.number = @number | |||||
# Render an operation and add it to operations li | # Render an operation and add it to operations li | ||||
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'}) | operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'}) | ||||
$('.endpoints', $(@el)).append operationView.render().el | $('.endpoints', $(@el)).append operationView.render().el | ||||
@number++ |
@@ -1579,3 +1579,12 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio | |||||
pre code { | pre code { | ||||
background: none; | background: none; | ||||
} | } | ||||
.content > .content-type > div > label { | |||||
clear: both; | |||||
display: block; | |||||
color: #0F6AB4; | |||||
font-size: 1.1em; | |||||
margin: 0; | |||||
padding: 15px 0 5px 0px; | |||||
} |
@@ -1,22 +1,22 @@ | |||||
<ul class='operations' > | <ul class='operations' > | ||||
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}'> | |||||
<li class='{{httpMethod}} operation' id='{{resourceName}}_{{nickname}}_{{httpMethod}}'> | |||||
<div class='heading'> | <div class='heading'> | ||||
<h3> | <h3> | ||||
<span class='http_method'> | <span class='http_method'> | ||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{httpMethod}}</a> | |||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{httpMethod}}</a> | |||||
</span> | </span> | ||||
<span class='path'> | <span class='path'> | ||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{path}}</a> | |||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{path}}</a> | |||||
</span> | </span> | ||||
</h3> | </h3> | ||||
<ul class='options'> | <ul class='options'> | ||||
<li> | <li> | ||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}_{{number}}' class="toggleOperation">{{{summary}}}</a> | |||||
<a href='#!/{{resourceName}}/{{nickname}}_{{httpMethod}}' class="toggleOperation">{{{summary}}}</a> | |||||
</li> | </li> | ||||
</ul> | </ul> | ||||
</div> | </div> | ||||
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_{{number}}_content' style='display:none'> | |||||
<div class='content' id='{{resourceName}}_{{nickname}}_{{httpMethod}}_content' style='display:none'> | |||||
{{#if notes}} | {{#if notes}} | ||||
<h4>Implementation Notes</h4> | <h4>Implementation Notes</h4> | ||||
<p>{{{notes}}}</p> | <p>{{{notes}}}</p> | ||||
@@ -25,6 +25,8 @@ | |||||
<h4>Response Model</h4> | <h4>Response Model</h4> | ||||
<span class="model-signature"></span> | <span class="model-signature"></span> | ||||
{{/if}} | {{/if}} | ||||
<br/> | |||||
<div class="content-type" /> | |||||
<form accept-charset='UTF-8' class='sandbox'> | <form accept-charset='UTF-8' class='sandbox'> | ||||
<div style='margin:0;padding:0;display:inline'></div> | <div style='margin:0;padding:0;display:inline'></div> | ||||
<h4>Parameters</h4> | <h4>Parameters</h4> | ||||
@@ -8,20 +8,22 @@ | |||||
{{#if defaultValue}} | {{#if defaultValue}} | ||||
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea> | <textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea> | ||||
{{else}} | {{else}} | ||||
<textarea class='body-textarea' name='{{name}}'></textarea> | |||||
<textarea class='body-textarea' name='{{name}}'></textarea> | |||||
<br /> | |||||
<div class="content-type" /> | |||||
{{/if}} | {{/if}} | ||||
{{/if}} | {{/if}} | ||||
{{else}} | {{else}} | ||||
{{#if defaultValue}} | {{#if defaultValue}} | ||||
<input minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/> | <input minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/> | ||||
{{else}} | {{else}} | ||||
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/> | |||||
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/> | |||||
{{/if}} | {{/if}} | ||||
{{/if}} | {{/if}} | ||||
</td> | </td> | ||||
<td>{{{description}}}</td> | <td>{{{description}}}</td> | ||||
<td> | <td> | ||||
<span class="model-signature"></span> | |||||
<span class="model-signature"></span> | |||||
</td> | </td> | ||||
@@ -7,7 +7,9 @@ | |||||
{{#if defaultValue}} | {{#if defaultValue}} | ||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea> | <textarea class='body-textarea' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea> | ||||
{{else}} | {{else}} | ||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea> | |||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea> | |||||
<br /> | |||||
<div class="content-type" /> | |||||
{{/if}} | {{/if}} | ||||
{{/if}} | {{/if}} | ||||
{{else}} | {{else}} | ||||
@@ -15,14 +17,14 @@ | |||||
<input class='required' type='file' name='{{name}}'/> | <input class='required' type='file' name='{{name}}'/> | ||||
{{else}} | {{else}} | ||||
{{#if defaultValue}} | {{#if defaultValue}} | ||||
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/> | |||||
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/> | |||||
{{else}} | {{else}} | ||||
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/> | |||||
<input class='required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/> | |||||
{{/if}} | {{/if}} | ||||
{{/if}} | {{/if}} | ||||
{{/if}} | {{/if}} | ||||
</td> | </td> | ||||
<td> | <td> | ||||
<strong>{{{description}}}</strong> | |||||
<strong>{{{description}}}</strong> | |||||
</td> | </td> | ||||
<td><span class="model-signature"></span></td> | <td><span class="model-signature"></span></td> |