diff --git a/http-generator-core/src/main/java/io/avaje/http/generator/core/BaseProcessor.java b/http-generator-core/src/main/java/io/avaje/http/generator/core/BaseProcessor.java index cb81b495..a83cbe74 100644 --- a/http-generator-core/src/main/java/io/avaje/http/generator/core/BaseProcessor.java +++ b/http-generator-core/src/main/java/io/avaje/http/generator/core/BaseProcessor.java @@ -1,12 +1,20 @@ package io.avaje.http.generator.core; -import static io.avaje.http.generator.core.ProcessingContext.*; +import static io.avaje.http.generator.core.ProcessingContext.doc; +import static io.avaje.http.generator.core.ProcessingContext.elements; +import static io.avaje.http.generator.core.ProcessingContext.isOpenApiAvailable; +import static io.avaje.http.generator.core.ProcessingContext.logError; +import static io.avaje.http.generator.core.ProcessingContext.typeElement; import static java.util.stream.Collectors.toMap; import java.io.IOException; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.Map.Entry; + import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; @@ -21,7 +29,7 @@ public abstract class BaseProcessor extends AbstractProcessor { String contextPathString; - Map packagePaths= new HashMap<>(); + Map packagePaths= new TreeMap<>(); @Override public SourceVersion getSupportedSourceVersion() { @@ -119,11 +127,16 @@ private void writeOpenAPI() { private void writeAdapter(Element controller) { if (controller instanceof TypeElement) { + + var packageFQN = elements().getPackageOf(controller).getQualifiedName().toString(); var contextPath = Util.combinePath( contextPathString, - packagePaths.get( - elements().getPackageOf(controller).getQualifiedName().toString())); + packagePaths.entrySet().stream() + .filter(k -> packageFQN.contains(k.getKey())) + .map(Entry::getValue) + .reduce(Util::combinePath) + .orElse(null)); final ControllerReader reader = new ControllerReader((TypeElement) controller, contextPath); reader.read(true); diff --git a/tests/test-nima-jsonb/src/main/java/org/example/path/nest/PathNestController.java b/tests/test-nima-jsonb/src/main/java/org/example/path/nest/PathNestController.java new file mode 100644 index 00000000..bdd49b65 --- /dev/null +++ b/tests/test-nima-jsonb/src/main/java/org/example/path/nest/PathNestController.java @@ -0,0 +1,17 @@ +package org.example.path.nest; + +import io.avaje.http.api.Controller; +import io.avaje.http.api.Get; +import io.avaje.http.api.Path; +import io.avaje.http.api.Produces; + +@Path("test") +@Controller +public class PathNestController { + + @Produces("text/plain") + @Get + String hello() { + return "hi"; + } +} diff --git a/tests/test-nima-jsonb/src/main/java/org/example/path/nest/package-info.java b/tests/test-nima-jsonb/src/main/java/org/example/path/nest/package-info.java new file mode 100644 index 00000000..73f306ff --- /dev/null +++ b/tests/test-nima-jsonb/src/main/java/org/example/path/nest/package-info.java @@ -0,0 +1,5 @@ + +@Path("nested") +package org.example.path.nest; + +import io.avaje.http.api.Path;