Skip to content

Commit 20c1a80

Browse files
committed
[issue-713] - Add a test to the TCKs in order to verify the usage of the "@ExternalDocumentation" annotation
1 parent 7092ac3 commit 20c1a80

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@
1717

1818
import jakarta.ws.rs.GET;
1919
import jakarta.ws.rs.Path;
20+
import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation;
2021

2122
@Path("a")
23+
@ExternalDocumentation(description = "Find more information about this application",
24+
url = "https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/ScanConfigApplication.java")
2225
public class AResource {
2326

2427
@GET
28+
@ExternalDocumentation(description = "Find more information about this application resource",
29+
url = "https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java")
2530
public String get() {
2631
return "a";
2732
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package org.eclipse.microprofile.openapi.tck;
2+
3+
import io.restassured.response.ValidatableResponse;
4+
import org.eclipse.microprofile.openapi.apps.scanconfig.ScanConfigApplication;
5+
import org.eclipse.microprofile.openapi.apps.scanconfig.a.AResource;
6+
import org.jboss.arquillian.container.test.api.Deployment;
7+
import org.jboss.shrinkwrap.api.ShrinkWrap;
8+
import org.jboss.shrinkwrap.api.spec.WebArchive;
9+
import org.testng.annotations.Test;
10+
11+
import static org.hamcrest.Matchers.equalTo;
12+
13+
/**
14+
* Verify usage of the {@code @ExternalDocumentation} annotation.
15+
*/
16+
public class ExternalDocumentationAnnotationTest extends AppTestBase {
17+
18+
@Deployment(name = "externalDocs-test", testable = false)
19+
public static WebArchive deployment() {
20+
return ShrinkWrap.create(WebArchive.class, "externalDocs-test.war")
21+
.addClasses(ScanConfigApplication.class, AResource.class);
22+
}
23+
24+
/**
25+
* Check that the {@code externalDocs} element is present in the generated OpenAPI document when the
26+
* {@code @ExternalDocumentation} annotation is used on a resource class definition.
27+
* @param type Type of the OpenAPI output format
28+
*/
29+
@Test(dataProvider = "formatProvider")
30+
public void testExternalDocumentationAnnotationOnClass(String type) {
31+
ValidatableResponse vr = callEndpoint(type);
32+
33+
vr.body("externalDocs.description", equalTo("Find more information about this application"));
34+
vr.body("externalDocs.url", equalTo(
35+
"https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/ScanConfigApplication.java"));
36+
}
37+
38+
/**
39+
* Check that the {@code externalDocs} element is present in the generated OpenAPI document when the
40+
* {@code @ExternalDocumentation} annotation is used on a resource method definition.
41+
* @param type Type of the OpenAPI output format
42+
*/
43+
@Test(dataProvider = "formatProvider")
44+
public void testExternalDocumentationAnnotationOnMethod(String type) {
45+
ValidatableResponse vr = callEndpoint(type);
46+
47+
vr.body("paths.'/a'.externalDocs.description", equalTo("Find more information about this application resource"));
48+
vr.body("paths.'/a'.externalDocs.url", equalTo(
49+
"https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java"));
50+
}
51+
}

0 commit comments

Comments
 (0)