Skip to content
Merged
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 @@ -15,13 +15,19 @@
*/
package org.eclipse.microprofile.openapi.apps.scanconfig.a;

import org.eclipse.microprofile.openapi.annotations.ExternalDocumentation;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@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,57 @@
/**
* Copyright (c) 2025 Contributors to the Eclipse Foundation
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.eclipse.microprofile.openapi.tck;

import static org.hamcrest.Matchers.equalTo;

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 io.restassured.response.ValidatableResponse;

/**
* 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'.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"));
}
}