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

Commit

Permalink
Merge pull request #449 from NCATS-Tangerine/fix-server-extensions
Browse files Browse the repository at this point in the history
Fix server extensions
  • Loading branch information
balhoff authored Nov 5, 2021
2 parents 4042b2b + 6aa9f3b commit 56e08cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
8 changes: 3 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,16 @@ libraryDependencies ++= {
)
}

dockerBaseImage := "openjdk:15-alpine"
dockerBaseImage := "openjdk:17-alpine"
Docker / daemonUser := "camkpapi"
dockerExposedPorts += 8080
// test
dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g")
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.2.0")
// dev
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.1.0 -DLOCATION=https://cam-kp-api-dev.renci.org -DSPARQL_ENDPOINT=https://stars-app.renci.org/camdev/sparql")
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.2.0 -DLOCATION=https://cam-kp-api-dev.renci.org -DSPARQL_ENDPOINT=https://stars-app.renci.org/camdev/sparql")
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.2.0 -DLOCATION=https://cam-kp-api-dev.renci.org -DSPARQL_ENDPOINT=https://stars-app.renci.org/camdev/sparql -DMATURITY=development")
// prod
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.1.0 -DLOCATION=https://cam-kp-api.renci.org -DSPARQL_ENDPOINT=https://stars-app.renci.org/cam/sparql")
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.2.0 -DLOCATION=https://cam-kp-api.renci.org -DSPARQL_ENDPOINT=https://stars-app.renci.org/cam/sparql")
//dockerEnvVars ++= Map("JAVA_OPTS" -> "-Xmx16g -Xms16g -DTRAPI_VERSION=1.2.0 -DLOCATION=https://cam-kp-api.renci.org -DSPARQL_ENDPOINT=https://stars-app.renci.org/cam/sparql -DMATURITY=production")
dockerEntrypoint := Seq("/opt/docker/bin/server")
Docker / dockerApiVersion := Some(DockerApiVersion(1, 40))
dockerChmodType := DockerChmodType.UserGroupWriteExecute
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
location = ${?LOCATION}
sparql-endpoint = "https://stars-app.renci.org/cam/sparql"
sparql-endpoint = ${?SPARQL_ENDPOINT}
maturity = "production"
maturity = "development"
maturity = ${?MATURITY}
}
14 changes: 11 additions & 3 deletions src/main/scala/org/renci/cam/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import org.renci.cam.HttpClient.HttpClient
import org.renci.cam.SPARQLQueryExecutor.SPARQLCache
import org.renci.cam.domain._
import sttp.tapir.Endpoint
import sttp.tapir.apispec.ExtensionValue
import sttp.tapir.docs.openapi._
import sttp.tapir.generic.auto._
import sttp.tapir.json.circe._
import sttp.tapir.openapi._
import sttp.tapir.openapi.circe.yaml._
import sttp.tapir.openapi.{Contact, Info, License}
import sttp.tapir.server.http4s.ztapir.ZHttp4sServerInterpreter
import sttp.tapir.swagger.SwaggerUI
import sttp.tapir.ztapir._
Expand All @@ -31,6 +32,7 @@ import zio.config.{getConfig, ZConfig}
import zio.interop.catz._

import java.util.Properties
import scala.collection.immutable.ListMap
import scala.concurrent.duration._

object Server extends App with LazyLogging {
Expand Down Expand Up @@ -166,14 +168,20 @@ object Server extends App with LazyLogging {
.toOpenAPI(List(queryEndpoint, metaKnowledgeGraphEndpoint), "CAM-KP API", "0.1")
.copy(info = openAPIInfo)
.copy(tags = List(sttp.tapir.apispec.Tag("maturity"), sttp.tapir.apispec.Tag("translator"), sttp.tapir.apispec.Tag("trapi")))
.servers(List(sttp.tapir.openapi.Server(s"${appConfig.location}/${appConfig.trapiVersion}")))
.servers(
List(
sttp.tapir.openapi
.Server(s"${appConfig.location}/${appConfig.trapiVersion}")
.description("Default server")
.extensions(ListMap("x-maturity" -> ExtensionValue(s"${appConfig.maturity}"), "x-location" -> ExtensionValue("RENCI")))
)
)
.toYaml
openAPIJson <- ZIO.fromEither(io.circe.yaml.parser.parse(openAPI))
info: String =
s"""
{
"info": {
"x-maturity": "${appConfig.maturity}",
"x-translator": {
"infores": "infores:cam-kp",
"component": "KP",
Expand Down

0 comments on commit 56e08cd

Please sign in to comment.