processConfiguration method

ApiGenerationConfig processConfiguration(
  1. ApiGenerationConfig config
)

Processes and normalizes configuration options.

Applies business rules and defaults to ensure configuration is consistent and ready for generation.

Parameters:

  • config: The API generation configuration to process

Returns processed ApiGenerationConfig

Implementation

ApiGenerationConfig processConfiguration(ApiGenerationConfig config) {
  // Apply method-specific adjustments
  // Determine if cache strategy should be applied
  final shouldApplyCacheStrategy = isApplyCacheStrategy(config.method);

  // Create a new config with appropriate values
  return ApiGenerationConfig(
    apiName: config.apiName,
    featureName: config.featureName,
    pageName: config.pageName,
    method: config.method,
    pathPage: config.pathPage,
    projectName: config.projectName,
    returnData: config.returnData,
    appsName: config.appsName,
    pathUrl: config.pathUrl,
    headerPath: config.headerPath,
    json2dart: config.json2dart,
    bodyList: config.bodyList && !isMultipart(config.method),
    responseList: config.responseList,
    // Remove cache strategy for methods that don't support it
    cacheStrategy: shouldApplyCacheStrategy ? config.cacheStrategy : null,
    ttl: shouldApplyCacheStrategy ? config.ttl : null,
    keepExpiredCache:
        shouldApplyCacheStrategy ? config.keepExpiredCache : null,
  );
}