From f0edc8e8fee7536476dc7a22a8a99cf6b6161cb9 Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Mon, 8 Dec 2025 22:11:45 +0100 Subject: [PATCH 1/6] docs(external interpolation): minor addition --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index 2f41e583..3080504a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -846,6 +846,7 @@ config: ``` This means every configuration key will be searched in env vars, with the `spectrum` prefix and words delimited by a dot. +The name of the variable to resolve is the json path of the corresponding configuration key. For instance, you can inject the `application.baseUrl` setting an env variable named `spectrum.application.baseUrl`. To give you another example, you can use this config to inject env vars like `APPLICATION_BASEURL`: @@ -903,6 +904,7 @@ config: ``` This means every configuration key will be searched in system properties, with the `spectrum` prefix and words delimited by a dot. +The name of the variable to resolve is the json path of the corresponding configuration key. For instance, you can inject the `application.baseUrl` setting the system property `-Dspectrum.application.baseUrl`. To give you another example, you can use this config to inject system properties like `-DAPPLICATION_BASEURL`: From 4efdb621afd2ef60e1c24550274c90eef260efb8 Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Tue, 9 Dec 2025 17:06:03 +0100 Subject: [PATCH 2/6] docs(external interpolation): clarifying the in-place interpolation is the only one working with data.yaml --- docs/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/README.md b/docs/README.md index 3080504a..79ffa316 100644 --- a/docs/README.md +++ b/docs/README.md @@ -669,6 +669,9 @@ The other keys are explained in the corresponding sections. ### In-place Interpolation +> ⚠️ **Interpolating data*.yaml**
+> The `in-place interpolation` is the only way to inject values into the `data*.yaml`, other interpolators won't work. + You can interpolate values directly in the `configuration*.yaml` and `data*.yaml` with a dollar-string in one of the following two ways, depending on the type needed as result. Let's suppose we have the variable `key = 123`: From b9fafb07a2daee6afcbf5fd4e03230fe37323b30 Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Wed, 10 Dec 2025 16:42:05 +0100 Subject: [PATCH 3/6] build: skipping tests when generating json schema in deploy gh action --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 70d4c206..9c8138dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -73,7 +73,7 @@ jobs: - name: Generate new public Json Schema shell: bash - run: ./mvnw install -Dmaven.plugin.validation=NONE -DskipSign -ntp -P framework-only + run: ./mvnw install -DskipTests -Dmaven.plugin.validation=NONE -DskipSign -ntp -P framework-only - name: Commit files and generate new tag run: | From d9ab46192296664087354504becc1df287a6be2c Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Thu, 11 Dec 2025 13:16:50 +0100 Subject: [PATCH 4/6] refactor(external interpolation)!: removing ExternalInterpolator.transformCase value --- it/src/test/resources/configuration.yaml | 2 +- .../interpolators/ExternalInterpolator.java | 15 +++------------ .../resources/yaml/configuration.default.yaml | 4 ++-- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/it/src/test/resources/configuration.yaml b/it/src/test/resources/configuration.yaml index 55a8dfed..9fa6a229 100644 --- a/it/src/test/resources/configuration.yaml +++ b/it/src/test/resources/configuration.yaml @@ -3,7 +3,7 @@ config: environment: priority: 10 delimiter: _ - transformCase: upper + transformCase: UPPER properties: { } application: diff --git a/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/deserializers/interpolation/interpolators/ExternalInterpolator.java b/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/deserializers/interpolation/interpolators/ExternalInterpolator.java index e63fe011..ad961fb1 100644 --- a/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/deserializers/interpolation/interpolators/ExternalInterpolator.java +++ b/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/deserializers/interpolation/interpolators/ExternalInterpolator.java @@ -9,12 +9,10 @@ import java.util.function.Function; import com.fasterxml.jackson.annotation.JsonPropertyDescription; -import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonStreamContext; import lombok.AllArgsConstructor; -import lombok.Generated; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -73,17 +71,10 @@ void getKeyPathTokens(final List accumulator, final JsonStreamContext co @AllArgsConstructor enum TransformCase { - NONE("none", s -> s), - LOWER("lower", String::toLowerCase), - UPPER("upper", String::toUpperCase); + NONE(s -> s), + LOWER(String::toLowerCase), + UPPER(String::toUpperCase); - private final String value; private final Function function; - - @JsonValue - @Generated - public String getValue() { - return value; - } } } diff --git a/spectrum/src/main/resources/yaml/configuration.default.yaml b/spectrum/src/main/resources/yaml/configuration.default.yaml index ad251611..0b5bb465 100644 --- a/spectrum/src/main/resources/yaml/configuration.default.yaml +++ b/spectrum/src/main/resources/yaml/configuration.default.yaml @@ -5,12 +5,12 @@ config: priority: 0 # Sets the order of evaluation of this interpolator among others. Higher priority wins. prefix: spectrum # Variable prefix delimiter: . # Variable tokens' delimiter - transformCase: none # Function to specify how to transform the original camelCase of the key to match the external variable to search + transformCase: NONE # Function to specify how to transform the original camelCase of the key to match the external variable to search properties: # Properties interpolator priority: 1 # Sets the order of evaluation of this interpolator among others. Higher priority wins. prefix: spectrum # Variable prefix delimiter: . # Variable tokens' delimiter - transformCase: none # Function to specify how to transform the original camelCase of the key to match the external variable to search + transformCase: NONE # Function to specify how to transform the original camelCase of the key to match the external variable to search inPlace: # In-place configuration file interpolator priority: 2 # Sets the order of evaluation of this interpolator among others. Higher priority wins. enabled: true From f0cca77f9dd88d4dc7cd95ec3e7f769085391784 Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Thu, 11 Dec 2025 13:18:15 +0100 Subject: [PATCH 5/6] refactor: setting Configuration.config field as transient instead of json-ignore it to have it added to the json schema --- .../json_schema/JsonSchemaInternalGeneratorModule.java | 5 ++++- .../java/io/github/giulong/spectrum/utils/Configuration.java | 3 +-- .../java/io/github/giulong/spectrum/utils/YamlUtils.java | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/json_schema/JsonSchemaInternalGeneratorModule.java b/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/json_schema/JsonSchemaInternalGeneratorModule.java index f81eed93..f495e1f1 100644 --- a/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/json_schema/JsonSchemaInternalGeneratorModule.java +++ b/spectrum/src/main/java/io/github/giulong/spectrum/internals/jackson/json_schema/JsonSchemaInternalGeneratorModule.java @@ -37,7 +37,10 @@ public void applyToConfigBuilder(final SchemaGeneratorConfigBuilder schemaGenera protected SchemaGeneratorConfigBuilder commonSetupFor(final SchemaGeneratorConfigBuilder schemaGeneratorConfigBuilder) { schemaGeneratorConfigBuilder .with(new JacksonModule(SKIP_SUBTYPE_LOOKUP, FLATTENED_ENUMS_FROM_JSONVALUE)) - .with(FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT, MAP_VALUES_AS_ADDITIONAL_PROPERTIES, NULLABLE_FIELDS_BY_DEFAULT); + .with(FORBIDDEN_ADDITIONAL_PROPERTIES_BY_DEFAULT, + MAP_VALUES_AS_ADDITIONAL_PROPERTIES, + TRANSIENT_FIELDS, + NULLABLE_FIELDS_BY_DEFAULT); schemaGeneratorConfigBuilder .forFields() diff --git a/spectrum/src/main/java/io/github/giulong/spectrum/utils/Configuration.java b/spectrum/src/main/java/io/github/giulong/spectrum/utils/Configuration.java index 2d101b27..e2388bb2 100644 --- a/spectrum/src/main/java/io/github/giulong/spectrum/utils/Configuration.java +++ b/spectrum/src/main/java/io/github/giulong/spectrum/utils/Configuration.java @@ -41,9 +41,8 @@ public class Configuration { private static final Configuration INSTANCE = new Configuration(); @Setter - @JsonIgnore @JsonPropertyDescription("Generic configuration. This node is read only from the base configuration.yaml") - private Config config; + private transient Config config; @JsonPropertyDescription("Common vars to interpolate other String values in the configuration") private Map vars; diff --git a/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java b/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java index 484a3090..eee0f5cb 100644 --- a/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java +++ b/spectrum/src/main/java/io/github/giulong/spectrum/utils/YamlUtils.java @@ -1,5 +1,6 @@ package io.github.giulong.spectrum.utils; +import static com.fasterxml.jackson.databind.MapperFeature.PROPAGATE_TRANSIENT_MARKER; import static com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS; import static lombok.AccessLevel.PRIVATE; @@ -45,6 +46,7 @@ public final class YamlUtils { private final ObjectMapper yamlMapper = YAMLMapper .builder() .defaultMergeable(true) + .configure(PROPAGATE_TRANSIENT_MARKER, true) .addModules( new JavaTimeModule(), buildModuleFor(Object.class, InterpolatedObjectDeserializer.getInstance()), From af5bafdf0d6c7cdaca581833703a15541dd942f4 Mon Sep 17 00:00:00 2001 From: Giulio Longfils Date: Thu, 11 Dec 2025 13:24:02 +0100 Subject: [PATCH 6/6] docs(external interpolation): updating occurrences of transformCase in code snippets to use the upper case enum key as value --- docs/README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/README.md b/docs/README.md index 79ffa316..b01c2799 100644 --- a/docs/README.md +++ b/docs/README.md @@ -648,12 +648,12 @@ config: priority: 0 # Sets the order of evaluation of this interpolator among others. Higher priority wins. prefix: spectrum # Variable prefix delimiter: . # Variable tokens' delimiter - transformCase: none # Function to specify how to transform the original camelCase of the key to match the external variable to search + transformCase: NONE # Function to specify how to transform the original camelCase of the key to match the external variable to search properties: # Properties interpolator priority: 1 # Sets the order of evaluation of this interpolator among others. Higher priority wins. prefix: spectrum # Variable prefix delimiter: . # Variable tokens' delimiter - transformCase: none # Function to specify how to transform the original camelCase of the key to match the external variable to search + transformCase: NONE # Function to specify how to transform the original camelCase of the key to match the external variable to search inPlace: # In-place configuration file interpolator priority: 2 # Sets the order of evaluation of this interpolator among others. Higher priority wins. enabled: true @@ -845,7 +845,7 @@ config: priority: 0 prefix: spectrum delimiter: . - transformCase: none + transformCase: NONE ``` This means every configuration key will be searched in env vars, with the `spectrum` prefix and words delimited by a dot. @@ -862,16 +862,16 @@ config: environment: prefix: '' delimiter: _ - transformCase: upper + transformCase: UPPER ``` Allowed values for the `transformCase` property are: | Value | Description | Example | |---------|-----------------------------------------------------------------------------------|---------------------| -| `none` | searches a key with the same case of the property, which is `camelCase` (default) | application.baseUrl | -| `lower` | searches a lowercase key | application.baseurl | -| `upper` | searches a uppercase key | APPLICATION.BASEURL | +| `NONE` | searches a key with the same case of the property, which is `camelCase` (default) | application.baseUrl | +| `LOWER` | searches a lowercase key | application.baseurl | +| `UPPER` | searches a uppercase key | APPLICATION.BASEURL | > ⚠️ **Priority**
> Pay attention to the priority: by default, the `inPlace` interpolator takes precedence over this one. @@ -903,7 +903,7 @@ config: priority: 1 prefix: spectrum delimiter: . - transformCase: none + transformCase: NONE ``` This means every configuration key will be searched in system properties, with the `spectrum` prefix and words delimited by a dot. @@ -920,16 +920,16 @@ config: properties: prefix: '' delimiter: _ - transformCase: upper + transformCase: UPPER ``` Allowed values for the `transformCase` property are: | Value | Description | Example | |---------|-----------------------------------------------------------------------------------|---------------------| -| `none` | searches a key with the same case of the property, which is `camelCase` (default) | application.baseUrl | -| `lower` | searches a lowercase key | application.baseurl | -| `upper` | searches a uppercase key | APPLICATION.BASEURL | +| `NONE` | searches a key with the same case of the property, which is `camelCase` (default) | application.baseUrl | +| `LOWER` | searches a lowercase key | application.baseurl | +| `UPPER` | searches a uppercase key | APPLICATION.BASEURL | > ⚠️ **Priority**
> Pay attention to the priority: by default, the `inPlace` interpolator takes precedence over this one.