11/**
22 * swagger-client - swagger.js is a javascript client for use with swaggering APIs.
3- * @version v2.1.3 -M1
3+ * @version v2.1.5 -M1
44 * @link http://swagger.io
55 * @license apache 2.0
66 */
@@ -57,10 +57,31 @@ ArrayModel.prototype.getSampleValue = function(modelsToIgnore) {
5757
5858ArrayModel . prototype . getMockSignature = function ( modelsToIgnore ) {
5959 var propertiesStr = [ ] ;
60+ var i , prop ;
61+ for ( i = 0 ; i < this . properties . length ; i ++ ) {
62+ prop = this . properties [ i ] ;
63+ propertiesStr . push ( prop . toString ( ) ) ;
64+ }
6065
61- if ( this . ref ) {
62- return models [ simpleRef ( this . ref ) ] . getMockSignature ( ) ;
66+ var strong = '<span class="strong">' ;
67+ var stronger = '<span class="stronger">' ;
68+ var strongClose = '</span>' ;
69+ var classOpen = strong + 'array' + ' {' + strongClose ;
70+ var classClose = strong + '}' + strongClose ;
71+ var returnVal = classOpen + '<div>' + propertiesStr . join ( ',</div><div>' ) + '</div>' + classClose ;
72+
73+ if ( ! modelsToIgnore )
74+ modelsToIgnore = { } ;
75+ modelsToIgnore [ this . name ] = this ;
76+ for ( i = 0 ; i < this . properties . length ; i ++ ) {
77+ prop = this . properties [ i ] ;
78+ var ref = prop . $ref ;
79+ var model = models [ ref ] ;
80+ if ( model && typeof modelsToIgnore [ ref ] === 'undefined' ) {
81+ returnVal = returnVal + ( '<br>' + model . getMockSignature ( modelsToIgnore ) ) ;
82+ }
6383 }
84+ return returnVal ;
6485} ;
6586
6687
@@ -336,6 +357,7 @@ SwaggerClient.prototype.initialize = function (url, options) {
336357 this . options = options ;
337358
338359 if ( typeof options . success === 'function' ) {
360+ this . ready = true ;
339361 this . build ( ) ;
340362 }
341363} ;
@@ -411,8 +433,16 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
411433 // legacy support
412434 this . authSchemes = response . securityDefinitions ;
413435
414- var location ;
436+ var definedTags = { } ;
437+ if ( Array . isArray ( response . tags ) ) {
438+ definedTags = { } ;
439+ for ( k = 0 ; k < response . tags . length ; k ++ ) {
440+ var t = response . tags [ k ] ;
441+ definedTags [ t . name ] = t ;
442+ }
443+ }
415444
445+ var location ;
416446 if ( typeof this . url === 'string' ) {
417447 location = this . parseUri ( this . url ) ;
418448 }
@@ -478,8 +508,13 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
478508 operationGroup . operations = { } ;
479509 operationGroup . label = tag ;
480510 operationGroup . apis = [ ] ;
511+ var tagObject = definedTags [ tag ] ;
512+ if ( typeof tagObject === 'object' ) {
513+ operationGroup . description = tagObject . description ;
514+ operationGroup . externalDocs = tagObject . externalDocs ;
515+ }
481516 this [ tag ] . help = this . help . bind ( operationGroup ) ;
482- this . apisArray . push ( new OperationGroup ( tag , operationObject ) ) ;
517+ this . apisArray . push ( new OperationGroup ( tag , operationGroup . description , operationGroup . externalDocs , operationObject ) ) ;
483518 }
484519 operationGroup [ operationId ] = operationObject . execute . bind ( operationObject ) ;
485520 operationGroup [ operationId ] . help = operationObject . help . bind ( operationObject ) ;
@@ -548,14 +583,14 @@ SwaggerClient.prototype.fail = function(message) {
548583 throw message ;
549584} ;
550585
551- var OperationGroup = function ( tag , operation ) {
586+ var OperationGroup = function ( tag , description , externalDocs , operation ) {
552587 this . tag = tag ;
553588 this . path = tag ;
589+ this . description = description ;
590+ this . externalDocs = externalDocs ;
554591 this . name = tag ;
555592 this . operation = operation ;
556593 this . operationsArray = [ ] ;
557-
558- this . description = operation . description || "" ;
559594} ;
560595
561596var Operation = function ( parent , scheme , operationId , httpMethod , path , args , definitions ) {
@@ -720,10 +755,14 @@ Operation.prototype.getType = function (param) {
720755 str = 'long' ;
721756 else if ( type === 'integer' )
722757 str = 'integer' ;
723- else if ( type === 'string' && format === 'date-time' )
724- str = 'date-time' ;
725- else if ( type === 'string' && format === 'date' )
726- str = 'date' ;
758+ else if ( type === 'string' ) {
759+ if ( format === 'date-time' )
760+ str = 'date-time' ;
761+ else if ( format === 'date' )
762+ str = 'date' ;
763+ else
764+ str = 'string' ;
765+ }
727766 else if ( type === 'number' && format === 'float' )
728767 str = 'float' ;
729768 else if ( type === 'number' && format === 'double' )
@@ -732,8 +771,6 @@ Operation.prototype.getType = function (param) {
732771 str = 'double' ;
733772 else if ( type === 'boolean' )
734773 str = 'boolean' ;
735- else if ( type === 'string' )
736- str = 'string' ;
737774 else if ( type === 'array' ) {
738775 isArray = true ;
739776 if ( param . items )
@@ -1028,14 +1065,13 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
10281065 if ( opts . mock === true )
10291066 return obj ;
10301067 else
1031- new SwaggerHttp ( ) . execute ( obj ) ;
1068+ new SwaggerHttp ( ) . execute ( obj , opts ) ;
10321069} ;
10331070
10341071Operation . prototype . setContentTypes = function ( args , opts ) {
10351072 // default type
10361073 var accepts = 'application/json' ;
10371074 var consumes = args . parameterContentType || 'application/json' ;
1038-
10391075 var allDefinedParams = this . parameters ;
10401076 var definedFormParams = [ ] ;
10411077 var definedFileParams = [ ] ;
@@ -1288,7 +1324,7 @@ var Property = function(name, obj, required) {
12881324 this . optional = true ;
12891325 this . optional = ! required ;
12901326 this . default = obj . default || null ;
1291- this . example = obj . example || null ;
1327+ this . example = obj . example !== undefined ? obj . example : null ;
12921328 this . collectionFormat = obj . collectionFormat || null ;
12931329 this . maximum = obj . maximum || null ;
12941330 this . exclusiveMaximum = obj . exclusiveMaximum || null ;
@@ -1591,6 +1627,7 @@ SwaggerClient.prototype.buildFrom1_2Spec = function (response) {
15911627SwaggerClient . prototype . finish = function ( ) {
15921628 if ( typeof this . success === 'function' ) {
15931629 this . isValid = true ;
1630+ this . ready = true ;
15941631 this . isBuilt = true ;
15951632 this . selfReflect ( ) ;
15961633 this . success ( ) ;
@@ -2356,7 +2393,7 @@ SwaggerOperation.prototype.urlify = function (args) {
23562393 if ( param . paramType === 'path' ) {
23572394 if ( typeof args [ param . name ] !== 'undefined' ) {
23582395 // apply path params and remove from args
2359- var reg = new RegExp ( '\\{\\s*?' + param . name + '.*?\\}(?=\\s*? (\\/?|$))' , 'gi' ) ;
2396+ var reg = new RegExp ( '\\{\\s*?' + param . name + '[^\\{\\}\\/]*(?:\\{ .*?\\}[^\\{\\}\\/]*)*\\}(?= (\\/?|$))' , 'gi' ) ;
23602397 url = url . replace ( reg , this . encodePathParam ( args [ param . name ] ) ) ;
23612398 delete args [ param . name ] ;
23622399 }
@@ -2724,7 +2761,7 @@ SwaggerRequest.prototype.setHeaders = function (params, opts, operation) {
27242761 */
27252762var SwaggerHttp = function ( ) { } ;
27262763
2727- SwaggerHttp . prototype . execute = function ( obj ) {
2764+ SwaggerHttp . prototype . execute = function ( obj , opts ) {
27282765 if ( obj && ( typeof obj . useJQuery === 'boolean' ) )
27292766 this . useJQuery = obj . useJQuery ;
27302767 else
@@ -2735,9 +2772,9 @@ SwaggerHttp.prototype.execute = function(obj) {
27352772 }
27362773
27372774 if ( this . useJQuery )
2738- return new JQueryHttpClient ( ) . execute ( obj ) ;
2775+ return new JQueryHttpClient ( opts ) . execute ( obj ) ;
27392776 else
2740- return new ShredHttpClient ( ) . execute ( obj ) ;
2777+ return new ShredHttpClient ( opts ) . execute ( obj ) ;
27412778} ;
27422779
27432780SwaggerHttp . prototype . isIE8 = function ( ) {
@@ -2845,8 +2882,8 @@ JQueryHttpClient.prototype.execute = function(obj) {
28452882/*
28462883 * ShredHttpClient is a light-weight, node or browser HTTP client
28472884 */
2848- var ShredHttpClient = function ( options ) {
2849- this . options = ( options || { } ) ;
2885+ var ShredHttpClient = function ( opts ) {
2886+ this . opts = ( opts || { } ) ;
28502887 this . isInitialized = false ;
28512888
28522889 var identity , toString ;
@@ -2857,7 +2894,7 @@ var ShredHttpClient = function(options) {
28572894 }
28582895 else
28592896 this . Shred = require ( "shred" ) ;
2860- this . shred = new this . Shred ( options ) ;
2897+ this . shred = new this . Shred ( opts ) ;
28612898} ;
28622899
28632900ShredHttpClient . prototype . initShred = function ( ) {
0 commit comments