From 7741a26b5a69015391d8a7f111ad9170d1f96063 Mon Sep 17 00:00:00 2001 From: Clay Teeter Date: Mon, 11 Mar 2019 11:03:57 +0100 Subject: [PATCH] added JodaTime --- README.md | 1 + build.sbt | 10 ++++++++-- .../com/github/andyglow/jsonschema/SchemaMacro.scala | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b1abd5a6..1959ab78 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Inspired by Coursera Autoschema but uses `Scala Macros` instead of `Java Reflect - `BigDecimal` - `String` - Date Time + - `org.joda.time.DateTime` - `java.util.Date` - `java.sql.Timestamp` - `java.time.Instant` diff --git a/build.sbt b/build.sbt index 6f0e46ee..fa53f138 100644 --- a/build.sbt +++ b/build.sbt @@ -59,7 +59,10 @@ lazy val commonSettings = Seq( releaseCrossBuild := true, - libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % Test + libraryDependencies ++= Seq( + "org.scalatest" %% "scalatest" % "3.0.1" % Test, + "joda-time" % "joda-time" % "2.10.1" + ) ) @@ -89,7 +92,10 @@ lazy val `play-json` = { project in file("play-json") }.dependsOn(core, api).set name := "scala-jsonschema-play-json", - libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.3" + libraryDependencies ++= Seq( + "com.typesafe.play" %% "play-json" % "2.6.3", + "com.typesafe.play" %% "play-json-joda" % "2.6.3", + ) ) lazy val `spray-json` = { project in file("spray-json") }.dependsOn(core, api).settings( diff --git a/macros/src/main/scala/com/github/andyglow/jsonschema/SchemaMacro.scala b/macros/src/main/scala/com/github/andyglow/jsonschema/SchemaMacro.scala index 9d933eae..8847391b 100644 --- a/macros/src/main/scala/com/github/andyglow/jsonschema/SchemaMacro.scala +++ b/macros/src/main/scala/com/github/andyglow/jsonschema/SchemaMacro.scala @@ -3,6 +3,8 @@ package com.github.andyglow.jsonschema import java.net.{URI, URL} import java.util.UUID +import org.joda.time.DateTime + import scala.reflect.macros.blackbox object SchemaMacro { @@ -44,6 +46,7 @@ object SchemaMacro { case x if x =:= typeOf[URI] => q"`string`[$x](Some(`string`.Format.`uri`), None)" // date, date-time + case x if x =:= typeOf[org.joda.time.DateTime] => q"`string`[$x](Some(`string`.Format.`date-time`), None)" case x if x =:= typeOf[java.util.Date] => q"`string`[$x](Some(`string`.Format.`date-time`), None)" case x if x =:= typeOf[java.sql.Timestamp] => q"`string`[$x](Some(`string`.Format.`date-time`), None)" case x if x =:= typeOf[java.time.Instant] => q"`string`[$x](Some(`string`.Format.`date-time`), None)" @@ -53,6 +56,7 @@ object SchemaMacro { case x if x =:= typeOf[java.sql.Time] => q"`string`[$x](Some(`string`.Format.`time`), None)" case x if x =:= typeOf[java.time.LocalTime] => q"`string`[$x](Some(`string`.Format.`time`), None)" + case x if x <:< typeOf[Map[String, _]] => SM.gen(x, stack) case x if x <:< typeOf[Map[Int, _]] => IM.gen(x, stack)