Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
Fix RamlGenerator for UnreachableStrategy by providing a playJsonForm…
Browse files Browse the repository at this point in the history
…at implicitly using the reader and writer
  • Loading branch information
Jason Gilanfarr authored and Tim Harper committed Feb 22, 2017
1 parent 0f2f5eb commit b263bc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 10 additions & 2 deletions project/RamlTypeGenerator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,18 @@ object RamlTypeGenerator {
Seq(
IMPORT("play.api.libs.json._"),
IMPORT("play.api.libs.functional.syntax._"),
VAL("playJsonReader") withFlags Flags.IMPLICIT := TUPLE(
VAL("playJsonReader") := TUPLE(
actualFields.map(_.playReader).reduce(_ DOT "and" APPLY _)
) APPLY (REF(name) DOT "apply _"),
VAL("playJsonWriter") withFlags Flags.IMPLICIT := REF(PlayJson) DOT "writes" APPLYTYPE (name)
VAL("playJsonWriter") := REF(PlayJson) DOT "writes" APPLYTYPE (name),
OBJECTDEF("playJsonFormat") withParents PLAY_JSON_FORMAT(name) withFlags Flags.IMPLICIT := BLOCK(
DEF("reads", PLAY_JSON_RESULT(name)) withParams PARAM("json", PlayJsValue) := BLOCK(
REF("playJsonReader") DOT "reads" APPLY REF("json")
),
DEF("writes", PlayJsValue) withParams PARAM("o", name) := BLOCK(
REF("playJsonWriter") DOT "writes" APPLY REF("o")
)
)
)
} else if (actualFields.size > 22 || actualFields.exists(f => f.repeated || f.omitEmpty) ||
actualFields.map(_.toString).exists(t => t.toString.startsWith(name) || t.toString.contains(s"[$name]"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ object EndpointsHelper {
}
sb.toString()
}

}

0 comments on commit b263bc4

Please sign in to comment.