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 {
4747 /// Default: false
4848 final bool skipValidation;
4949
50+ /// Write the last run placeholder to the annotated file.
51+ ///
52+ /// Default: true
53+ final bool updateAnnotatedFile;
54+
5055 /// Provides an OAS spec file.
5156 ///
5257 /// When the [useNextGen] flag is set this should be the spec file configuration
@@ -104,6 +109,8 @@ class GeneratorArguments {
104109 annotations.readPropertyOrDefault ('runSourceGenOnOutput' , true ),
105110 shouldFetchDependencies =
106111 annotations.readPropertyOrDefault ('fetchDependencies' , true ),
112+ updateAnnotatedFile =
113+ annotations.readPropertyOrDefault ('updateAnnotatedFile' , true ),
107114 outputDirectory = annotations.readPropertyOrNull ('outputDirectory' ),
108115 cachePath =
109116 annotations.readPropertyOrDefault ('cachePath' , defaultCachedPath),
Original file line number Diff line number Diff line change @@ -220,24 +220,35 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
220220 ),
221221 ),
222222 );
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+ ),
229231 ),
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 (
232244 log: log,
233245 communication: OutputMessage (
234- message: 'Failed to update annotated class file.' ,
246+ message:
247+ 'Skipped updating annotated file step because flag was set.' ,
235248 level: Level .WARNING ,
236- additionalContext: e,
237- stackTrace: st,
238249 ),
239- ),
240- );
250+ );
251+ }
241252 }
242253 return '' ;
243254 }
You can’t perform that action at this time.
0 commit comments