From f327ea0a96688bf2a1db4300d95300a107292cbb Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Fri, 3 May 2024 14:22:43 +0200 Subject: [PATCH] Check whether outputDirectory is the root of the file system before using its parent --- .../openapi/deployment/SmallRyeOpenApiProcessor.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java b/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java index 53f3f86b0fe17..2502f2c710442 100644 --- a/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java +++ b/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java @@ -12,7 +12,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.Arrays; @@ -939,14 +938,19 @@ private void storeGeneratedSchema(SmallRyeOpenApiConfig openApiConfig, OutputTar Path outputDirectory = out.getOutputDirectory(); if (!directory.isAbsolute() && outputDirectory != null) { - directory = Paths.get(outputDirectory.getParent().toString(), directory.toString()); + var baseDir = outputDirectory.getParent(); + // check if outputDirectory is the root of the filesystem + if (baseDir == null) { + baseDir = outputDirectory; + } + directory = baseDir.resolve(directory); } if (!Files.exists(directory)) { Files.createDirectories(directory); } - Path file = Paths.get(directory.toString(), "openapi." + format.toString().toLowerCase()); + Path file = directory.resolve("openapi." + format.toString().toLowerCase()); if (!Files.exists(file)) { Files.createFile(file); }