Skip to content

Commit

Permalink
fix for swagger-api#640
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Feb 1, 2015
1 parent 116b487 commit a9c2b91
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
30 changes: 24 additions & 6 deletions lib/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ SwaggerClient.prototype.initialize = function (url, options) {

if (typeof options.success === 'function') {
this.build();
// this.isBuilt = true;
}
};

Expand Down Expand Up @@ -1214,7 +1213,6 @@ Model.prototype.getMockSignature = function(modelsToIgnore) {
prop = this.properties[i];
propertiesStr.push(prop.toString());
}

var strong = '<span class="strong">';
var stronger = '<span class="stronger">';
var strongClose = '</span>';
Expand Down Expand Up @@ -1326,8 +1324,10 @@ Property.prototype.sampleValue = function(isArray, ignoredModels) {

getStringSignature = function(obj) {
var str = '';
if(typeof obj.type === 'undefined')
str += obj;
if(typeof obj.$ref !== 'undefined')
str += simpleRef(obj.$ref);
else if(typeof obj.type === 'undefined')
str += 'object';
else if(obj.type === 'array') {
str += 'Array[';
str += getStringSignature((obj.items || obj.$ref || {}));
Expand Down Expand Up @@ -1383,9 +1383,27 @@ Property.prototype.toString = function() {
if(typeof this.description !== 'undefined')
str += ': ' + this.description;

if (this['enum']) {
str += ' = <span class="propVals">[\'' + this['enum'].join('\' or \'') + '\']</span>';
}
if (this.descr) {
str += ': <span class="propDesc">' + this.descr + '</span>';
}


var options = '';
var isArray = this.schema.type === 'array';
var type = isArray ? this.schema.items.type : this.schema.type;
var type;

if(isArray) {
if(this.schema.items)
type = this.schema.items.type;
else
type = '';
}
else {
this.schema.type;
}

if (this.default)
options += optionHtml('Default', this.default);
Expand Down Expand Up @@ -1973,7 +1991,7 @@ SwaggerModelProperty.prototype.toString = function () {
}
str += ')';
if (this.values) {
str += ' = <span class="propVals">["' + this.values.join('\' or \'') + '\']</span>';
str += ' = <span class="propVals">[\'' + this.values.join('\' or \'') + '\']</span>';
}
if (this.descr) {
str += ': <span class="propDesc">' + this.descr + '</span>';
Expand Down
7 changes: 4 additions & 3 deletions src/main/coffeescript/view/OperationView.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,14 @@ class OperationView extends Backbone.View
if typeof @model.responseMessages is 'undefined'
@model.responseMessages = []

$(@el).html(Handlebars.templates.operation(@model))

# 2.0
signatureModel = null
if @model.successResponse
successResponse = @model.successResponse
for key of successResponse
value = successResponse[key]
@model.successCode = key
if typeof value is 'object' and typeof value.createJSONSample is 'function'
foo = 'bar'
signatureModel =
sampleJSON: JSON.stringify(value.createJSONSample(), undefined, 2)
isParam: false
Expand All @@ -112,6 +110,9 @@ class OperationView extends Backbone.View
isParam: false
signature: @model.responseClassSignature


$(@el).html(Handlebars.templates.operation(@model))

if signatureModel
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
$('.model-signature', $(@el)).append responseSignatureView.render().el
Expand Down
2 changes: 1 addition & 1 deletion src/main/template/operation.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
{{/oauth}}
{{#if type}}
<h4>Response Class</h4>
<h4>Response Class (Status {{successCode}})</h4>
<p><span class="model-signature" /></p>
<br/>
<div class="response-content-type" />
Expand Down

0 comments on commit a9c2b91

Please sign in to comment.