@@ -275,6 +275,20 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
275275 error_free = false ;
276276 }
277277 } ) ;
278+ form . find ( 'select.required' ) . each ( function ( ) {
279+ $ ( this ) . removeClass ( 'error' ) ;
280+ if ( this . selectedIndex === - 1 ) {
281+ $ ( this ) . addClass ( 'error' ) ;
282+ $ ( this ) . wiggle ( {
283+ callback : ( function ( _this ) {
284+ return function ( ) {
285+ $ ( _this ) . focus ( ) ;
286+ } ;
287+ } ) ( this )
288+ } ) ;
289+ error_free = false ;
290+ }
291+ } ) ;
278292 if ( error_free ) {
279293 map = { } ;
280294 opts = {
@@ -295,8 +309,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
295309 ref2 = form . find ( 'textarea' ) ;
296310 for ( m = 0 , len1 = ref2 . length ; m < len1 ; m ++ ) {
297311 o = ref2 [ m ] ;
298- if ( ( o . value !== null ) && jQuery . trim ( o . value ) . length > 0 ) {
299- map [ o . name ] = o . value ;
312+ val = this . getTextAreaValue ( o ) ;
313+ if ( ( val !== null ) && jQuery . trim ( val ) . length > 0 ) {
314+ map [ o . name ] = val ;
300315 }
301316 }
302317 ref3 = form . find ( 'select' ) ;
@@ -661,5 +676,38 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
661676 } else {
662677 Docs . expandOperation ( elem ) ;
663678 }
679+ } ,
680+
681+ getTextAreaValue : function ( textArea ) {
682+ var param , parsed , result , i ;
683+ if ( textArea . value === null || jQuery . trim ( textArea . value ) . length === 0 ) {
684+ return null ;
685+ }
686+ param = this . getParamByName ( textArea . name ) ;
687+ if ( param && param . type && param . type . toLowerCase ( ) === 'array' ) {
688+ parsed = textArea . value . split ( '\n' ) ;
689+ result = [ ] ;
690+ for ( i = 0 ; i < parsed . length ; i ++ ) {
691+ if ( parsed [ i ] !== null && jQuery . trim ( parsed [ i ] ) . length > 0 ) {
692+ result . push ( parsed [ i ] ) ;
693+ }
694+ }
695+ return result . length > 0 ? result : null ;
696+ } else {
697+ return textArea . value ;
698+ }
699+ } ,
700+
701+ getParamByName : function ( name ) {
702+ var i ;
703+ if ( this . model . parameters ) {
704+ for ( i = 0 ; i < this . model . parameters . length ; i ++ ) {
705+ if ( this . model . parameters [ i ] . name === name ) {
706+ return this . model . parameters [ i ] ;
707+ }
708+ }
709+ }
710+ return null ;
664711 }
712+
665713} ) ;
0 commit comments