avaje/avaje-http

Support List/Array Types in client generation

SentryMan opened this issue · 2 comments

The following fails to compile.

@Client
public interface ApiClient {

  @Post("/post")
  HttpResponse<byte[]> call(Holder[] body);

  @Post("/post2")
  HttpResponse<byte[]> call2(List<Holder> body);

  public static record Holder(int s) {}
}

It seems that imports are not being added correctly to the generated client.

import com.jojo.javalin.api.client.ApiClient;
import com.jojo.javalin.api.client.ApiClient.Holder[];
import io.avaje.http.api.*;
import io.avaje.http.client.HttpApiProvider;
import io.avaje.http.client.HttpClientContext;
import java.net.http.HttpResponse;
import java.util.List;

@Generated("avaje-http-client-generator")
public class ApiClientHttpClient implements ApiClient {

  private final HttpClientContext clientContext;

  public ApiClientHttpClient(HttpClientContext ctx) {
    this.clientContext = ctx;
  }

  // POST /post
  @Override
  public HttpResponse<byte[]> call(Holder[] body) {
    return clientContext.request()
      .path("post")
      .body(body)
      .POST()
      .asByteArray();
  }

  // POST /post2
  @Override
  public HttpResponse<byte[]> call2(List<Holder> body) {
    return clientContext.request()
      .path("post2")
      .body(body)
      .POST()
      .asByteArray();
  }
... rest of the generation is fine

It seems that 1.20 is still unavailable on maven

Ah, they were sitting there in staging. I've just released them now.

I need to adjust the pom so that they auto-release from staging ...