Skip to content

Commit a9c2b91

Browse files
committed
1 parent 116b487 commit a9c2b91

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

lib/swagger-client.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ SwaggerClient.prototype.initialize = function (url, options) {
325325

326326
if (typeof options.success === 'function') {
327327
this.build();
328-
// this.isBuilt = true;
329328
}
330329
};
331330

@@ -1214,7 +1213,6 @@ Model.prototype.getMockSignature = function(modelsToIgnore) {
12141213
prop = this.properties[i];
12151214
propertiesStr.push(prop.toString());
12161215
}
1217-
12181216
var strong = '<span class="strong">';
12191217
var stronger = '<span class="stronger">';
12201218
var strongClose = '</span>';
@@ -1326,8 +1324,10 @@ Property.prototype.sampleValue = function(isArray, ignoredModels) {
13261324

13271325
getStringSignature = function(obj) {
13281326
var str = '';
1329-
if(typeof obj.type === 'undefined')
1330-
str += obj;
1327+
if(typeof obj.$ref !== 'undefined')
1328+
str += simpleRef(obj.$ref);
1329+
else if(typeof obj.type === 'undefined')
1330+
str += 'object';
13311331
else if(obj.type === 'array') {
13321332
str += 'Array[';
13331333
str += getStringSignature((obj.items || obj.$ref || {}));
@@ -1383,9 +1383,27 @@ Property.prototype.toString = function() {
13831383
if(typeof this.description !== 'undefined')
13841384
str += ': ' + this.description;
13851385

1386+
if (this['enum']) {
1387+
str += ' = <span class="propVals">[\'' + this['enum'].join('\' or \'') + '\']</span>';
1388+
}
1389+
if (this.descr) {
1390+
str += ': <span class="propDesc">' + this.descr + '</span>';
1391+
}
1392+
1393+
13861394
var options = '';
13871395
var isArray = this.schema.type === 'array';
1388-
var type = isArray ? this.schema.items.type : this.schema.type;
1396+
var type;
1397+
1398+
if(isArray) {
1399+
if(this.schema.items)
1400+
type = this.schema.items.type;
1401+
else
1402+
type = '';
1403+
}
1404+
else {
1405+
this.schema.type;
1406+
}
13891407

13901408
if (this.default)
13911409
options += optionHtml('Default', this.default);
@@ -1973,7 +1991,7 @@ SwaggerModelProperty.prototype.toString = function () {
19731991
}
19741992
str += ')';
19751993
if (this.values) {
1976-
str += ' = <span class="propVals">["' + this.values.join('\' or \'') + '\']</span>';
1994+
str += ' = <span class="propVals">[\'' + this.values.join('\' or \'') + '\']</span>';
19771995
}
19781996
if (this.descr) {
19791997
str += ': <span class="propDesc">' + this.descr + '</span>';

src/main/coffeescript/view/OperationView.coffee

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,14 @@ class OperationView extends Backbone.View
9191
if typeof @model.responseMessages is 'undefined'
9292
@model.responseMessages = []
9393

94-
$(@el).html(Handlebars.templates.operation(@model))
95-
9694
# 2.0
9795
signatureModel = null
9896
if @model.successResponse
9997
successResponse = @model.successResponse
10098
for key of successResponse
10199
value = successResponse[key]
100+
@model.successCode = key
102101
if typeof value is 'object' and typeof value.createJSONSample is 'function'
103-
foo = 'bar'
104102
signatureModel =
105103
sampleJSON: JSON.stringify(value.createJSONSample(), undefined, 2)
106104
isParam: false
@@ -112,6 +110,9 @@ class OperationView extends Backbone.View
112110
isParam: false
113111
signature: @model.responseClassSignature
114112

113+
114+
$(@el).html(Handlebars.templates.operation(@model))
115+
115116
if signatureModel
116117
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
117118
$('.model-signature', $(@el)).append responseSignatureView.render().el

src/main/template/operation.handlebars

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242
{{/oauth}}
4343
{{#if type}}
44-
<h4>Response Class</h4>
44+
<h4>Response Class (Status {{successCode}})</h4>
4545
<p><span class="model-signature" /></p>
4646
<br/>
4747
<div class="response-content-type" />

0 commit comments

Comments
 (0)