Skip to content

Commit

Permalink
Merge pull request #23431 from phillip-kruger/additional-docs-fix
Browse files Browse the repository at this point in the history
Small fix for non-existing openapi additional folder
  • Loading branch information
gsmet authored Feb 4, 2022
2 parents 3502f4f + 960a1f2 commit fa2f323
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ void configFiles(BuildProducer<HotDeploymentWatchedFileBuildItem> watchedFiles,
List<Path> additionalStaticDocuments = openApiConfig.additionalDocsDirectory.get();
for (Path path : additionalStaticDocuments) {
// Scan all yaml and json files
List<String> filesInDir = getResourceFiles(path.toString(), outputTargetBuildItem.getOutputDirectory());
List<String> filesInDir = getResourceFiles(PathUtils.asString(path, "/"),
outputTargetBuildItem.getOutputDirectory());
for (String possibleFile : filesInDir) {
watchedFiles.produce(new HotDeploymentWatchedFileBuildItem(possibleFile));
}
Expand Down Expand Up @@ -845,10 +846,11 @@ private List<String> getResourceFiles(String pathName, Path target) throws IOExc
Path classes = target.resolve("classes");
if (classes != null) {
Path path = classes.resolve(pathName);

return Files.list(path).map((t) -> {
return pathName + "/" + t.getFileName().toString();
}).collect(Collectors.toList());
if (Files.exists(path)) {
return Files.list(path).map((t) -> {
return pathName + "/" + t.getFileName().toString();
}).collect(Collectors.toList());
}
}
}
return filenames;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.quarkus.smallrye.openapi.test.jaxrs;

import java.io.IOException;

import org.hamcrest.Matchers;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;

public class OpenApiEmptyStaticModelsTestCase {

private static String directory = "META-INF/foldernamethatdoesnotexist";

@RegisterExtension
static QuarkusUnitTest runner = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(OpenApiResource.class, ResourceBean.class)
.addAsResource(
new StringAsset("quarkus.smallrye-openapi.additional-docs-directory=" + directory),
"application.properties"));

@Test
public void testNonExistingAdditionalDocsDirectory() throws IOException {

RestAssured.given().header("Accept", "application/json")
.when().get("/q/openapi")
.then()
.log().body().and()
.body("openapi", Matchers.startsWith("3.0."));
}
}

0 comments on commit fa2f323

Please sign in to comment.