File tree Expand file tree Collapse file tree 2 files changed +31
-13
lines changed
openapi-generator/lib/src Expand file tree Collapse file tree 2 files changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,11 @@ class GeneratorArguments {
47
47
/// Default: false
48
48
final bool skipValidation;
49
49
50
+ /// Write the last run placeholder to the annotated file.
51
+ ///
52
+ /// Default: true
53
+ final bool updateAnnotatedFile;
54
+
50
55
/// Provides an OAS spec file.
51
56
///
52
57
/// When the [useNextGen] flag is set this should be the spec file configuration
@@ -104,6 +109,8 @@ class GeneratorArguments {
104
109
annotations.readPropertyOrDefault ('runSourceGenOnOutput' , true ),
105
110
shouldFetchDependencies =
106
111
annotations.readPropertyOrDefault ('fetchDependencies' , true ),
112
+ updateAnnotatedFile =
113
+ annotations.readPropertyOrDefault ('updateAnnotatedFile' , true ),
107
114
outputDirectory = annotations.readPropertyOrNull ('outputDirectory' ),
108
115
cachePath =
109
116
annotations.readPropertyOrDefault ('cachePath' , defaultCachedPath),
Original file line number Diff line number Diff line change @@ -220,24 +220,35 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
220
220
),
221
221
),
222
222
);
223
- await updateAnnotatedFile (annotatedPath: annotatedPath).then (
224
- (_) => logOutputMessage (
225
- log: log,
226
- communication: OutputMessage (
227
- message: 'Successfully updated annotated file.' ,
228
- level: Level .CONFIG ,
223
+ if (args.updateAnnotatedFile) {
224
+ await updateAnnotatedFile (annotatedPath: annotatedPath).then (
225
+ (_) => logOutputMessage (
226
+ log: log,
227
+ communication: OutputMessage (
228
+ message: 'Successfully updated annotated file.' ,
229
+ level: Level .CONFIG ,
230
+ ),
229
231
),
230
- ),
231
- onError: (e, st) => logOutputMessage (
232
+ onError: (e, st) => logOutputMessage (
233
+ log: log,
234
+ communication: OutputMessage (
235
+ message: 'Failed to update annotated class file.' ,
236
+ level: Level .WARNING ,
237
+ additionalContext: e,
238
+ stackTrace: st,
239
+ ),
240
+ ),
241
+ );
242
+ } else {
243
+ logOutputMessage (
232
244
log: log,
233
245
communication: OutputMessage (
234
- message: 'Failed to update annotated class file.' ,
246
+ message:
247
+ 'Skipped updating annotated file step because flag was set.' ,
235
248
level: Level .WARNING ,
236
- additionalContext: e,
237
- stackTrace: st,
238
249
),
239
- ),
240
- );
250
+ );
251
+ }
241
252
}
242
253
return '' ;
243
254
}
You can’t perform that action at this time.
0 commit comments