@@ -240,21 +240,19 @@ object SwaggerSerializers extends Serializers {
240240 (" authorizations" -> {
241241 x.authorizations match {
242242 case e : List [Authorization ] if (e.size > 0 ) => {
243- Extraction .decompose({
244- var open = false
245- val o = ((for (at <- e) yield {
246- if (at.`type` == " open" ) {
247- open = true
248- None
249- }
250- else if (at.`type` != " " ){
251- val out : Option [Tuple2 [String , Authorization ]] = Some (at.`type`, at)
252- out
253- }
254- else
255- None
256- }).flatten.toMap)
257- })
243+ var open = false
244+ val o = ((for (at <- e) yield {
245+ if (at.`type` == " open" ) {
246+ open = true
247+ None
248+ }
249+ else if (at.`type` != " " )
250+ Some (at.`type`, at)
251+ else
252+ None
253+ }).flatten.toMap)
254+ if (o.size > 0 || open) Extraction .decompose(o)
255+ else JNothing
258256 }
259257 case _ => JNothing
260258 }
@@ -503,9 +501,9 @@ trait Serializers {
503501 }) ~
504502 (" authorizations" -> {
505503 x.authorizations match {
506- case e : List [Authorization ] if (e.size > 0 ) => {
507- Extraction .decompose((for (at : Authorization <- e) yield {
508- if (at.`type` != " " ) Some (at.`type` , at)
504+ case e : List [AuthorizationType ] if (e.size > 0 ) => {
505+ Extraction .decompose((for (at <- e) yield {
506+ if (at.`type` != " " ) Some (at.getName , at)
509507 else None
510508 }).flatten.toMap)
511509 }
@@ -563,8 +561,8 @@ trait Serializers {
563561 (" authorizations" -> {
564562 x.authorizations match {
565563 case e : List [AuthorizationType ] if (e.size > 0 ) => {
566- Extraction .decompose((for (at : AuthorizationType <- e) yield {
567- if (at.`type` != " " ) Some (at.`type` , at)
564+ Extraction .decompose((for (at <- e) yield {
565+ if (at.`type` != " " ) Some (at.getName , at)
568566 else None
569567 }).flatten.toMap)
570568 }
@@ -754,14 +752,13 @@ trait Serializers {
754752 }) ~
755753 (" authorizations" -> {
756754 x.authorizations match {
757- case e : List [Authorization ] if (e.size > 0 ) => {
758- val out = (for (at : Authorization <- e) yield {
759- if (at.`type` != " " ) {
760- Some (at.`type`, at)
761- }
762- else None
763- }).flatten.toMap
764- Extraction .decompose(out)
755+ case e : List [AuthorizationType ] if (e.size > 0 ) => {
756+ Extraction .decompose((for (at <- e) yield {
757+ if (at.getName != " " ) {
758+ Some (at.getName, at)
759+ }
760+ else None
761+ }).flatten.toMap)
765762 }
766763 case _ => JNothing
767764 }
@@ -944,7 +941,7 @@ trait Serializers {
944941
945942 class AuthorizationTypeSerializer extends CustomSerializer [AuthorizationType ](formats => ({
946943 case json =>
947- implicit val fmts : Formats = formats
944+ implicit val fmts = formats
948945 json \ " type" match {
949946 case JString (x) if x.equalsIgnoreCase(" oauth2" ) => {
950947 OAuth ((json \ " scopes" ).extractOrElse(List ()),
@@ -986,7 +983,7 @@ trait Serializers {
986983 }, {
987984 case x : Authorization =>
988985 implicit val fmts = formats
989- Extraction .decompose(x.scopes)
986+ Extraction .decompose(x.scopes.filter(_.scope != " " ) )
990987 }
991988 ))
992989
0 commit comments