Skip to content

Commit c374e54

Browse files
authored
Merge pull request #399 from modelix/bugfix/missing-openapi-in-docker
MODELIX-685 Resource based routing breaks docker container of model-server
2 parents 194db6b + 5249588 commit c374e54

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

model-server/build.gradle.kts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,30 @@ val cucumber = task("cucumber") {
117117
}
118118
}
119119

120+
// copies the openAPI specifications from the api folder into a resource
121+
// folder so that they are packaged and deployed with the model-server
122+
tasks.register<Copy>("copyApis") {
123+
from("../api/")
124+
include("*.yaml")
125+
into(project.layout.buildDirectory.dir("openapi/src/main/resources/api"))
126+
sourceSets["main"].resources.srcDir(project.layout.buildDirectory.dir("openapi/src/main/resources/"))
127+
}
128+
129+
tasks.named("runKtlintCheckOverMainSourceSet") {
130+
dependsOn("copyApis")
131+
}
132+
133+
tasks.named("compileKotlin") {
134+
dependsOn("copyApis")
135+
}
136+
120137
tasks.named("build") {
121138
dependsOn("cucumber")
139+
dependsOn("copyApis")
140+
}
141+
142+
tasks.named("processResources") {
143+
dependsOn("copyApis")
122144
}
123145

124146
task("copyLibs", Sync::class) {

model-server/src/main/kotlin/org/modelix/model/server/Main.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import org.modelix.model.server.store.loadDump
6363
import org.modelix.model.server.store.writeDump
6464
import org.modelix.model.server.templates.PageWithMenuBar
6565
import org.slf4j.LoggerFactory
66+
import org.springframework.util.ResourceUtils
6667
import java.io.File
6768
import java.io.IOException
6869
import java.nio.charset.StandardCharsets
@@ -238,8 +239,8 @@ object Main {
238239
call.respondText("SwaggerUI is disabled")
239240
}
240241
} else {
241-
// we only serve the public API to the outside via swagger UI
242-
swaggerUI(path = "swagger", swaggerFile = "../api/model-server.yaml")
242+
// we serve the public API to the outside via swagger UI
243+
swaggerUI(path = "swagger", swaggerFile = ResourceUtils.getFile("api/model-server.yaml").path.toString())
243244
}
244245
}
245246
}

model-server/src/main/kotlin/org/modelix/model/server/templates/PageWithMenuBar.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import kotlinx.html.head
1313
import kotlinx.html.img
1414
import kotlinx.html.link
1515
import kotlinx.html.style
16+
import kotlinx.html.title
1617

1718
class PageWithMenuBar(val activePage: String, val baseUrl: String) : Template<HTML> {
1819

@@ -21,6 +22,7 @@ class PageWithMenuBar(val activePage: String, val baseUrl: String) : Template<HT
2122

2223
override fun HTML.apply() {
2324
head {
25+
title("Model-Server Home")
2426
link("$baseUrl/public/modelix-base.css", rel = "stylesheet")
2527
link("$baseUrl/public/menu-bar.css", rel = "stylesheet")
2628
insert(headContent)

0 commit comments

Comments
 (0)