Skip to content

Commit

Permalink
allow to override tag for rest api generated for processes to group t…
Browse files Browse the repository at this point in the history
…he endpoints
  • Loading branch information
mswiderski committed Aug 6, 2024
1 parent 40a29e4 commit 3df10af
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ public CompilationUnit generateCompilationUnit() {
ClassOrInterfaceDeclaration template = clazz.findFirst(ClassOrInterfaceDeclaration.class).orElseThrow(
() -> new NoSuchElementException("Compilation unit doesn't contain a class or interface declaration!"));

String category = (String) process.getMetaData().getOrDefault("category", process.getName());
String categoryDescription = (String) process.getMetaData().getOrDefault("categoryDescription",
process.getMetaData().getOrDefault("Documentation", processName).toString());

template.addAnnotation(new NormalAnnotationExpr(new Name("org.eclipse.microprofile.openapi.annotations.tags.Tag"),
NodeList.nodeList(new MemberValuePair("name", new StringLiteralExpr(category)),
new MemberValuePair("description", new StringLiteralExpr(categoryDescription)))));

template.setName(resourceClazzName);
AtomicInteger index = new AtomicInteger(0);
AtomicInteger uindex = new AtomicInteger(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import org.eclipse.microprofile.openapi.annotations.responses.APIResponses;

@SuppressWarnings({ "rawtypes", "unchecked" })
@org.eclipse.microprofile.openapi.annotations.tags.Tag(name="$processname$", description="$processdocumentation$")
@Path("/$name$")
public class $Type$Resource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -99,7 +100,7 @@ public static WorkflowBuilder newWorkflow(String id, String name, String version
process.setPackageName("org.acme.test");

if (description != null) {
process.setMetaData("description", description);
process.setMetaData("Documentation", description);
}

return new WorkflowBuilder(process);
Expand Down Expand Up @@ -150,7 +151,7 @@ public static WorkflowBuilder newPrivateWorkflow(String id, String name, String
process.setPackageName("org.acme.test");

if (description != null) {
process.setMetaData("description", description);
process.setMetaData("Documentation", description);
}

return new WorkflowBuilder(process);
Expand Down Expand Up @@ -194,6 +195,19 @@ public WorkflowBuilder tags(String... tags) {
return this;
}

/**
* Sets category of the workflow that is used to group workflows at documentation level
*
* @param category not null name of the category
* @return the builder
*/
public WorkflowBuilder category(String category, String description) {
Objects.requireNonNull(category, "Category must not be null");
process.setMetaData("category", category);
process.setMetaData("categoryDescription", description);
return this;
}

/**
* Aborts workflow instance inn case it is not completed within given duration expressed as ISO 8601 duration format.
* For example <code>P5D</code> stands for 5 days, which will abort workflow instance after 5 days from the starting time
Expand Down

0 comments on commit 3df10af

Please sign in to comment.