You can limit which REST endpoints and resources are included in the OpenAPI model using scan profiles. This is achieved by combining the x-smallrye-profile-{profileName} extension on methods with the mp.openapi.extensions.smallrye.scan.profiles or mp.openapi.extensions.smallrye.scan.exclude.profiles configuration properties.
Step 1: Annotate your methods
Use @Extension to assign a profile name to a method.
@Path("/api")
public class MyResource {
@Path("/users")
@GET
@Extension(name = "x-smallrye-profile-user", value = "")
public List<UserDTO> listUsers() { ... }
@Path("/orders")
@GET
@Extension(name = "x-smallrye-profile-order", value = "")
public List<OrderDTO> listOrders() { ... }
}
Step 2: Configure the scan
- To include only the 'user' profile: Set
mp.openapi.extensions.smallrye.scan.profiles=user. - To exclude the 'order' profile: Set
mp.openapi.extensions.smallrye.scan.exclude.profiles=order.
Note: Path items where all operations have been excluded will be removed from the model unless the path item is in the components section. Profiles are processed after the model is merged but before user-provided filters.
import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
@Path("/api")
public class MyResource {
@Path("/users")
@GET
@Extension(name = "x-smallrye-profile-user", value = "")
public List<UserDTO> listUsers() {
// ...
}
@Path("/orders")
@GET
@Extension(name = "x-smallrye-profile-order", value = "")
public List<OrderDTO> listOrders() {
// ...
}
}