Skip to content

Commit

Permalink
fixes #334 update config class to support conversion from string to i…
Browse files Browse the repository at this point in the history
…nteger and boolean (#335)
  • Loading branch information
stevehu authored Nov 25, 2023
1 parent 9bdcf84 commit e82adec
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public class OpenApiHandler implements MiddlewareHandler {

public static final String CONFIG_NAME = "openapi";
public static final String SPEC_INJECT = "openapi-inject";
public static final String HANDLER_CONFIG = "handler";

public static final AttachmentKey<Map<String, Object>> DESERIALIZED_QUERY_PARAMETERS = AttachmentKey.create(Map.class);
public static final AttachmentKey<Map<String, Object>> DESERIALIZED_PATH_PARAMETERS = AttachmentKey.create(Map.class);
public static final AttachmentKey<Map<String, Object>> DESERIALIZED_HEADER_PARAMETERS = AttachmentKey.create(Map.class);
Expand Down Expand Up @@ -112,7 +110,7 @@ public OpenApiHandler(OpenApiHandlerConfig cfg) {
if(logger.isTraceEnabled()) logger.trace("multiple specifications loaded.");
} else {
Map<String, Object> openapi = Config.getInstance().getJsonMapConfigNoCache(CONFIG_NAME);
handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
handlerConfig = HandlerConfig.load();

this.validateSpec(openapi, inject, "openapi.yml");

Expand Down Expand Up @@ -309,7 +307,8 @@ public void register() {

@Override
public void reload() {
handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
config.reload();
ModuleRegistry.registerModule(OpenApiHandlerConfig.CONFIG_NAME, OpenApiHandler.class.getName(), config.getMappedConfig(), null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@
*/
public class JwtVerifyHandler implements MiddlewareHandler, IJwtVerifyHandler {
static final Logger logger = LoggerFactory.getLogger(JwtVerifyHandler.class);

static final String HANDLER_CONFIG = "handler";
static final String OPENAPI_SECURITY_CONFIG = "openapi-security";

static final String STATUS_INVALID_AUTH_TOKEN = "ERR10000";
static final String STATUS_AUTH_TOKEN_EXPIRED = "ERR10001";
static final String STATUS_MISSING_AUTH_TOKEN = "ERR10002";
Expand All @@ -84,7 +81,7 @@ public JwtVerifyHandler() {
config = SecurityConfig.load(OPENAPI_SECURITY_CONFIG);
jwtVerifier = new JwtVerifier(config);
// in case that the specification doesn't exist, get the basePath from the handler.yml for endpoint lookup.
HandlerConfig handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
HandlerConfig handlerConfig = HandlerConfig.load();
this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
public class SwtVerifyHandler implements MiddlewareHandler {
static final Logger logger = LoggerFactory.getLogger(SwtVerifyHandler.class);
static final String OPENAPI_SECURITY_CONFIG = "openapi-security";
static final String HANDLER_CONFIG = "handler";
static final String STATUS_INVALID_AUTH_TOKEN = "ERR10000";
static final String STATUS_AUTH_TOKEN_EXPIRED = "ERR10001";
static final String STATUS_MISSING_AUTH_TOKEN = "ERR10002";
Expand Down Expand Up @@ -429,7 +428,7 @@ public SwtVerifyHandler() {
config = SecurityConfig.load(OPENAPI_SECURITY_CONFIG);
swtVerifier = new SwtVerifier(config);
// in case that the specification doesn't exist, get the basePath from the handler.yml for endpoint lookup.
HandlerConfig handlerConfig = (HandlerConfig) Config.getInstance().getJsonObjectConfig(HANDLER_CONFIG, HandlerConfig.class);
HandlerConfig handlerConfig = HandlerConfig.load();
this.basePath = handlerConfig == null ? "/" : handlerConfig.getBasePath();
}

Expand Down

0 comments on commit e82adec

Please sign in to comment.