This commit is contained in:
Max 2026-01-12 15:51:36 +08:00
parent 4df56bb5f0
commit 9fa88e9821
2 changed files with 8 additions and 2 deletions

View File

@ -66,6 +66,11 @@ class ConfigRepository {
static ConfigRepository? _cachedConfig; static ConfigRepository? _cachedConfig;
///
static void setCachedConfig(ConfigRepository config) {
_cachedConfig = config;
}
/// ///
/// ///
static ConfigRepository loadSync([String? configPath]) { static ConfigRepository loadSync([String? configPath]) {

View File

@ -79,8 +79,9 @@ generation:
// Force a reload of the static config by accessing it. // Force a reload of the static config by accessing it.
// This is a bit of a hack due to the static nature of SwaggerConfig and StringHelper. // This is a bit of a hack due to the static nature of SwaggerConfig and StringHelper.
// A better approach would be to pass the config explicitly or mock the static dependencies. // A better approach would be to pass the config explicitly or mock the static dependencies.
ConfigRepository.loadSync(configFile // Load config and set it as cached so static accessors pick it up
.path); // Ensure the config is loaded for the static accessor final config = ConfigRepository.loadSync(configFile.path);
ConfigRepository.setCachedConfig(config);
expect(StringHelper.generateClassName('User'), 'SUser'); expect(StringHelper.generateClassName('User'), 'SUser');
expect(StringHelper.generateClassName('model'), 'SModel'); expect(StringHelper.generateClassName('model'), 'SModel');