|
|
@ -861,24 +861,35 @@ class OpenAPIBuilder implements Builder { |
|
|
|
final formatter = DartFormatter( |
|
|
|
final formatter = DartFormatter( |
|
|
|
pageWidth: 120, |
|
|
|
pageWidth: 120, |
|
|
|
); |
|
|
|
); |
|
|
|
await buildStep.writeAsString( |
|
|
|
const coverageIgnoreStart = ' // coverage:ignore-start'; |
|
|
|
outputId, |
|
|
|
const coverageIgnoreEnd = ' // coverage:ignore-end'; |
|
|
|
formatter.format( |
|
|
|
final patterns = [ |
|
|
|
output |
|
|
|
RegExp( |
|
|
|
.join('\n') |
|
|
|
r'factory .*\.fromJson\(Map<String, dynamic> json\) => _\$.*FromJson\(json\);', |
|
|
|
.replaceAll( |
|
|
|
), |
|
|
|
'Map<String, dynamic> toJson()', |
|
|
|
RegExp( |
|
|
|
' // coverage:ignore-start\nMap<String, dynamic> toJson()', |
|
|
|
r'Map<String, dynamic> toJson\(\) => _\$.*ToJson\(this\);', |
|
|
|
) |
|
|
|
), |
|
|
|
.replaceAll( |
|
|
|
RegExp( |
|
|
|
'ToJson(this);', |
|
|
|
r'factory .*\.fromJsonString\(String data\) => .*\.fromJson\(json\.decode\(data\)(?: as Map<String, dynamic>)?\);', |
|
|
|
'ToJson(this);\n // coverage:ignore-end\n', |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.replaceAll( |
|
|
|
|
|
|
|
'dynamic toJson() => _data;', |
|
|
|
|
|
|
|
' // coverage:ignore-start\ndynamic toJson() => _data;\n // coverage:ignore-end\n', |
|
|
|
|
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
RegExp( |
|
|
|
|
|
|
|
r'static String toJsonString\(.* data\) => json\.encode\(data(?:\.toJson\(\))?\);', |
|
|
|
), |
|
|
|
), |
|
|
|
|
|
|
|
RegExp( |
|
|
|
|
|
|
|
r'dynamic toJson\(\) => _data;', |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
var outputString = output.join('\n'); |
|
|
|
|
|
|
|
for (final pattern in patterns) { |
|
|
|
|
|
|
|
outputString = outputString.replaceAllMapped( |
|
|
|
|
|
|
|
pattern, |
|
|
|
|
|
|
|
(final match) => '$coverageIgnoreStart\n${match.group(0)}\n$coverageIgnoreEnd', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
await buildStep.writeAsString( |
|
|
|
|
|
|
|
outputId, |
|
|
|
|
|
|
|
formatter.format(outputString), |
|
|
|
); |
|
|
|
); |
|
|
|
} catch (e, s) { |
|
|
|
} catch (e, s) { |
|
|
|
print(s); |
|
|
|
print(s); |
|
|
|