Skip to content

Commit

Permalink
Remove joda-time
Browse files Browse the repository at this point in the history
  • Loading branch information
shimamoto committed Nov 19, 2018
1 parent 4d673d8 commit 8f419ca
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
2 changes: 0 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ lazy val scalatraSwagger = Project(
base = file("swagger")).settings(
scalatraSettings ++ Seq(
libraryDependencies ++= Seq(
jodaTime,
jodaConvert,
json4sExt,
parserCombinators,
logbackClassic % "provided"
Expand Down
2 changes: 0 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ object Dependencies {
lazy val jettyServlet = "org.eclipse.jetty" % "jetty-servlet" % jettyVersion
lazy val jettyWebsocket = "org.eclipse.jetty.websocket" %"websocket-server" % jettyVersion
lazy val jettyWebapp = "org.eclipse.jetty" % "jetty-webapp" % jettyVersion
lazy val jodaConvert = "org.joda" % "joda-convert" % "2.1.2"
lazy val jodaTime = "joda-time" % "joda-time" % "2.10"
lazy val json4sCore = "org.json4s" %% "json4s-core" % json4sVersion
lazy val json4sExt = "org.json4s" %% "json4s-ext" % json4sVersion
lazy val json4sJackson = "org.json4s" %% "json4s-jackson" % json4sVersion
Expand Down
17 changes: 9 additions & 8 deletions swagger/src/main/scala/org/scalatra/swagger/Swagger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import java.lang.reflect.Field
import java.util.concurrent.ConcurrentHashMap
import java.util.{ Date => JDate }

import org.joda.time._
import org.json4s._
import org.scalatra.swagger.reflect._
import org.scalatra.swagger.runtime.annotations.{ ApiModel, ApiModelProperty }
Expand Down Expand Up @@ -49,11 +48,13 @@ object Swagger {
val excludes: Set[java.lang.reflect.Type] = Set(
classOf[java.util.TimeZone],
classOf[java.util.Date],
classOf[DateTime],
classOf[LocalDate],
classOf[ReadableInstant],
classOf[Chronology],
classOf[DateTimeZone])
classOf[java.time.OffsetDateTime],
classOf[java.time.ZonedDateTime],
classOf[java.time.LocalDateTime],
classOf[java.time.LocalDate],
classOf[java.time.Instant],
classOf[java.time.chrono.Chronology],
classOf[java.time.ZoneOffset])
val SpecVersion = "2.0"

def collectModels[T: Manifest](alreadyKnown: Set[Model]): Set[Model] = collectModels(Reflector.scalaTypeOf[T], alreadyKnown)
Expand Down Expand Up @@ -373,10 +374,10 @@ object DataType {
private[this] def isDecimal(klass: Class[_]) = DecimalTypes contains klass

private[this] val DateTypes =
Set[Class[_]](classOf[LocalDate], classOf[java.time.LocalDate])
Set[Class[_]](classOf[java.time.LocalDate])
private[this] def isDate(klass: Class[_]) = DateTypes.exists(_.isAssignableFrom(klass))
private[this] val DateTimeTypes =
Set[Class[_]](classOf[JDate], classOf[DateTime], classOf[LocalDateTime], classOf[java.time.LocalDateTime], classOf[java.time.ZonedDateTime], classOf[java.time.OffsetDateTime])
Set[Class[_]](classOf[JDate], classOf[java.time.LocalDateTime], classOf[java.time.ZonedDateTime], classOf[java.time.OffsetDateTime])
private[this] def isDateTime(klass: Class[_]) = DateTimeTypes.exists(_.isAssignableFrom(klass))

private[this] def isCollection(klass: Class[_]) =
Expand Down
4 changes: 0 additions & 4 deletions swagger/src/main/scala/org/scalatra/swagger/SwaggerAuth.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.scalatra
package swagger

import org.joda.time._
import org.joda.time.format.ISODateTimeFormat
import org.json4s._
import org.scalatra.auth.ScentrySupport
import org.scalatra.swagger.DataType.ValueDataType
Expand Down Expand Up @@ -83,8 +81,6 @@ object AuthApi {

import org.scalatra.swagger.SwaggerSupportSyntax.SwaggerOperationBuilder

lazy val Iso8601Date = ISODateTimeFormat.dateTime.withZone(DateTimeZone.UTC)

trait SwaggerAuthOperationBuilder[T <: AnyRef] extends SwaggerOperationBuilder[AuthOperation[T]] {
private[this] var _allows: Option[T] => Boolean = (u: Option[T]) => true
def allows: Option[T] => Boolean = _allows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class DataTypeSpec extends Specification {

"return a correct Date datatype" in {
DataType[java.util.Date] must_== DataType.DateTime
DataType[org.joda.time.DateTime] must_== DataType.DateTime
// DateMidnight is deprecated at least in 2.6
//DataType[org.joda.time.DateMidnight] must_== DataType.Date
}

"return a correct Boolean datatype" in {
Expand Down
5 changes: 2 additions & 3 deletions swagger/src/test/scala/org/scalatra/swagger/SwaggerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package org.scalatra
package swagger

import java.net.ServerSocket
import java.time.OffsetDateTime

import org.joda.time.DateTime
import org.json4s.JsonDSL._
import org.json4s._
import org.json4s.jackson.JsonMethods
import org.json4s.native.JsonParser
Expand Down Expand Up @@ -368,7 +367,7 @@ case class Order(
@ApiModelProperty(position = 2, description = "Order Status", allowableValues = "placed,approved,delivered") status: String,
@ApiModelProperty(position = 3) petId: Long,
@ApiModelProperty(position = 4) quantity: Int,
@ApiModelProperty(position = 5) shipDate: DateTime)
@ApiModelProperty(position = 5) shipDate: OffsetDateTime)
case class User(id: Long, username: String, password: String, email: String, firstName: String, lastName: String, phone: String, userStatus: Int)
case class Pet(
@ApiModelProperty(position = 3) id: Long,
Expand Down

0 comments on commit 8f419ca

Please sign in to comment.