Skip to content

Commit c264fa2

Browse files
committed
default to inject
1 parent 086078a commit c264fa2

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ final class ClientMethodWriter {
8989
}
9090

9191
void addImportTypes(ControllerReader reader) {
92-
if (useJsonb) {
92+
if (useInject) {
93+
reader.addImportType("io.avaje.inject.spi.GenericType");
94+
} else if (useJsonb) {
9395
reader.addImportType("io.avaje.jsonb.Types");
9496
} else if (useJackson) {
9597
reader.addImportType("com.fasterxml.jackson.core.type.TypeReference");
96-
} else if (useInject) {
97-
reader.addImportType("io.avaje.inject.spi.GenericType");
9898
}
9999
reader.addImportTypes(returnType.importTypes());
100100
method.throwsList().stream()
@@ -263,18 +263,20 @@ private void writeResponse(UType type) {
263263
}
264264

265265
void writeGeneric(UType type) {
266-
if (type.isGeneric() && useJsonb) {
266+
if (type.isGeneric() && useInject) {
267+
writer.append("new GenericType<%s>() {}.type()", type.shortType());
268+
} else if (type.isGeneric() && useJsonb) {
267269
final var params =
268-
type.importTypes().stream()
269-
.skip(1)
270-
.map(Util::shortName)
271-
.collect(Collectors.joining(".class, "));
272-
273-
writer.append("Types.newParameterizedType(%s.class, %s.class)", Util.shortName(type.mainType()), params);
270+
type.importTypes().stream()
271+
.skip(1)
272+
.map(Util::shortName)
273+
.collect(Collectors.joining(".class, "));
274+
275+
writer.append(
276+
"Types.newParameterizedType(%s.class, %s.class)",
277+
Util.shortName(type.mainType()), params);
274278
} else if (type.isGeneric() && useJackson) {
275279
writer.append("new TypeReference<%s>() {}.getType()", type.shortType());
276-
} else if (type.isGeneric() && useInject) {
277-
writer.append("new GenericType<%s>() {}.getType()", type.shortType());
278280
} else {
279281
writer.append("%s.class", Util.shortName(type.mainType()));
280282
}

http-generator-client/src/test/java/io/avaje/http/generator/client/clients/TitanFall.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.avaje.http.generator.client.clients;
22

3+
import java.util.List;
4+
import java.util.Map;
5+
36
import io.avaje.http.api.Client;
47
import io.avaje.http.api.Get;
58
import io.avaje.http.api.Headers;
@@ -12,6 +15,9 @@ public interface TitanFall {
1215
@Headers("Something: \\invalid\n\t")
1316
Titan titanFall();
1417

18+
@Get("/masterpiece")
19+
Map<String, List<Titan>> titanFall2();
20+
1521

1622
@Get("/${titan}/copium")
1723
@Headers(" Accept : applicaton/json")

0 commit comments

Comments
 (0)