diff --git a/src/main/scala/com/campudus/tableaux/Starter.scala b/src/main/scala/com/campudus/tableaux/Starter.scala index 7f82b532..3266491c 100644 --- a/src/main/scala/com/campudus/tableaux/Starter.scala +++ b/src/main/scala/com/campudus/tableaux/Starter.scala @@ -53,7 +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 openApiUrl = Option(getStringDefault(config, "openApiUrl", null)) val rolePermissions = FileUtils(vertxAccessContainer()).readJsonFile(rolePermissionsPath, Json.emptyObj()) diff --git a/src/main/scala/com/campudus/tableaux/TableauxConfig.scala b/src/main/scala/com/campudus/tableaux/TableauxConfig.scala index 3ab68e02..9603ac70 100644 --- a/src/main/scala/com/campudus/tableaux/TableauxConfig.scala +++ b/src/main/scala/com/campudus/tableaux/TableauxConfig.scala @@ -14,7 +14,7 @@ class TableauxConfig( workingDirectory: String, uploadsDirectory: String, val rolePermissions: JsonObject, - val openApiUrl: String = "" + val openApiUrl: Option[String] = None ) extends VertxAccess { def uploadsDirectoryPath(): Path = { diff --git a/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala b/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala index a3d1dea6..d0dab1cd 100644 --- a/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala +++ b/src/main/scala/com/campudus/tableaux/router/DocumentationRouter.scala @@ -130,10 +130,12 @@ class DocumentationRouter(override val config: TableauxConfig) extends BaseRoute }) val forwardedUrl = request.getHeader("x-forwarded-url") + val openApiUrl = config.openApiUrl - val uri = (forwardedScheme, forwardedHost, forwardedUrl) match { - case (Some(scheme), Some(host), Some(query)) => s"$scheme://$host$query" - case _ => config.openApiUrl + val uri = (forwardedScheme, forwardedHost, forwardedUrl, openApiUrl) match { + case (Some(scheme), Some(host), Some(query), _) => s"$scheme://$host$query" + case (_, _, _, Some(openApiUrl)) => openApiUrl + case _ => request.absoluteURI() } DocUriParser.parse(uri)