Robert Jaros
10/13/2025, 5:27 PMRobert Jaros
10/13/2025, 5:28 PMOct 13 19:07:18 prv-sodtest.finn.pl finn-java-jre21[1132819]: 2025-10-13 19:07:18,146 [main] WARN i.s.c.v.i.CodegenIgnoreProcessor - Output directory does not exist, or is
inaccessible. No file (.swagger-codegen-ignore) will be evaluated.
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: 2025-10-13 19:07:19,335 [main] INFO i.s.codegen.v3.AbstractGenerator - writing file docs/index.html
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: Exception in thread "main" java.lang.RuntimeException: Could not generate supporting file 'SupportingFile:
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: templateFile: index.mustache
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: folder:
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: destinationFilename: index.html
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: '
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: at io.swagger.codegen.v3.DefaultGenerator.generateSupportingFiles(DefaultGenerator.java:677)
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: at io.swagger.codegen.v3.DefaultGenerator.generate(DefaultGenerator.java:860)
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: at io.ktor.server.plugins.openapi.OpenAPIKt.openAPI(OpenAPI.kt:45)
Oct 13 19:07:19 prv-sodtest.finn.pl finn-java-jre21[1132819]: at io.ktor.server.plugins.openapi.OpenAPIKt.openAPI$default(OpenAPI.kt:24)Robert Jaros
10/13/2025, 5:29 PMrouting {
openAPI(path = "openapi", swaggerFile = "api.yaml")
swaggerUI(path = "swagger", swaggerFile = "api.yaml")
}Robert Jaros
10/13/2025, 5:32 PMdocs directory is generated in the current directory. I think there are no permissions to write files on production. Is this configurable? Can be disabled without removing the swagger plugin?Aleksei Tirman [JB]
10/14/2025, 7:17 AMdocs directory is hardcoded. You can inline the implementation of the openAPI method, which is quite small, and change the directory there. Here is an example:
fun readOpenAPIFile(swaggerFile: String, classLoader: ClassLoader): String {
val resource = classLoader.getResourceAsStream(swaggerFile)
?.bufferedReader()?.readText()
if (resource != null) return resource
val file = File(swaggerFile)
if (!file.exists()) {
throw FileNotFoundException("Swagger file not found: $swaggerFile")
}
return file.readText()
}
fun main(args: Array<String>) {
embeddedServer(Netty, port = 9000) {
routing {
val apiDocument = readOpenAPIFile("api.yaml", environment.classLoader)
val config = OpenAPIConfig()
with(config) {
val swagger = parser.readContents(apiDocument, null, options)
val dir = File("docs") // Change the dir
dir.mkdirs()
opts.apply {
config(codegen)
opts(ClientOpts())
openAPI(swagger.openAPI)
}
generator.opts(opts)
generator.generate()
staticFiles("openapi", dir)
}
}
}.start(wait = true)
}