yongjhih / NotRetrofit

Type-safe REST client for Android and Java
Apache License 2.0
93 stars 12 forks source link

@Header parameter not being generated #2

Closed kenkyee closed 9 years ago

kenkyee commented 9 years ago

I'm defining it like this: @DELETE("/api/token") public abstract BaseResponse logout(@Retrofit.Header(Endpoints.HTTPHEADER_TOKEN) String authToken);

generated code doesn't have anything that looks at this header :-(

        HttpUrl httpUrl = httpUrlBuilder.build();
        Request.Builder requestBuilder = new Request.Builder().url(httpUrl);
        final String _finalUrl = httpUrl.toString();
        String bodyString = null;
        requestBuilder.delete();
        Request request = requestBuilder.build();
        Observable<Request> requestObs = Observable.just(request);
        System.out.println("retrofit: logout");
        final String finalBodyString = bodyString;
        requestObs = requestObs.map(new Func1<Request, Request>() {
            @Override public Request call(Request request) {
                System.out.println("retrofit: log");
                if (logLevel.log()) {
                    // Log the request data.
                    try {
                        return logAndReplaceRequest("HTTP", request, finalBodyString);
                    } catch (IOException e) {
                        throw retrofit.RetrofitError.unexpectedError(request.urlString(), e);
                    }
                }
                return request;
            }
        });
        Observable<com.squareup.okhttp.Response> responseCachedObs = requestObs.flatMap(new Func1<Request, Observable<com.squareup.okhttp.Response>>() {
            @Override public Observable<com.squareup.okhttp.Response> call(Request request) {
                System.out.println("retrofit: responseCachedObs");
                return Observable.create(new OnSubscribeResponse(okHttpClient, request));
            }
        })
        .cache();
        Observable<BaseResponse> obs;
        obs = responseCachedObs.map(new Func1<com.squareup.okhttp.Response, String>() {
            @Override public String call(com.squareup.okhttp.Response response) {
                try {
                    return response.body().string();
                } catch (Exception e) {
                    //throw new RuntimeException(e);
                    throw retrofit.RetrofitError.unexpectedError(_finalUrl, e);
                }
            }
        }).filter(new Func1<String, Boolean>() {
            @Override public Boolean call(String json) {
                return json != null;
            }
        }).map(new Func1<String, BaseResponse>() {
            @Override public BaseResponse call(String json) {
                // TODO Using RetrofitConveter
                try {
                    if (logLevel.ordinal() >= LogLevel.FULL.ordinal()) {
                        log.log(json);
                    }
                    Type type = new TypeToken<BaseResponse>(){}.getType();
                    return (BaseResponse) finalConverter.fromBody(new JsonTypedInput(json), type);
                } catch (Exception e) {
                    //throw new RuntimeException(e);
                    throw retrofit.RetrofitError.unexpectedError(_finalUrl, e);
                }
            }
        }).filter(new Func1<BaseResponse, Boolean>() {
            @Override public Boolean call(BaseResponse object) {
                return object != null;
            }
        });
        Observable<retrofit.client.Response> retrofitResponseObs = responseCachedObs.map(new Func1<com.squareup.okhttp.Response, retrofit.client.Response>() {
            @Override public retrofit.client.Response call(com.squareup.okhttp.Response response) {
                return parseResponse(response);
            }
        });
        return obs
            .subscribeOn(Schedulers.io()).toBlocking().single();
yongjhih commented 9 years ago

Thanks for your report. I fixed: 8b285fad3035f3878f72ddf00f272ae8aed81a51

kenkyee commented 9 years ago

Thanks for the quick fix :-)