Skip to content
Open
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 @@ -17,11 +17,16 @@

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation;

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

@GET
@ExternalDocumentation(description = "Find more information about this application resource",
url = "https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java")
public String get() {
return "a";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.eclipse.microprofile.openapi.tck;

import io.restassured.response.ValidatableResponse;
import org.eclipse.microprofile.openapi.apps.scanconfig.ScanConfigApplication;
import org.eclipse.microprofile.openapi.apps.scanconfig.a.AResource;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.annotations.Test;

import static org.hamcrest.Matchers.equalTo;

/**
* Verify usage of the {@code @ExternalDocumentation} annotation.
*/
public class ExternalDocumentationAnnotationTest extends AppTestBase {

@Deployment(name = "externalDocs-test", testable = false)
public static WebArchive deployment() {
return ShrinkWrap.create(WebArchive.class, "externalDocs-test.war")
.addClasses(ScanConfigApplication.class, AResource.class);
}

/**
* Check that the {@code externalDocs} element is present in the generated OpenAPI document when the
* {@code @ExternalDocumentation} annotation is used on a resource method definition.
* @param type Type of the OpenAPI output format
*/
@Test(dataProvider = "formatProvider")
public void testExternalDocumentationAnnotationOnMethod(String type) {
ValidatableResponse vr = callEndpoint(type);

vr.body("paths.'/a'.externalDocs.description", equalTo("Find more information about this application resource"));
vr.body("paths.'/a'.externalDocs.url", equalTo(
"https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java"));
Comment on lines +33 to +35
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
vr.body("paths.'/a'.externalDocs.description", equalTo("Find more information about this application resource"));
vr.body("paths.'/a'.externalDocs.url", equalTo(
"https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java"));
vr.body("paths.'/a'.get.externalDocs.description", equalTo("Find more information about this application resource"));
vr.body("paths.'/a'.get.externalDocs.url", equalTo(
"https://github.com/microprofile/microprofile-open-api/blob/main/tck/src/main/java/org/eclipse/microprofile/openapi/apps/scanconfig/a/AResource.java"));

Should be this I think?

externalDocs is on the operation object, not the path item object.

}
}