Skip to content

Commit

Permalink
(fix) Fixed a bug loading the Kotlinx Module without use-fqn variable
Browse files Browse the repository at this point in the history
When the Kotlinx Serialization Module was available in an environment without the `springwolf.use-fqn` the code was failing, since it was trying to inject the variable.

The code is now loading the converter **only** if `springwolf.enabled` is `true` (default value). The `springwolf.use-fqn` is also defaulting to `true`.

This solution fixes the identified issue.
  • Loading branch information
ctasada committed May 1, 2024
1 parent d844219 commit 70d8f2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ plugins {
}

dependencies {
api project(":springwolf-core")

implementation "org.springframework:spring-context"
implementation "org.springframework:spring-beans"
implementation "org.springframework.boot:spring-boot-autoconfigure"

implementation "io.swagger.core.v3:swagger-core-jakarta:${swaggerVersion}"
implementation "io.swagger.core.v3:swagger-models-jakarta:${swaggerVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
package io.github.springwolf.addons.kotlinx_serialization_model_converter.configuration;

import io.github.springwolf.addons.kotlinx_serialization_model_converter.converter.KotlinxSerializationModelConverter;
import io.github.springwolf.core.configuration.properties.SpringwolfConfigConstants;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static io.github.springwolf.core.configuration.properties.SpringwolfConfigConstants.SPRINGWOLF_USE_FQN;

/**
* Spring AutoConfiguration adding an {@link KotlinxSerializationModelConverter} Bean to the spring context.
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnProperty(name = SpringwolfConfigConstants.SPRINGWOLF_ENABLED, havingValue = "true", matchIfMissing = true)
public class KotlinxSerializationModelConverterAutoConfiguration {

@Bean
public KotlinxSerializationModelConverter kotlinxSerializationTypeConverter(
@Value("${springwolf.use-fqn}") boolean useFqn) {
@Value("${" + SPRINGWOLF_USE_FQN + ":true}") boolean useFqn) {
return new KotlinxSerializationModelConverter(useFqn);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class SpringwolfConfigConstants {

public static final String SPRINGWOLF_ENABLED = SPRINGWOLF_CONFIG_PREFIX + ENABLED;

public static final String SPRINGWOLF_USE_FQN = SPRINGWOLF_CONFIG_PREFIX + ".use-fqn";

public static final String ENDPOINT_ACTUATOR = ".endpoint.actuator";

public static final String SPRINGWOLF_ENDPOINT_ACTUATOR_ENABLED =
Expand Down

0 comments on commit 70d8f2d

Please sign in to comment.