Skip to content

Commit 73631fb

Browse files
committed
Add a new validation
1 parent 0049143 commit 73631fb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

server/deployment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/codegen/ApicurioOpenApiServerCodegen.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ public boolean shouldRun(Path sourceDir, Config config) {
5858
public boolean trigger(CodeGenContext context) throws CodeGenException {
5959
final Path openApiDir = getInputBaseDir(context.inputDir(), context.config());
6060

61-
if (!Files.exists(openApiDir)) {
62-
throw new CodeGenException(
63-
"The OpenAPI input base directory does not exist, please, create the directory on " + context.inputDir());
64-
}
61+
validateOpenApiDir(context, openApiDir);
6562

6663
final Path outDir = context.outDir();
6764
final ApicurioCodegenWrapper apicurioCodegenWrapper = new ApicurioCodegenWrapper(
@@ -99,6 +96,19 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {
9996
return true;
10097
}
10198

99+
private static void validateOpenApiDir(CodeGenContext context, Path openApiDir) throws CodeGenException {
100+
if (!Files.exists(openApiDir)) {
101+
throw new CodeGenException(
102+
"The OpenAPI input base directory does not exist, please, create the directory on " + context.inputDir());
103+
}
104+
105+
if (Files.isDirectory(openApiDir)) {
106+
throw new CodeGenException(
107+
"The OpenAPI input base directory is not a directory, please, create the directory on " + context.inputDir()
108+
);
109+
}
110+
}
111+
102112
private File convertToJSON(Path yamlPath) throws CodeGenException {
103113
try {
104114
ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());

0 commit comments

Comments
 (0)