Skip to content

New Client Name #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class ClientWriter extends BaseControllerWriter {

private static final String HTTP_CLIENT_CONTEXT = "io.avaje.http.client.HttpClientContext";
private static final String HTTP_CLIENT_CONTEXT = "io.avaje.http.client.HttpClient";
private static final String HTTP_API_PROVIDER = "io.avaje.http.client.HttpApiProvider";

private static final String AT_GENERATED = "@Generated(\"avaje-http-client-generator\")";
Expand All @@ -25,6 +25,7 @@ class ClientWriter extends BaseControllerWriter {

ClientWriter(ControllerReader reader, ProcessingContext ctx, boolean useJsonB) throws IOException {
super(reader, ctx, SUFFIX);

reader.addImportType(HTTP_CLIENT_CONTEXT);
reader.addImportType(HTTP_API_PROVIDER);
this.useJsonb = useJsonB;
Expand Down Expand Up @@ -65,7 +66,7 @@ private void writeProvider() {
writer.append(" return %s.class;", shortName).eol();
writer.append(" }").eol();
writer.append(" @Override").eol();
writer.append(" public %s provide(HttpClientContext client) {", shortName).eol();
writer.append(" public %s provide(HttpClient client) {", shortName).eol();
writer.append(" return new %s%s(client);", shortName, SUFFIX).eol();
writer.append(" }").eol();
writer.append(" }").eol();
Expand All @@ -81,9 +82,9 @@ private void writeClassStart() {
writer.append(AT_GENERATED).eol();
writer.append("public class %s%s implements %s {", shortName, SUFFIX, shortName).eol().eol();

writer.append(" private final HttpClientContext clientContext;").eol().eol();
writer.append(" private final HttpClient clientContext;").eol().eol();

writer.append(" public %s%s(HttpClientContext ctx) {", shortName, SUFFIX).eol();
writer.append(" public %s%s(HttpClient ctx) {", shortName, SUFFIX).eol();
writer.append(" this.clientContext = ctx;").eol();
writer.append(" }").eol().eol();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-client</artifactId>
<version>1.20</version>
<version>1.22</version>
</dependency>

<dependency>
Expand Down
8 changes: 4 additions & 4 deletions tests/test-client/src/test/java/org/example/SimpleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.avaje.http.client.HttpApiProvider;
import io.avaje.http.client.HttpClientContext;
import io.avaje.http.client.HttpClient;
import io.avaje.http.client.JacksonBodyAdapter;

import org.example.httpclient.GitHubUsersHttpClient;
Expand All @@ -23,8 +23,8 @@ void listRepos() {
final ObjectMapper objectMapper = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

final HttpClientContext clientContext =
HttpClientContext.builder()
final HttpClient clientContext =
HttpClient.builder()
.baseUrl("https://api.github.com")
.bodyAdapter(new JacksonBodyAdapter(objectMapper))
.build();
Expand All @@ -45,7 +45,7 @@ public Class<GitHubUsers> type() {
}

@Override
public GitHubUsers provide(HttpClientContext client) {
public GitHubUsers provide(HttpClient client) {
return new GitHubUsersHttpClient(client);
}
}
Expand Down