-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from electronicarts/0.2.2
Fix regression that prevented the generation of a Swagger UI for multiple Thrift services
- Loading branch information
Showing
22 changed files
with
243 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always" | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always" | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always" | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always" | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always" | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
import sbt._ | ||
|
||
val twitterVersion = "20.10.0" | ||
val circeVersion = "0.14.1" | ||
|
||
lazy val root = (project in file(".")) | ||
.settings( | ||
scalaVersion := "2.12.15", | ||
libraryDependencies ++= Seq( | ||
"com.twitter" %% "twitter-server" % twitterVersion, | ||
"com.twitter" %% "scrooge-core" % twitterVersion, | ||
"com.twitter" %% "finagle-http" % twitterVersion, | ||
"io.circe" %% "circe-generic" % circeVersion, | ||
"io.circe" %% "circe-parser" % circeVersion | ||
), | ||
karaServices := Seq( | ||
"com.local.ServiceOne", | ||
"com.local.ServiceTwo", | ||
"com.local.ServiceThree", | ||
"com.local.ServiceFour", | ||
) | ||
) | ||
.enablePlugins(Kara) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.ea.kara" % "kara" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} |
93 changes: 93 additions & 0 deletions
93
src/sbt-test/kara/multi_service/src/main/scala/MultiServiceTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
import java.net.InetSocketAddress | ||
|
||
import com.local._ | ||
import com.twitter.finagle.http | ||
import com.twitter.finagle.Http | ||
import com.twitter.finagle.Service | ||
import com.twitter.util.{Await, Future} | ||
import io.circe._ | ||
import io.circe.generic.auto._ | ||
import com.ea.kara.generated.svc_one._ | ||
import com.ea.kara.generated.svc_two._ | ||
import com.ea.kara.generated.svcs_three_four._ | ||
|
||
object MultiServiceTest extends App { | ||
|
||
case class GenericError(message: String) | ||
|
||
lazy val svcOne: Service[http.Request, http.Response] = new HttpServiceOne(new ServiceOne) | ||
lazy val svcTwo: Service[http.Request, http.Response] = new HttpServiceTwo(new ServiceTwo) | ||
lazy val svcThree: Service[http.Request, http.Response] = new HttpServiceThree(new ServiceThree) | ||
lazy val svcFour: Service[http.Request, http.Response] = new HttpServiceFour(new ServiceFour) | ||
|
||
override def main(args: Array[String]): Unit = { | ||
assert(args.length == 1, "Should pass the name of the test to run.") | ||
|
||
val testName = args.head | ||
|
||
val request = finagleRequest("ping") | ||
|
||
testName match { | ||
case "pingServiceOne" => serve(svcOne, request) | ||
case "pingServiceTwo" => serve(svcTwo, request) | ||
case "pingServiceThree" => serve(svcThree, request) | ||
case "pingServiceFour" => serve(svcFour, request) | ||
} | ||
} | ||
|
||
def serve(svc: Service[http.Request, http.Response], request: http.Request): Unit = { | ||
val response = Await.result(svc(request)) | ||
assertSuccessfulResponse(response) | ||
} | ||
|
||
def finagleRequest(rpcName: String): http.Request = { | ||
val request = http.Request(method = com.twitter.finagle.http.Method.Post, uri = s"/$rpcName") | ||
request.setContentTypeJson() | ||
request | ||
} | ||
|
||
def assertSuccessfulResponse(response: http.Response): Unit = { | ||
assertJsonResponse(response) | ||
assertResponseStatus(response, http.Status.Ok) | ||
} | ||
|
||
def assertResponseStatus(response: http.Response, expectedStatus: http.Status): Unit = | ||
assert( | ||
response.status == expectedStatus, | ||
s""" | ||
|Status code should be '$expectedStatus', | ||
|instead was found ${response.status}. | ||
""".stripMargin | ||
) | ||
|
||
def assertJsonResponse(response: http.Response): Unit = { | ||
val applicationJsonContentType = "application/json;charset=utf-8" | ||
assert( | ||
response.contentType == Some(applicationJsonContentType), | ||
s""" | ||
|Content type should be '$applicationJsonContentType', | ||
|instead was found '${response.contentType}'. | ||
""".stripMargin | ||
) | ||
} | ||
} | ||
|
||
class ServiceOne extends ServiceOne.MethodPerEndpoint { | ||
override def ping(): Future[Unit] = Future.Unit | ||
} | ||
|
||
class ServiceTwo extends ServiceTwo.MethodPerEndpoint { | ||
override def ping(): Future[Unit] = Future.Unit | ||
} | ||
|
||
class ServiceThree extends ServiceThree.MethodPerEndpoint { | ||
override def ping(): Future[Unit] = Future.Unit | ||
} | ||
|
||
class ServiceFour extends ServiceFour.MethodPerEndpoint { | ||
override def ping(): Future[Unit] = Future.Unit | ||
} |
9 changes: 9 additions & 0 deletions
9
src/sbt-test/kara/multi_service/src/main/thrift/svc_one.thrift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
namespace java com.local | ||
|
||
service ServiceOne { | ||
void ping() | ||
} |
9 changes: 9 additions & 0 deletions
9
src/sbt-test/kara/multi_service/src/main/thrift/svc_two.thrift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
namespace java com.local | ||
|
||
service ServiceTwo { | ||
void ping() | ||
} |
13 changes: 13 additions & 0 deletions
13
src/sbt-test/kara/multi_service/src/main/thrift/svcs_three_four.thrift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
namespace java com.local | ||
|
||
service ServiceThree { | ||
void ping() | ||
} | ||
|
||
service ServiceFour { | ||
void ping() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
|
||
# Make sure both services can be hit | ||
> run pingServiceOne | ||
> run pingServiceTwo | ||
> run pingServiceThree | ||
> run pingServiceFour | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % "always" | ||
/* | ||
* Copyright (C) 2022 Electronic Arts Inc. All rights reserved. | ||
*/ | ||
|
||
ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-parser-combinators" % VersionScheme.Always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters