@@ -2,10 +2,8 @@ import 'dart:async';
2
2
import 'dart:io' ;
3
3
4
4
import 'package:logging/logging.dart' ;
5
- import 'package:openapi_generator/src/extensions/type_methods.dart' ;
6
5
import 'package:openapi_generator/src/models/output_message.dart' ;
7
6
import 'package:openapi_generator_annotations/openapi_generator_annotations.dart' ;
8
- import 'package:source_gen/source_gen.dart' as src_gen;
9
7
10
8
import '../utils.dart' ;
11
9
@@ -74,6 +72,7 @@ class GeneratorArguments {
74
72
/// Use the provided spec instead of one located in [Directory.current] .
75
73
///
76
74
/// Default: openapi.(ya?ml) | openapi.json
75
+ @Deprecated ('Use inputSpec instead.' )
77
76
String _inputFile;
78
77
79
78
/// Provides an OAS spec file.
@@ -114,12 +113,12 @@ class GeneratorArguments {
114
113
final InlineSchemaOptions ? inlineSchemaOptions;
115
114
116
115
GeneratorArguments ({
117
- required src_gen. ConstantReader annotations ,
116
+ required Openapi annotation ,
118
117
bool alwaysRun = false ,
119
- String inputSpecFile = '' ,
118
+ String ? inputSpecFile,
120
119
InputSpec inputSpec = const InputSpec .empty (),
121
120
String templateDirectory = '' ,
122
- Generator generator = Generator .dart ,
121
+ Generator ? generator,
123
122
Map <String , String > typeMapping = const {},
124
123
Map <String , String > importMapping = const {},
125
124
Map <String , String > reservedWordsMapping = const {},
@@ -130,47 +129,39 @@ class GeneratorArguments {
130
129
bool runSourceGen = true ,
131
130
String ? outputDirectory,
132
131
bool fetchDependencies = true ,
133
- bool useNextGen = false ,
132
+ bool ? useNextGen,
134
133
String ? cachePath,
135
134
String ? pubspecPath,
136
135
bool isDebug = false ,
137
- }) : alwaysRun = annotations.readPropertyOrDefault ('alwaysRun' , alwaysRun),
138
- _inputFile =
139
- annotations.readPropertyOrDefault ('inputSpecFile' , inputSpecFile),
140
- templateDirectory = annotations.readPropertyOrDefault (
141
- 'templateDirectory' , templateDirectory),
142
- generator =
143
- annotations.readPropertyOrDefault ('generatorName' , generator),
144
- typeMappings =
145
- annotations.readPropertyOrDefault ('typeMappings' , typeMapping),
146
- importMappings =
147
- annotations.readPropertyOrDefault ('importMappings' , importMapping),
148
- reservedWordsMappings = annotations.readPropertyOrDefault (
149
- 'reservedWordsMappings' , reservedWordsMapping),
150
- inlineSchemaNameMappings = annotations.readPropertyOrDefault (
151
- 'inlineSchemaNameMappings' , inlineSchemaNameMapping),
152
- additionalProperties = annotations.readPropertyOrDefault (
153
- 'additionalProperties' , additionalProperties),
154
- inlineSchemaOptions = annotations.readPropertyOrDefault (
155
- 'inlineSchemaOptions' , inlineSchemaOptions),
156
- skipValidation = annotations.readPropertyOrDefault (
157
- 'skipSpecValidation' , skipValidation),
158
- runSourceGen = annotations.readPropertyOrDefault (
159
- 'runSourceGenOnOutput' , runSourceGen),
160
- shouldFetchDependencies = annotations.readPropertyOrDefault (
161
- 'fetchDependencies' , fetchDependencies),
162
- outputDirectory = annotations.readPropertyOrDefault (
163
- 'outputDirectory' , outputDirectory ?? Directory .current.path),
164
- useNextGen =
165
- annotations.readPropertyOrDefault ('useNextGen' , useNextGen),
166
- cachePath = annotations.readPropertyOrDefault (
167
- 'cachePath' , cachePath ?? defaultCachedPath),
168
- pubspecPath = annotations.readPropertyOrDefault <String >(
169
- 'projectPubspecPath' ,
136
+ }) : alwaysRun = annotation.alwaysRun ?? alwaysRun,
137
+ _inputFile = inputSpecFile ?? annotation.inputSpecFile,
138
+ templateDirectory = annotation.templateDirectory ?? templateDirectory,
139
+ generator = generator ?? annotation.generatorName,
140
+ typeMappings = annotation.typeMappings ?? typeMapping,
141
+ importMappings = annotation.importMappings ?? importMapping,
142
+ reservedWordsMappings =
143
+ annotation.reservedWordsMappings ?? reservedWordsMapping,
144
+ inlineSchemaNameMappings =
145
+ annotation.inlineSchemaNameMappings ?? inlineSchemaNameMapping,
146
+ additionalProperties =
147
+ additionalProperties ?? annotation.additionalProperties,
148
+ inlineSchemaOptions = inlineSchemaOptions,
149
+ // ?? annotations.readPropertyOrDefault(
150
+ // 'inlineSchemaOptions', inlineSchemaOptions),
151
+ skipValidation = annotation.skipSpecValidation ?? skipValidation,
152
+ runSourceGen = annotation.runSourceGenOnOutput ?? runSourceGen,
153
+ shouldFetchDependencies =
154
+ annotation.fetchDependencies ?? fetchDependencies,
155
+ outputDirectory = annotation.outputDirectory ??
156
+ outputDirectory ??
157
+ Directory .current.path,
158
+ useNextGen = useNextGen ?? annotation.useNextGen,
159
+ cachePath = cachePath ?? annotation.cachePath ?? defaultCachedPath,
160
+ pubspecPath = annotation.projectPubspecPath ??
170
161
pubspecPath ??
171
- '${Directory .current .path }${Platform .pathSeparator }pubspec.yaml' ) ,
172
- isDebug = annotations. readPropertyOrDefault ( ' debugLogging' , isDebug) ,
173
- inputSpec = annotations. readPropertyOrDefault ( ' inputSpec' , inputSpec) ;
162
+ '${Directory .current .path }${Platform .pathSeparator }pubspec.yaml' ,
163
+ isDebug = annotation. debugLogging,
164
+ inputSpec = annotation. inputSpec ?? inputSpec;
174
165
175
166
/// The stringified name of the [Generator] .
176
167
String get generatorName => generator == Generator .dart
0 commit comments