diff --git a/extensions/panache/hibernate-orm-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java b/extensions/panache/hibernate-orm-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java index 030293d1eebbd..c0f140b17c784 100644 --- a/extensions/panache/hibernate-orm-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java +++ b/extensions/panache/hibernate-orm-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/orm/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java @@ -49,12 +49,16 @@ public void testOpenApiForGeneratedResources() { .header("Content-Type", "application/json;charset=UTF-8") .body("info.title", Matchers.equalTo("quarkus-hibernate-orm-rest-data-panache-deployment API")) .body("paths.'/collections'", Matchers.hasKey("get")) + .body("paths.'/collections'.get.tags", Matchers.hasItem("CollectionsResource")) .body("paths.'/collections'", Matchers.hasKey("post")) + .body("paths.'/collections'.post.tags", Matchers.hasItem("CollectionsResource")) .body("paths.'/collections/{id}'", Matchers.hasKey("get")) .body("paths.'/collections/{id}'", Matchers.hasKey("put")) .body("paths.'/collections/{id}'", Matchers.hasKey("delete")) .body("paths.'/empty-list-items'", Matchers.hasKey("get")) + .body("paths.'/empty-list-items'.get.tags", Matchers.hasItem("EmptyListItemsResource")) .body("paths.'/empty-list-items'", Matchers.hasKey("post")) + .body("paths.'/empty-list-items'.post.tags", Matchers.hasItem("EmptyListItemsResource")) .body("paths.'/empty-list-items/{id}'", Matchers.hasKey("get")) .body("paths.'/empty-list-items/{id}'", Matchers.hasKey("put")) .body("paths.'/empty-list-items/{id}'", Matchers.hasKey("delete")) diff --git a/extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java b/extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java index 1911dd96969c1..b0e9d637e1897 100644 --- a/extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java +++ b/extensions/panache/hibernate-reactive-rest-data-panache/deployment/src/test/java/io/quarkus/hibernate/reactive/rest/data/panache/deployment/openapi/OpenApiIntegrationTest.java @@ -49,12 +49,16 @@ public void testOpenApiForGeneratedResources() { .header("Content-Type", "application/json;charset=UTF-8") .body("info.title", Matchers.equalTo("quarkus-hibernate-reactive-rest-data-panache-deployment API")) .body("paths.'/collections'", Matchers.hasKey("get")) + .body("paths.'/collections'.get.tags", Matchers.hasItem("CollectionsResource")) .body("paths.'/collections'", Matchers.hasKey("post")) + .body("paths.'/collections'.post.tags", Matchers.hasItem("CollectionsResource")) .body("paths.'/collections/{id}'", Matchers.hasKey("get")) .body("paths.'/collections/{id}'", Matchers.hasKey("put")) .body("paths.'/collections/{id}'", Matchers.hasKey("delete")) .body("paths.'/empty-list-items'", Matchers.hasKey("get")) + .body("paths.'/empty-list-items'.get.tags", Matchers.hasItem("EmptyListItemsResource")) .body("paths.'/empty-list-items'", Matchers.hasKey("post")) + .body("paths.'/empty-list-items'.post.tags", Matchers.hasItem("EmptyListItemsResource")) .body("paths.'/empty-list-items/{id}'", Matchers.hasKey("get")) .body("paths.'/empty-list-items/{id}'", Matchers.hasKey("put")) .body("paths.'/empty-list-items/{id}'", Matchers.hasKey("delete")) diff --git a/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/JaxRsResourceImplementor.java b/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/JaxRsResourceImplementor.java index 0691e13bec031..b6287fac51eea 100644 --- a/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/JaxRsResourceImplementor.java +++ b/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/JaxRsResourceImplementor.java @@ -7,8 +7,11 @@ import javax.inject.Inject; import javax.ws.rs.Path; +import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; +import io.quarkus.deployment.Capabilities; +import io.quarkus.deployment.Capability; import io.quarkus.gizmo.ClassCreator; import io.quarkus.gizmo.ClassOutput; import io.quarkus.gizmo.FieldCreator; @@ -29,6 +32,7 @@ class JaxRsResourceImplementor { private static final Logger LOGGER = Logger.getLogger(JaxRsResourceImplementor.class); + private static final String OPENAPI_TAG_ANNOTATION = "org.eclipse.microprofile.openapi.annotations.tags.Tag"; private final List methodImplementors; @@ -58,7 +62,8 @@ class JaxRsResourceImplementor { * } * */ - void implement(ClassOutput classOutput, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties) { + void implement(ClassOutput classOutput, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, + Capabilities capabilities) { String controllerClassName = resourceMetadata.getResourceInterface() + "JaxRs_" + HashUtil.sha1(resourceMetadata.getResourceInterface()); LOGGER.tracef("Starting generation of '%s'", controllerClassName); @@ -66,7 +71,7 @@ void implement(ClassOutput classOutput, ResourceMetadata resourceMetadata, Resou .classOutput(classOutput).className(controllerClassName) .build(); - implementClassAnnotations(classCreator, resourceProperties); + implementClassAnnotations(classCreator, resourceMetadata, resourceProperties, capabilities); FieldDescriptor resourceField = implementResourceField(classCreator, resourceMetadata); implementMethods(classCreator, resourceMetadata, resourceProperties, resourceField); @@ -74,8 +79,13 @@ void implement(ClassOutput classOutput, ResourceMetadata resourceMetadata, Resou LOGGER.tracef("Completed generation of '%s'", controllerClassName); } - private void implementClassAnnotations(ClassCreator classCreator, ResourceProperties resourceProperties) { + private void implementClassAnnotations(ClassCreator classCreator, ResourceMetadata resourceMetadata, + ResourceProperties resourceProperties, Capabilities capabilities) { classCreator.addAnnotation(Path.class).addValue("value", resourceProperties.getPath()); + if (capabilities.isPresent(Capability.SMALLRYE_OPENAPI)) { + String className = StringUtils.substringAfterLast(resourceMetadata.getResourceInterface(), "."); + classCreator.addAnnotation(OPENAPI_TAG_ANNOTATION).add("name", className); + } } private FieldDescriptor implementResourceField(ClassCreator classCreator, ResourceMetadata resourceMetadata) { diff --git a/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/RestDataProcessor.java b/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/RestDataProcessor.java index c1843ab0e6a7f..2dc465386c1a6 100644 --- a/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/RestDataProcessor.java +++ b/extensions/panache/rest-data-panache/deployment/src/main/java/io/quarkus/rest/data/panache/deployment/RestDataProcessor.java @@ -84,7 +84,7 @@ void implementResources(CombinedIndexBuildItem index, List