Skip to content

Commit

Permalink
Check whether outputDirectory is the root of the file system before u…
Browse files Browse the repository at this point in the history
…sing its parent
  • Loading branch information
aloubyansky committed May 3, 2024
1 parent 9d92610 commit f327ea0
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit f327ea0

Please sign in to comment.