Skip to content

Commit

Permalink
allow to overwrite openApiUrl per settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed Mar 12, 2024
1 parent 9733521 commit b8f068e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"uploadsDirectory": "uploads/",
"workingDirectory": "./",
"rolePermissionsPath": "./role-permissions.json",
"openApiUrl": "https://my.domain.com/api/docs",

"database" : {
"host" : "localhost",
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/com/campudus/tableaux/Starter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/com/campudus/tableaux/TableauxConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TableauxConfig(
databaseConfig: JsonObject,
workingDirectory: String,
uploadsDirectory: String,
val openApiUrl: String,
val rolePermissions: JsonObject
) extends VertxAccess {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b8f068e

Please sign in to comment.