Skip to content

Commit 53f6824

Browse files
committed
Merge pull request #224 from swagger-api/ui-issue-898
fix for swagger-api/swagger-ui#898, exposing p...
2 parents 00fa8b0 + ef54d2b commit 53f6824

File tree

5 files changed

+33
-19
lines changed

5 files changed

+33
-19
lines changed

lib/swagger-client.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* swagger-client - swagger.js is a javascript client for use with swaggering APIs.
3-
* @version v2.1.0-M1
3+
* @version v2.1.1-M1
44
* @link http://swagger.io
55
* @license apache 2.0
66
*/
@@ -614,13 +614,15 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
614614
param.allowableValues.descriptiveValues.push({value : value, isDefault: isDefault});
615615
}
616616
}
617-
if(param.type === 'array' && typeof param.allowableValues === 'undefined') {
618-
// can't show as a list if no values to select from
619-
delete param.isList;
620-
delete param.allowMultiple;
617+
if(param.type === 'array') {
621618
innerType = [innerType];
619+
if(typeof param.allowableValues === 'undefined') {
620+
// can't show as a list if no values to select from
621+
delete param.isList;
622+
delete param.allowMultiple;
623+
}
622624
}
623-
param.signature = this.getModelSignature(innerType, models);
625+
param.signature = this.getModelSignature(innerType, models).toString();
624626
param.sampleJSON = this.getModelSampleJSON(innerType, models);
625627
param.responseClassSignature = param.signature;
626628
}
@@ -772,16 +774,21 @@ Operation.prototype.getModelSignature = function(type, definitions) {
772774
listType = true;
773775
type = type[0];
774776
}
777+
else if(typeof type === 'undefined')
778+
type = 'undefined';
775779

776780
if(type === 'string')
777781
isPrimitive = true;
778782
else
779783
isPrimitive = (listType && definitions[listType]) || (definitions[type]) ? false : true;
780784
if (isPrimitive) {
781-
return type;
785+
if(listType)
786+
return 'Array[' + type + ']';
787+
else
788+
return type.toString();
782789
} else {
783790
if (listType)
784-
return definitions[type].getMockSignature();
791+
return 'Array[' + definitions[type].getMockSignature() + ']';
785792
else
786793
return definitions[type].getMockSignature();
787794
}

lib/swagger-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "swagger-client",
33
"author": "Tony Tam <[email protected]>",
44
"description": "swagger.js is a javascript client for use with swaggering APIs.",
5-
"version": "2.1.0-M1",
5+
"version": "2.1.1-M1",
66
"homepage": "http://swagger.io",
77
"repository": {
88
"type": "git",

src/js/swagger-a.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,13 +332,15 @@ var Operation = function(parent, scheme, operationId, httpMethod, path, args, de
332332
param.allowableValues.descriptiveValues.push({value : value, isDefault: isDefault});
333333
}
334334
}
335-
if(param.type === 'array' && typeof param.allowableValues === 'undefined') {
336-
// can't show as a list if no values to select from
337-
delete param.isList;
338-
delete param.allowMultiple;
335+
if(param.type === 'array') {
339336
innerType = [innerType];
337+
if(typeof param.allowableValues === 'undefined') {
338+
// can't show as a list if no values to select from
339+
delete param.isList;
340+
delete param.allowMultiple;
341+
}
340342
}
341-
param.signature = this.getModelSignature(innerType, models);
343+
param.signature = this.getModelSignature(innerType, models).toString();
342344
param.sampleJSON = this.getModelSampleJSON(innerType, models);
343345
param.responseClassSignature = param.signature;
344346
}
@@ -490,16 +492,21 @@ Operation.prototype.getModelSignature = function(type, definitions) {
490492
listType = true;
491493
type = type[0];
492494
}
495+
else if(typeof type === 'undefined')
496+
type = 'undefined';
493497

494498
if(type === 'string')
495499
isPrimitive = true;
496500
else
497501
isPrimitive = (listType && definitions[listType]) || (definitions[type]) ? false : true;
498502
if (isPrimitive) {
499-
return type;
503+
if(listType)
504+
return 'Array[' + type + ']';
505+
else
506+
return type.toString();
500507
} else {
501508
if (listType)
502-
return definitions[type].getMockSignature();
509+
return 'Array[' + definitions[type].getMockSignature() + ']';
503510
else
504511
return definitions[type].getMockSignature();
505512
}

test/operation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ describe('operations', function() {
238238
{ in: 'query', name: 'year', type: 'array', items: {type: 'string'} }
239239
];
240240
var op = new swagger.Operation({}, 'http', 'test', 'get', '/fantastic', { parameters: parameters });
241-
expect(op.parameters[0].signature).toEqual(['string']);
241+
expect(op.parameters[0].signature).toEqual('Array[string]');
242242
});
243243

244244
it('should get a date array signature', function() {
245245
var parameters = [
246246
{ in: 'query', name: 'year', type: 'array', items: {type: 'string', format: 'date-time'} }
247247
];
248248
var op = new swagger.Operation({}, 'http', 'test', 'get', '/fantastic', { parameters: parameters });
249-
expect(op.parameters[0].signature).toEqual(['date-time']);
249+
expect(op.parameters[0].signature).toEqual('Array[date-time]');
250250
});
251251
});
252252

0 commit comments

Comments
 (0)