Skip to content

Commit

Permalink
Merge branch 'master' into scala-3
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerman authored Nov 18, 2023
2 parents 16f5f94 + b250f73 commit 0f461a3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# Scala Steward: Reformat with scalafmt 3.7.0
65e04a3eeaf1b0f141e3a5ebbd40bd820b4f6f5d

# Scala Steward: Reformat with scalafmt 3.7.17
f93a6966c771e973e2a474ea36ffbb922291538f
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.7.16
version = 3.7.17

runner.dialect = scala213source3
style = defaultWithAlign
Expand Down
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ lazy val commonSettings = Seq(
Deps.scalatest.value % Test ::
Nil,
scalacOptions --= Seq("-Wconf:any&src=src_managed/.*"),

libraryDependencies ++= (if (isDotty.value) Nil
libraryDependencies ++= (if (isDotty.value) Nil
else
Seq(
compilerPlugin(("org.typelevel" %% "kind-projector" % "0.13.2").cross(CrossVersion.full)),
)),
)

lazy val jsSettings = Seq(
useYarn := true,
useYarn := true,
)

lazy val core = project
Expand Down
17 changes: 13 additions & 4 deletions lambdaHttpApiTapir/src/main/scala/helper/DocServer.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package funstack.lambda.http.api.tapir.helper

import io.circe.Encoder
import io.circe.syntax._
import net.exoego.facade.aws_lambda._
import sttp.apispec.{SecurityRequirement, Tag}
import sttp.apispec.openapi.{Info, PathItem, ReferenceOr, Server}
import sttp.apispec.openapi.circe._
import sttp.apispec.openapi.{Info, OpenAPI, PathItem, ReferenceOr, Server}
import sttp.tapir.docs.openapi.{OpenAPIDocsInterpreter, OpenAPIDocsOptions}
import sttp.tapir.server.ServerEndpoint
import sttp.tapir.{EndpointInfoOps, EndpointMetaOps}
Expand All @@ -20,6 +20,7 @@ case class DocInfo(
security: List[SecurityRequirement] = Nil,
swaggerUIOptions: js.Object = js.Object(),
filterEndpoints: EndpointInfoOps[_] with EndpointMetaOps => Boolean = _ => true,
openApiVersion: Option[String] = None,
)
object DocInfo {
def default = DocInfo(title = "API", version = "latest")
Expand All @@ -29,6 +30,11 @@ object DocInfo {

object DocServer {

private def openApiEncoder(version: String): Encoder[OpenAPI] = version match {
case "3.0.3" => sttp.apispec.openapi.circe_openapi_3_0_3.encoderOpenAPI
case _ => sttp.apispec.openapi.circe.encoderOpenAPI
}

private def result(body: String, contentType: String): APIGatewayProxyStructuredResultV2 = APIGatewayProxyStructuredResultV2(
statusCode = 200,
body = body,
Expand All @@ -45,10 +51,13 @@ object DocServer {
Some(result(html, "text/html"))

case List("openapi.json") =>
val openapi = OpenAPIDocsInterpreter(docInfo.options)
val openapiBase = OpenAPIDocsInterpreter(docInfo.options)
.serverEndpointsToOpenAPI[F](endpoints.filter(docInfo.filterEndpoints), docInfo.info)
.copy(tags = docInfo.tags, webhooks = docInfo.webhooks, servers = docInfo.servers, security = docInfo.security)
val json = openapi.asJson.spaces2SortKeys

val openapi = docInfo.openApiVersion.fold(openapiBase)(version => openapiBase.copy(openapi = version))

val json = openapi.asJson(openApiEncoder(openapi.openapi)).spaces2SortKeys
Some(result(json, "application/json"))

case _ => None
Expand Down
6 changes: 3 additions & 3 deletions lambdaWsEventAuthorizer/src/main/scala/Handler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ object Handler {
val router = routerf(request)

val result: Future[Boolean] = ServerMessageSerdes.deserialize(record.Sns.Message) match {
case Right(n: Notification[SubscriptionEvent@unchecked]) =>
case Right(n: Notification[SubscriptionEvent @unchecked]) =>
val (a, b, arg) = n.event.subscriptionKey.split("/") match {
case Array(a, b) => (a, b, "")
case Array(a, b, arg) => (a, b, arg)
Expand All @@ -129,8 +129,8 @@ object Handler {
}
case Left(error) => Future.failed(new Exception(s"Deserialization Error - ${error}"))
}
case Right(s) => Future.failed(new Exception(s"Unexpected event body: $s"))
case Left(error) => Future.failed(new Exception(s"Deserialization Error - ${error}"))
case Right(s) => Future.failed(new Exception(s"Unexpected event body: $s"))
case Left(error) => Future.failed(new Exception(s"Deserialization Error - ${error}"))
}

result.flatMap {
Expand Down
2 changes: 1 addition & 1 deletion project/Deps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object Deps {

// sttp
val apiSpec = new {
val version = "0.7.0"
val version = "0.7.1"
val circe = s("com.softwaremill.sttp.apispec" %%% "openapi-circe" % version)
}

Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ addSbtPlugin("org.scalablytyped.converter" % "sbt-converter" % "1.0.0
// sane scalac options
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.0")

addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")

addSbtPlugin("com.thoughtworks.sbt-scala-js-map" % "sbt-scala-js-map" % "4.1.1")

0 comments on commit 0f461a3

Please sign in to comment.