Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix for non-existing openapi additional folder #23431

Merged
merged 1 commit into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."));
}
}