GeneratorConfig.fromYaml constructor
GeneratorConfig.fromYaml(
- String yamlContent
Implementation
factory GeneratorConfig.fromYaml(String yamlContent) {
final yaml = loadYaml(yamlContent) as YamlMap?;
if (yaml == null) return GeneratorConfig();
final generate = yaml['generate'] as YamlMap?;
final api = yaml['api'] as YamlMap?;
final endpointsYaml = yaml['endpoints'] as YamlList?;
final endpointList = <ApiEndpoint>[];
if (endpointsYaml != null) {
for (var item in endpointsYaml) {
if (item is YamlMap) {
endpointList.add(ApiEndpoint.fromYaml(item));
}
}
}
return GeneratorConfig(
modelsPath: yaml['models_path'] ?? 'lib/models',
servicesPath: yaml['services_path'] ?? 'lib/services',
repositoriesPath: yaml['repositories_path'] ?? 'lib/repositories',
apiPath: yaml['api_path'] ?? 'lib/api',
generateService: generate?['service'] ?? false,
generateRepository: generate?['repository'] ?? false,
httpClient: yaml['http_client'] ?? 'http',
baseUrl: api?['base_url'],
endpoints: endpointList,
);
}