Skip to content

Commit fd4d04e

Browse files
committed
support subtypes
1 parent 94c52af commit fd4d04e

File tree

6 files changed

+34
-12
lines changed

6 files changed

+34
-12
lines changed

http-client/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@
2929
<dependency>
3030
<groupId>com.fasterxml.jackson.core</groupId>
3131
<artifactId>jackson-databind</artifactId>
32-
<version>2.14.1</version>
32+
<version>2.14.2</version>
3333
<optional>true</optional>
3434
</dependency>
3535

3636
<dependency>
3737
<groupId>io.avaje</groupId>
3838
<artifactId>avaje-jsonb</artifactId>
39-
<version>1.1</version>
39+
<version>1.3</version>
4040
<optional>true</optional>
4141
</dependency>
4242

4343
<dependency>
4444
<groupId>io.avaje</groupId>
4545
<artifactId>avaje-inject</artifactId>
46-
<version>8.12-RC1</version>
46+
<version>8.13</version>
4747
<optional>true</optional>
4848
</dependency>
4949

http-client/src/main/java/io/avaje/http/client/DHttpClientContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest.Builder requestBuil
265265
return httpClient.sendAsync(requestBuilder.build(), bodyHandler);
266266
}
267267

268-
<T> BodyContent write(T bean, String contentType) {
269-
return bodyAdapter.beanWriter(bean.getClass()).write(bean, contentType);
268+
<T> BodyContent write(T bean, Class<?> type, String contentType) {
269+
return bodyAdapter.beanWriter(type).write(bean, contentType);
270270
}
271271

272272
<T> BodyReader<T> beanReader(Class<T> type) {

http-client/src/main/java/io/avaje/http/client/DHttpClientRequest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,26 @@ public HttpClientRequest body(BodyContent bodyContent) {
265265
return this;
266266
}
267267

268+
@Override
269+
public HttpClientRequest body(Object bean) {
270+
return body(bean, bean.getClass(), null);
271+
}
272+
268273
@Override
269274
public HttpClientRequest body(Object bean, String contentType) {
270-
encodedRequestBody = context.write(bean, contentType);
271-
return this;
275+
276+
return body(bean, bean.getClass(), contentType);
272277
}
273278

274279
@Override
275-
public HttpClientRequest body(Object bean) {
276-
return body(bean, null);
280+
public HttpClientRequest body(Object bean, Class<?> type) {
281+
return body(bean, type, null);
282+
}
283+
284+
@Override
285+
public HttpClientRequest body(Object bean, Class<?> type, String contentType) {
286+
encodedRequestBody = context.write(bean, type, contentType);
287+
return this;
277288
}
278289

279290
@Override

http-client/src/main/java/io/avaje/http/client/HttpClientRequest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,17 @@ default HttpClientRequest queryParam(String name, Collection<String> values) {
298298
*/
299299
HttpClientRequest body(Object bean);
300300

301+
/**
302+
* Set the body as a bean with the given content type using a BodyWriter.
303+
* Used for JsonbAdapter
304+
*/
305+
HttpClientRequest body(Object bean, Class<?> type);
306+
307+
/**
308+
* Set the body as a bean with the given content type using a BodyWriter.
309+
*/
310+
HttpClientRequest body(Object bean, Class<?> type, String contentType);
311+
301312
/**
302313
* Set the body content as a string.
303314
*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ private void writeBody() {
251251
for (MethodParam param : method.params()) {
252252
ParamType paramType = param.paramType();
253253
if (paramType == ParamType.BODY) {
254-
writer.append(" .body(%s)", param.name()).eol();
254+
writer.append(" .body(%s, %s.class)", param.name(), param.utype().shortType()).eol();
255255
}
256256
}
257257
}

http-generator-core/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<dependency>
1414
<groupId>io.avaje</groupId>
1515
<artifactId>avaje-prisms</artifactId>
16-
<version>1.5</version>
16+
<version>1.6</version>
1717
<optional>true</optional>
1818
<scope>provided</scope>
1919
</dependency>
@@ -81,7 +81,7 @@
8181
<path>
8282
<groupId>io.avaje</groupId>
8383
<artifactId>avaje-prisms</artifactId>
84-
<version>1.5</version>
84+
<version>1.6</version>
8585
</path>
8686
</annotationProcessorPaths>
8787
</configuration>

0 commit comments

Comments
 (0)