From b8f068e48f1394a26c643d89e0347cd64bb8d249 Mon Sep 17 00:00:00 2001 From: Manfred Zingl Date: Tue, 12 Mar 2024 18:51:30 +0100 Subject: [PATCH] allow to overwrite openApiUrl per settings --- conf-example.json | 1 + src/main/scala/com/campudus/tableaux/Starter.scala | 4 +++- src/main/scala/com/campudus/tableaux/TableauxConfig.scala | 1 + .../com/campudus/tableaux/router/DocumentationRouter.scala | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf-example.json b/conf-example.json index 1504fe0d2..db7297c16 100644 --- a/conf-example.json +++ b/conf-example.json @@ -5,6 +5,7 @@ "uploadsDirectory": "uploads/", "workingDirectory": "./", "rolePermissionsPath": "./role-permissions.json", + "openApiUrl": "https://my.domain.com/api/docs", "database" : { "host" : "localhost", diff --git a/src/main/scala/com/campudus/tableaux/Starter.scala b/src/main/scala/com/campudus/tableaux/Starter.scala index 1fce925c0..7f82b532b 100644 --- a/src/main/scala/com/campudus/tableaux/Starter.scala +++ b/src/main/scala/com/campudus/tableaux/Starter.scala @@ -53,6 +53,7 @@ class Starter extends ScalaVerticle with LazyLogging { val uploadsDirectory = getStringDefault(config, "uploadsDirectory", Starter.DEFAULT_UPLOADS_DIRECTORY) val authConfig = config.getJsonObject("auth", Json.obj()) val rolePermissionsPath = getStringDefault(config, "rolePermissionsPath", Starter.DEFAULT_ROLE_PERMISSIONS_PATH) + val openApiUrl = getStringDefault(config, "openApiUrl", "") val rolePermissions = FileUtils(vertxAccessContainer()).readJsonFile(rolePermissionsPath, Json.emptyObj()) @@ -62,7 +63,8 @@ class Starter extends ScalaVerticle with LazyLogging { authConfig = authConfig, workingDirectory = workingDirectory, uploadsDirectory = uploadsDirectory, - rolePermissions = rolePermissions + rolePermissions = rolePermissions, + openApiUrl = openApiUrl ) connection = SQLConnection(vertxAccessContainer(), databaseConfig) diff --git a/src/main/scala/com/campudus/tableaux/TableauxConfig.scala b/src/main/scala/com/campudus/tableaux/TableauxConfig.scala index d9b76f3bd..7bb8644a8 100644 --- a/src/main/scala/com/campudus/tableaux/TableauxConfig.scala +++ b/src/main/scala/com/campudus/tableaux/TableauxConfig.scala @@ -13,6 +13,7 @@ class TableauxConfig( databaseConfig: JsonObject, workingDirectory: String, uploadsDirectory: String, + val openApiUrl: String, val rolePermissions: JsonObject ) extends VertxAccess { diff --git a/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala b/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala index 841e6c68f..a3d1dea68 100644 --- a/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala +++ b/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala @@ -133,7 +133,7 @@ class DocumentationRouter(override val config: TableauxConfig) extends BaseRoute val uri = (forwardedScheme, forwardedHost, forwardedUrl) match { case (Some(scheme), Some(host), Some(query)) => s"$scheme://$host$query" - case _ => request.absoluteURI() + case _ => config.openApiUrl } DocUriParser.parse(uri)