@@ -30,9 +30,10 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
30
30
todo: '`$friendlyName ` need to extends the [OpenapiConfig] class.' ,
31
31
);
32
32
}
33
- String separator= '?*?' ;
34
- String command = 'generate' ;
35
- String inputFile = annotation.read ('inputSpecFile' ).stringValue ?? '' ;
33
+ //print('===> ${classElement.source.}');
34
+ var separator = '?*?' ;
35
+ var command = 'generate' ;
36
+ var inputFile = annotation.read ('inputSpecFile' )? .stringValue ?? '' ;
36
37
if (inputFile.isNotEmpty) {
37
38
if (path.isAbsolute (inputFile)) {
38
39
throw InvalidGenerationSourceError (
@@ -48,7 +49,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
48
49
command = '$command $separator -i$separator ${inputFile }' ;
49
50
}
50
51
51
- var generator = annotation.read ('generator' ) .stringValue ?? 'dart' ;
52
+ var generator = annotation.read ('generatorName' ) ? .stringValue ?? 'dart' ;
52
53
command = '$command $separator -g$separator $generator ' ;
53
54
54
55
var outputDirectory = annotation.read ('outputDirectory' ).stringValue ?? '' ;
@@ -60,20 +61,30 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
60
61
}
61
62
// outputDirectory = path.absolute( Directory.current.path,outputDirectory);
62
63
if (! await FileSystemEntity .isDirectory (outputDirectory)) {
63
- new Directory (outputDirectory).create (recursive: true )
64
- // The created directory is returned as a Future.
64
+ await Directory (outputDirectory).create (recursive: true )
65
+ // The created directory is returned as a Future.
65
66
.then ((Directory directory) {
66
67
print (directory.path);
67
68
});
68
69
}
69
70
command = '$command $separator -o$separator ${outputDirectory }' ;
70
71
}
71
- var additionalProperties = annotation.read ('additionalProperties' ).mapValue;
72
- if (additionalProperties != null ) {
72
+ var additionalProperties = '' ;
73
+ annotation
74
+ .read ('additionalProperties' )
75
+ .revive ()
76
+ .namedArguments
77
+ .entries
78
+ .forEach ((entry) => {
79
+ additionalProperties =
80
+ '$additionalProperties ${additionalProperties .isEmpty ? '' : ',' }${entry .key }=${entry .value .toStringValue ()}'
81
+ });
82
+ print (additionalProperties);
83
+ if (additionalProperties != null && additionalProperties.isNotEmpty) {
73
84
command =
74
- '$command $separator --additional-properties=${additionalProperties . entries . map (( entry ) => '${ entry . key . toStringValue ()}=${ entry . value . toStringValue ()}' ). join ( ',' ) }' ;
85
+ '$command $separator --additional-properties=${additionalProperties }' ;
75
86
}
76
- command= '$command $separator -Dcolor' ;
87
+ command = '$command $separator -Dcolor' ;
77
88
78
89
print (command);
79
90
var binPath = await Isolate .resolvePackageUri (
@@ -82,9 +93,9 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
82
93
// var command = '${JAVA_OPTS} -jar "" ${arguments.join(' ')}';
83
94
84
95
print (
85
- " ${FileSystemEntity .isFileSync (binPath .toFilePath (windows : Platform .isWindows ))} exists ===>" );
96
+ ' ${FileSystemEntity .isFileSync (binPath .toFilePath (windows : Platform .isWindows ))} exists ===>' );
86
97
87
- Process .run ('java' , [
98
+ await Process .run ('java' , [
88
99
'-jar' ,
89
100
"${"${binPath .path }" }" ,
90
101
...command.split (separator).toList (),
@@ -93,17 +104,6 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
93
104
print (pr.stdout);
94
105
print (pr.stderr);
95
106
});
96
- // String arguments=command.split(" ")
97
- // var binPath = 'openapi-generator.jar';
98
- // var JAVA_OPTS = Platform.environment['JAVA_OPTS'] ?? '';
99
- // var consoleCommand = '${JAVA_OPTS} -jar "" ${arguments.join(' ')}';
100
- // Process.run('java', ["-jar", "${"${binPath}"}", ...arguments],
101
- // workingDirectory: 'bin')
102
- // .then((ProcessResult pr) {
103
- // print(pr.exitCode);
104
- // print(pr.stdout);
105
- // print(pr.stderr);
106
- // });
107
107
return '' ;
108
108
}
109
109
@@ -115,4 +115,19 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
115
115
String getMapAsString (Map <dynamic , dynamic > data) {
116
116
return data.entries.map ((entry) => '${entry .key }=${entry .value }' ).join (',' );
117
117
}
118
+
119
+ AdditionalProperties _reviveAdditionalProperties (ConstantReader read) {
120
+ var reviveable = read.revive ();
121
+ return AdditionalProperties (
122
+ allowUnicodeIdentifiers:
123
+ reviveable.namedArguments['allowUnicodeIdentifiers' ].toBoolValue ());
124
+ }
118
125
}
126
+
127
+ //abstract class RevivableInstance implements ConstantReader {
128
+ // Uri get uri;
129
+ // String get name;
130
+ // String get constructor;
131
+ // List<ConstantReader> get positionalArguments;
132
+ // Map<String, ConstantReader> get namedArguments;
133
+ //}
0 commit comments