Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1bffc8fb4 | ||
|
|
55f0c1a2f8 | ||
|
|
03e21019d2 | ||
|
|
75fd46ef21 | ||
|
|
75ff471425 | ||
|
|
dd1b2219b8 | ||
|
|
f5cfee8296 | ||
|
|
a1337cf118 | ||
|
|
2bc67cbcae | ||
|
|
30886478d4 | ||
|
|
fc320397e9 |
@@ -11,6 +11,7 @@ sourceFiles = [
|
||||
'view/StatusCodeView'
|
||||
'view/ParameterView'
|
||||
'view/SignatureView'
|
||||
'view/ContentTypeView'
|
||||
]
|
||||
|
||||
|
||||
|
||||
+7
-4
@@ -255,7 +255,7 @@
|
||||
_results = [];
|
||||
for (_i = 0, _len = ops.length; _i < _len; _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;
|
||||
_results.push(this.operationsArray.push(op));
|
||||
}
|
||||
@@ -413,7 +413,7 @@
|
||||
|
||||
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,
|
||||
_this = this;
|
||||
this.nickname = nickname;
|
||||
@@ -425,6 +425,7 @@
|
||||
this.responseClass = responseClass;
|
||||
this.errorResponses = errorResponses;
|
||||
this.resource = resource;
|
||||
this.supportedContentTypes = supportedContentTypes;
|
||||
this["do"] = __bind(this["do"], this);
|
||||
|
||||
if (this.nickname == null) {
|
||||
@@ -445,6 +446,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;
|
||||
@@ -562,7 +564,7 @@
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
|
||||
var param, queryParams, url, _i, _len, _ref;
|
||||
var param, queryParams, reg, url, _i, _len, _ref;
|
||||
if (includeApiKey == null) {
|
||||
includeApiKey = true;
|
||||
}
|
||||
@@ -572,7 +574,8 @@
|
||||
param = _ref[_i];
|
||||
if (param.paramType === 'path') {
|
||||
if (args[param.name]) {
|
||||
url = url.replace("{" + param.name + "}", encodeURIComponent(args[param.name]));
|
||||
reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
||||
url = url.replace(reg, encodeURIComponent(args[param.name]));
|
||||
delete args[param.name];
|
||||
} else {
|
||||
throw "" + param.name + " is a required path param.";
|
||||
|
||||
@@ -14,6 +14,24 @@ 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)
|
||||
|
||||
contentTypeModel =
|
||||
isParam: false
|
||||
supportedContentTypes: @model.supportedContentTypes
|
||||
|
||||
contentTypeView = new ContentTypeView({model: contentTypeModel})
|
||||
$('.content-type', $(@el)).append contentTypeView.render().el
|
||||
|
||||
# Render each parameter
|
||||
@addParameter param for param in @model.parameters
|
||||
|
||||
@@ -106,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 = 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)
|
||||
false
|
||||
# $.getJSON(invocationUrl, (r) => @showResponse(r)).complete((r) => @showCompleteStatus(r)).error (r) => @showErrorStatus(r)
|
||||
|
||||
@@ -8,11 +8,23 @@ 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'})
|
||||
$('.model-signature', $(@el)).append signatureView.render().el
|
||||
signatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
||||
$('.model-signature', $(@el)).append signatureView.render().el
|
||||
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
|
||||
|
||||
@
|
||||
|
||||
|
||||
@@ -11,4 +11,4 @@ class ResourceView extends Backbone.View
|
||||
addOperation: (operation) ->
|
||||
# Render an operation and add it to operations li
|
||||
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
|
||||
$('.endpoints', $(@el)).append operationView.render().el
|
||||
$('.endpoints', $(@el)).append operationView.render().el
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1579,3 +1579,12 @@ body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operatio
|
||||
pre code {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.content > .content-type > div > label {
|
||||
clear: both;
|
||||
display: block;
|
||||
color: #0F6AB4;
|
||||
font-size: 1.1em;
|
||||
margin: 0;
|
||||
padding: 15px 0 5px 0px;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,11 @@
|
||||
<p>{{{notes}}}</p>
|
||||
{{/if}}
|
||||
{{#if responseClass}}
|
||||
<h4>Response Class</h4>
|
||||
{{#if responseClassSignature}}
|
||||
<p><span class="model-signature">{{{responseClassSignature}}}</span></p>
|
||||
{{else}}
|
||||
<p>{{{responseClass}}}</p>
|
||||
{{/if}}
|
||||
<h4>Response Model</h4>
|
||||
<span class="model-signature"></span>
|
||||
{{/if}}
|
||||
<br/>
|
||||
<div class="content-type" />
|
||||
<form accept-charset='UTF-8' class='sandbox'>
|
||||
<div style='margin:0;padding:0;display:inline'></div>
|
||||
<h4>Parameters</h4>
|
||||
|
||||
@@ -8,20 +8,22 @@
|
||||
{{#if defaultValue}}
|
||||
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
|
||||
{{else}}
|
||||
<textarea class='body-textarea' name='{{name}}'></textarea>
|
||||
<textarea class='body-textarea' name='{{name}}'></textarea>
|
||||
<br />
|
||||
<div class="content-type" />
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
<input minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
|
||||
{{else}}
|
||||
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
|
||||
<input minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
</td>
|
||||
<td>{{{description}}}</td>
|
||||
<td>
|
||||
<span class="model-signature"></span>
|
||||
<span class="model-signature"></span>
|
||||
</td>
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
{{#if defaultValue}}
|
||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea>
|
||||
{{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}}
|
||||
{{else}}
|
||||
@@ -15,14 +17,14 @@
|
||||
<input class='required' type='file' name='{{name}}'/>
|
||||
{{else}}
|
||||
{{#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}}
|
||||
<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}}
|
||||
</td>
|
||||
<td>
|
||||
<strong>{{{description}}}</strong>
|
||||
<strong>{{{description}}}</strong>
|
||||
</td>
|
||||
<td><span class="model-signature"></span></td>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div>
|
||||
<ul class="signature-nav">
|
||||
<li><a class="description-link" href="#">Description</a></li>
|
||||
<li><a class="snippet-link" href="#">Snippet</a></li>
|
||||
<li><a class="description-link" href="#">Model</a></li>
|
||||
<li><a class="snippet-link" href="#">Example JSON</a></li>
|
||||
</ul>
|
||||
<div>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<div class="snippet">
|
||||
<pre><code>{{sampleJSON}}</code></pre>
|
||||
<small>Click to set as parameter value</small>
|
||||
<small class="notice"></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user