@@ -65,7 +65,7 @@ object RouteGenerator {
6565 * Array query string is assumed to be split with comma, i.e. ?q=a,b,c,d
6666 */
6767 def listDecoder (routes : List [RouteDefinition ], indentationLevel : Int ): List [String ] = {
68- val decoder =
68+ val decoder : List [ String ] =
6969 s """ implicit def listDecoder[T](implicit decoder: QueryParamDecoder[T]): QueryParamDecoder[List[T]] =
7070 | QueryParamDecoder[String]
7171 | .map(
@@ -76,20 +76,22 @@ object RouteGenerator {
7676 .toList
7777
7878 if (routes.exists(anyListQueryParameter)) {
79+ decoder.map(`\t` * indentationLevel + _)
80+ } else {
81+ Nil
82+ }
83+ }
7984
80- val refDecoders : List [String ] =
81- routes
82- .flatMap(getEnumQueryParameter)
83- .flatten
84- .flatMap(typeName => enumDecoder(typeName, indentationLevel))
85-
86- if (refDecoders.nonEmpty) {
87- println(" Generating http4s decoders for request references, assuming they all are enums" )
88- val importLine = List (" import org.http4s.QueryParamDecoder.fromUnsafeCast\n " )
89- (importLine ++ refDecoders ++ decoder).map(`\t` * indentationLevel + _)
90- } else {
91- decoder.map(`\t` * indentationLevel + _)
92- }
85+ def enumDecoders (routes : List [RouteDefinition ], indentationLevel : Int ): List [String ] = {
86+ val refDecoders : List [String ] =
87+ routes
88+ .flatMap(getEnumQueryParameter)
89+ .flatten
90+ .flatMap(typeName => enumDecoder(typeName, indentationLevel))
91+ if (refDecoders.nonEmpty) {
92+ println(" Generating http4s decoders for request references, assuming they all are enums" )
93+ val importLine = List (" import org.http4s.QueryParamDecoder.fromUnsafeCast\n " )
94+ (importLine ++ refDecoders).map(`\t` * indentationLevel + _)
9395 } else {
9496 Nil
9597 }
@@ -103,7 +105,7 @@ object RouteGenerator {
103105 *
104106 * @return generated decoder string lines
105107 */
106- def enumDecoder (enumFullTypeName : String , indentationLevel : Int ): List [String ] = {
108+ private def enumDecoder (enumFullTypeName : String , indentationLevel : Int ): List [String ] = {
107109 val typeNameLowerCase = enumFullTypeName.toLowerCase
108110 .split(" \\ ." )
109111 .last
0 commit comments