|
| 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 method definition. |
| 27 | + * @param type Type of the OpenAPI output format |
| 28 | + */ |
| 29 | + @Test(dataProvider = "formatProvider") |
| 30 | + public void testExternalDocumentationAnnotationOnMethod(String type) { |
| 31 | + ValidatableResponse vr = callEndpoint(type); |
| 32 | + |
| 33 | + vr.body("paths.'/a'.externalDocs.description", equalTo("Find more information about this application resource")); |
| 34 | + vr.body("paths.'/a'.externalDocs.url", equalTo( |
| 35 | + "https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java")); |
| 36 | + } |
| 37 | +} |
0 commit comments