-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Evict twice callings on build OpenAPI documentation
- Loading branch information
Showing
3 changed files
with
63 additions
and
6 deletions.
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
25 changes: 25 additions & 0 deletions
25
...ployment/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/CounterBuildtimeFilter.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,25 @@ | ||
package io.quarkus.smallrye.openapi.test.jaxrs; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import org.eclipse.microprofile.openapi.OASFactory; | ||
import org.eclipse.microprofile.openapi.OASFilter; | ||
import org.eclipse.microprofile.openapi.models.OpenAPI; | ||
|
||
import io.quarkus.smallrye.openapi.OpenApiFilter; | ||
|
||
@OpenApiFilter(OpenApiFilter.RunStage.BUILD) | ||
public class CounterBuildtimeFilter implements OASFilter { | ||
|
||
private static final AtomicInteger TIMES = new AtomicInteger(); | ||
|
||
public CounterBuildtimeFilter() { | ||
} | ||
|
||
@Override | ||
public void filterOpenAPI(OpenAPI aOpenAPI) { | ||
int times = TIMES.incrementAndGet(); | ||
aOpenAPI.info( | ||
OASFactory.createInfo().description("CounterBuildtimeFilter was called " + times + " time(s)")); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...o/quarkus/smallrye/openapi/test/jaxrs/OpenApiAnnotatedCounterBuildtimeFilterTestCase.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,28 @@ | ||
package io.quarkus.smallrye.openapi.test.jaxrs; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class OpenApiAnnotatedCounterBuildtimeFilterTestCase { | ||
private static final String OPEN_API_PATH = "/q/openapi"; | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest runner = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(OpenApiResource.class, ResourceBean.class, CounterBuildtimeFilter.class)); | ||
|
||
@Test | ||
public void testOpenApiFilterResource() { | ||
RestAssured.given().header("Accept", "application/json") | ||
.when().get(OPEN_API_PATH) | ||
.then() | ||
.header("Content-Type", "application/json;charset=UTF-8") | ||
.body("info.description", Matchers.startsWith("CounterBuildtimeFilter was called 1 time(s)")); | ||
|
||
} | ||
|
||
} |