generateQueriesClass method
Implementation
String generateQueriesClass(
List<OpenApiPathMethodParameter> queries,
String name,
) {
final generator = OpenApiModelGenerator(config: config);
final className = '${name}Queries';
final params = queries.map((e) {
return MapEntry(e.name, e.schema);
}).toList();
final result = generator.run(
MapEntry(
className,
OpenApiSchemas(
type: 'object',
properties: Map.fromIterable(
params,
key: (e) => e.key,
value: (e) => e.value,
),
),
),
);
if (!Directory(config.modelsOutputDirectory).existsSync()) {
Directory(config.modelsOutputDirectory).createSync(recursive: true);
}
final filepath = path.join(
config.modelsOutputDirectory,
'${config.renameFile(className)}.dart',
);
final file = File(filepath);
file.writeAsString(result.content);
print('Generated: $filepath');
return className;
}