From 24a538e5cc5f377a44fb1b10d7b5eb586fb4ad81 Mon Sep 17 00:00:00 2001 From: Mayank Rai Date: Wed, 16 Jul 2025 18:45:47 +0530 Subject: [PATCH] fix: add jsonpath Option while parsing template --- .../firehose/config/HttpSinkConfig.java | 13 +++++----- ...pJsonBodyTemplateParseOptionConverter.java | 14 ++++++++++ .../serializer/MessageToTemplatizedJson.java | 26 ++++++++++++++++--- .../sink/http/factory/SerializerFactory.java | 2 +- 4 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/gotocompany/firehose/config/converter/HttpJsonBodyTemplateParseOptionConverter.java diff --git a/src/main/java/com/gotocompany/firehose/config/HttpSinkConfig.java b/src/main/java/com/gotocompany/firehose/config/HttpSinkConfig.java index e59a05196..2830fac79 100644 --- a/src/main/java/com/gotocompany/firehose/config/HttpSinkConfig.java +++ b/src/main/java/com/gotocompany/firehose/config/HttpSinkConfig.java @@ -1,15 +1,11 @@ package com.gotocompany.firehose.config; -import com.gotocompany.firehose.config.converter.HttpSinkSerializerJsonTypecastConfigConverter; +import com.gotocompany.firehose.config.converter.*; import com.gotocompany.firehose.config.enums.HttpSinkDataFormatType; import com.gotocompany.firehose.config.enums.HttpSinkParameterPlacementType; import com.gotocompany.firehose.config.enums.HttpSinkParameterSourceType; import com.gotocompany.firehose.config.enums.HttpSinkRequestMethodType; -import com.gotocompany.firehose.config.converter.HttpSinkRequestMethodConverter; -import com.gotocompany.firehose.config.converter.HttpSinkParameterDataFormatConverter; -import com.gotocompany.firehose.config.converter.HttpSinkParameterPlacementTypeConverter; -import com.gotocompany.firehose.config.converter.HttpSinkParameterSourceTypeConverter; -import com.gotocompany.firehose.config.converter.RangeToHashMapConverter; +import com.jayway.jsonpath.Option; import java.util.Map; import java.util.function.Function; @@ -80,6 +76,11 @@ public interface HttpSinkConfig extends AppConfig { @DefaultValue("") String getSinkHttpJsonBodyTemplate(); + @Key("SINK_HTTP_JSON_BODY_TEMPLATE_PARSE_OPTION") + @DefaultValue("") + @ConverterClass(HttpJsonBodyTemplateParseOptionConverter.class) + Option getSinkHttpJsonBodyTemplateParseOption(); + @Key("SINK_HTTP_PARAMETER_PLACEMENT") @DefaultValue("header") @ConverterClass(HttpSinkParameterPlacementTypeConverter.class) diff --git a/src/main/java/com/gotocompany/firehose/config/converter/HttpJsonBodyTemplateParseOptionConverter.java b/src/main/java/com/gotocompany/firehose/config/converter/HttpJsonBodyTemplateParseOptionConverter.java new file mode 100644 index 000000000..6092ab08d --- /dev/null +++ b/src/main/java/com/gotocompany/firehose/config/converter/HttpJsonBodyTemplateParseOptionConverter.java @@ -0,0 +1,14 @@ +package com.gotocompany.firehose.config.converter; + +import com.jayway.jsonpath.Option; +import org.aeonbits.owner.Converter; + +import java.lang.reflect.Method; + +public class HttpJsonBodyTemplateParseOptionConverter implements Converter