Я пытаюсь настроить класс Apiclient, сгенерированный генератором OpenAPI, чтобы включить пользовательский перехватчик. Я хочу обновить метод inithttpclient, чтобы он включал мой класс перехвата.
Код: Выделить всё
private void initHttpClient() {
List interceptors = new ArrayList();
interceptors.add(new derrick.com.app.interceptor.TestLoggingInterceptor());
initHttpClient(interceptors);
}
Код: Выделить всё
private void initHttpClient() {
List interceptors = new ArrayList();
interceptors.add(new ()); // The interceptor package and class name is missing
initHttpClient(interceptors);
}
Код: Выделить всё
org.openapitools
openapi-generator-maven-plugin
6.6.0
${project.build.directory}/generated-sources/openapi
za.co.nedbank.groupplatform.generated.model
false
false
true
true
true
java8
true
gson
true
generate-groupcore-clients
generate
${project.basedir}/src/main/resources/swagger/Test_Swagger_v1_1235.yaml
java
okhttp-gson
derrick.com.app.generated.groupcore.client.api
derrick.com.app.generated.groupcore.client
Client
${project.basedir}/src/main/resources/openapi-templates
derrick.com.app.interceptor.TestLoggingInterceptor
true
Код: Выделить всё
package derrick.com.app.interceptor;
import lombok.extern.slf4j.Slf4j;
import okhttp3.Interceptor;
import okhttp3.Response;
import java.io.IOException;
@Slf4j
public class TestLoggingInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
log.info("Intercepting request: {}", chain.request().url());
Response response = chain.proceed(chain.request());
log.info("Received response for {}: {}", chain.request().url(), response.code());
return response;
}
}
private void initHttpClient() {
List interceptors = new ArrayList();
{{#allInterceptors}}
interceptors.add(new {{.}}());
{{/allInterceptors}}
{{^allInterceptors}}
{{#allInterceptor}}
interceptors.add(new {{{allInterceptor}}}());
{{/allInterceptor}}
{{/allInterceptors}}
initHttpClient(interceptors);
}
< /code>
Проблема: < /strong>
Несмотря на указание Allinterceptors в дополнительных продуктах, сгенерированный код неправильно разрешает имя и упаковку класса. Вместо этого он выводит new (). < /P>
Вопрос: < /strong>
Почему Allinterceptors не разрешаются в шаблоне усов?
Есть ли определенный способ прохождения и доступа к пользовательским дополнительным продуктам в шаблоне?>
Подробнее здесь: https://stackoverflow.com/questions/797 ... penapi-gen