-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix loading of static resources from the class path (#2017)
Signed-off-by: Michael Edgar <[email protected]>
- Loading branch information
Showing
5 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
core/src/test/java/io/smallrye/openapi/api/SmallRyeOpenAPIBuilderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.smallrye.openapi.api; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
|
||
import org.eclipse.microprofile.openapi.models.OpenAPI; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class SmallRyeOpenAPIBuilderTest { | ||
|
||
@Test | ||
void testStaticFileLoadedFromClasspath() throws Exception { | ||
URL loaderRoot = getClass() | ||
.getClassLoader() | ||
.getResource("classloader/META-INF/openapi.yaml") | ||
.toURI() | ||
.resolve("..") | ||
.toURL(); | ||
|
||
ClassLoader custom = new URLClassLoader( | ||
new URL[] { loaderRoot }, | ||
Thread.currentThread().getContextClassLoader()); | ||
|
||
SmallRyeOpenAPI result = SmallRyeOpenAPI.builder() | ||
.withApplicationClassLoader(custom) | ||
.enableModelReader(false) | ||
.enableStandardFilter(false) | ||
.enableAnnotationScan(false) | ||
.enableStandardStaticFiles(true) | ||
.build(); | ||
|
||
OpenAPI model = result.model(); | ||
assertEquals("Loaded from the class path", model.getInfo().getTitle()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
openapi: 3.1.0 | ||
info: | ||
title: Loaded from the class path | ||
version: "1.0.0" | ||
paths: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
.../smallrye/openapi/mavenplugin/BasicIT/basic_info/src/main/resources/META-INF/openapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
openapi: "3.0.3" | ||
info: | ||
x-custom-extension: My Custom Extension |