validateConfiguration method
Validates configuration compatibility and constraints.
Ensures that the combination of configuration options is valid and follows the expected patterns.
Parameters:
config: The API generation configuration to validate
Throws ConfigurationException if configuration is invalid
Implementation
void validateConfiguration(ApiGenerationConfig config) {
// Validate cache strategy is only used with compatible methods
if (config.cacheStrategy != null && !_isApplyCacheStrategy(config.method)) {
throw ConfigurationException(
'Cache strategy cannot be used with method "${config.method}". '
'Cache strategies are not supported for multipart and SSE methods.');
}
// Validate TTL is only provided when cache strategy is set
if (config.ttl != null && config.cacheStrategy == null) {
throw ConfigurationException(
'TTL can only be specified when a cache strategy is provided.');
}
// Validate keep expired cache is only provided when cache strategy is set
if (config.keepExpiredCache != null && config.cacheStrategy == null) {
throw ConfigurationException(
'Keep expired cache can only be specified when a cache strategy is provided.');
}
// Validate body list is not used with multipart methods
if (config.bodyList && _isMultipart(config.method)) {
throw ConfigurationException(
'Body list cannot be used with multipart methods.');
}
}