@@ -4,12 +4,6 @@ import 'dart:io';
4
4
import 'package:crypto/crypto.dart' ;
5
5
import 'package:meta/meta.dart' ;
6
6
7
- /// Config base class
8
- /// Your annotated class must extend this config class
9
- @Deprecated (
10
- 'You do not need to extend this anymore (See example). This class would be removed in the next major release.' )
11
- abstract class OpenapiGeneratorConfig {}
12
-
13
7
class Openapi {
14
8
/// Additional properties to pass to the compiler (CSV)
15
9
///
@@ -26,12 +20,6 @@ class Openapi {
26
20
/// --api-package
27
21
final String ? apiPackage;
28
22
29
- /// relative path or url to spec file
30
- ///
31
- /// -i
32
- @Deprecated ('To be removed in the next major' )
33
- final String inputSpecFile;
34
-
35
23
/// Provides the access information to the input spec file.
36
24
///
37
25
/// For use with useNextGen.
@@ -43,7 +31,7 @@ class Openapi {
43
31
/// to be applied to the fetch request when the spec file is in a remote
44
32
/// location. There is also special handling for when the spec file lives within
45
33
/// AWS.
46
- final InputSpec ? inputSpec;
34
+ final InputSpec inputSpec;
47
35
48
36
/// folder containing the template files
49
37
///
@@ -80,12 +68,6 @@ class Openapi {
80
68
/// --reserved-words-mappings
81
69
final Map <String , String >? reservedWordsMappings;
82
70
83
- /// Tells openapi-generator to always run during the build process
84
- /// if set to false (the default), openapi-generator will skip processing if the [outputDirectory] already exists
85
- @Deprecated (
86
- 'The generator will always run to determine if there are changes made on the input spec file' )
87
- final bool ? alwaysRun;
88
-
89
71
/// if set to true, flutter pub get will be run on the [outputDirectory] after the code has been generated.
90
72
/// Defaults to true for backwards compatibility
91
73
final bool ? fetchDependencies;
@@ -122,21 +104,6 @@ class Openapi {
122
104
/// e.g {'inline_object_2': 'SomethingMapped'}
123
105
final Map <String , String >? inlineSchemaNameMappings;
124
106
125
- /// Use the next generation of the generator.
126
- ///
127
- /// This annotation informs the generator to use the new generator pathway.
128
- /// Enabling this option allows for incremental changes to the [inputSpecFile]
129
- /// to be generated even though the annotation was unchanged.
130
- ///
131
- /// Due to some limitations with build_runner and it only running when the
132
- /// asset graph has changed, a generated line get injected at the beginning of
133
- /// the file at the end of each run.
134
- ///
135
- /// This will become the default behaviour in the next Major version (v5).
136
- ///
137
- /// Default: false
138
- final bool useNextGen;
139
-
140
107
/// The path where to store the cached copy of the specification.
141
108
///
142
109
/// For use with [useNextGen] .
@@ -152,8 +119,7 @@ class Openapi {
152
119
this .additionalProperties,
153
120
this .overwriteExistingFiles,
154
121
this .skipSpecValidation = false ,
155
- required this .inputSpecFile,
156
- this .inputSpec,
122
+ required this .inputSpec,
157
123
this .templateDirectory,
158
124
required this .generatorName,
159
125
this .outputDirectory,
@@ -165,9 +131,7 @@ class Openapi {
165
131
this .apiPackage,
166
132
this .fetchDependencies = true ,
167
133
this .runSourceGenOnOutput = true ,
168
- this .alwaysRun = false ,
169
134
this .cachePath,
170
- this .useNextGen = false ,
171
135
this .projectPubspecPath,
172
136
this .debugLogging = false ,
173
137
});
@@ -179,30 +143,18 @@ class Openapi {
179
143
/// Includes the option to use the default json or yaml paths.
180
144
class InputSpec {
181
145
final String path;
182
- final bool defaultYaml;
183
- final bool useYml;
184
146
185
- const InputSpec ({String ? path, this .defaultYaml = true , this .useYml = false })
186
- : path = path ??
187
- 'openapi.${defaultYaml ? 'y${useYml ? '' : 'a' }ml' : 'json' }' ;
147
+ const InputSpec ({required this .path});
188
148
189
- const InputSpec .empty () : this ();
149
+ const InputSpec .json () : this (path : 'openapi.json' );
190
150
191
- const InputSpec .emptyJson () : this (defaultYaml : false );
192
- const InputSpec . emptyYml () : this (useYml : true );
151
+ const InputSpec .yaml ({ bool shortExtension = false })
152
+ : this (path : 'openapi.y${ shortExtension ? '' : 'a' }ml' );
193
153
194
- Map <String , dynamic > toJsonMap () => {
195
- 'path' : path,
196
- 'defaultYaml' : defaultYaml,
197
- 'useYml' : useYml,
198
- };
154
+ Map <String , dynamic > toJsonMap () => {'path' : path};
199
155
200
156
InputSpec .fromMap (Map <String , dynamic > map)
201
- : this (
202
- path: map['path' ],
203
- defaultYaml: map['defaultYaml' ] == 'true' ? true : false ,
204
- useYml: map['useYml' ] == 'true' ? true : false ,
205
- );
157
+ : this (path: map['path' ]);
206
158
}
207
159
208
160
/// Provides the location for the remote specification.
@@ -377,10 +329,13 @@ class AdditionalProperties {
377
329
/// Allow the 'x-enum-values' extension for enums
378
330
final bool ? useEnumExtension;
379
331
380
- /// With this option enabled, each enum will have a new case, 'unknown_default_open_api',
332
+ /// If the server adds new enum cases, that are unknown by an old spec/client,
333
+ /// the client will fail to parse the network response.With this option enabled, each enum will have a new case, 'unknown_default_open_api',
381
334
/// so that when the server sends an enum case that is not known by the client/spec,
382
- /// they can safely fallback to this case
383
- final bool ? enumUnknownDefaultCase;
335
+ /// they can safely fallback to this case.
336
+ ///
337
+ /// Default: false
338
+ final bool enumUnknownDefaultCase;
384
339
385
340
/// Flutter wrapper to use (none|flutterw|fvm)
386
341
final Wrapper wrapper;
@@ -404,7 +359,7 @@ class AdditionalProperties {
404
359
this .allowUnicodeIdentifiers = false ,
405
360
this .ensureUniqueParams = true ,
406
361
this .useEnumExtension = false ,
407
- this .enumUnknownDefaultCase = true ,
362
+ this .enumUnknownDefaultCase = false ,
408
363
this .prependFormOrBodyParameters = false ,
409
364
this .pubAuthor,
410
365
this .pubAuthorEmail,
@@ -425,7 +380,7 @@ class AdditionalProperties {
425
380
allowUnicodeIdentifiers: map['allowUnicodeIdentifiers' ] ?? false ,
426
381
ensureUniqueParams: map['ensureUniqueParams' ] ?? true ,
427
382
useEnumExtension: map['useEnumExtension' ] ?? true ,
428
- enumUnknownDefaultCase: map['enumUnknownDefaultCase' ] ?? true ,
383
+ enumUnknownDefaultCase: map['enumUnknownDefaultCase' ] ?? false ,
429
384
prependFormOrBodyParameters:
430
385
map['prependFormOrBodyParameters' ] ?? false ,
431
386
pubAuthor: map['pubAuthor' ],
@@ -532,7 +487,7 @@ class DioProperties extends AdditionalProperties {
532
487
bool sortModelPropertiesByRequiredFlag = true ,
533
488
bool sortParamsByRequiredFlag = true ,
534
489
bool useEnumExtension = true ,
535
- bool enumUnknownDefaultCase = true ,
490
+ bool enumUnknownDefaultCase = false ,
536
491
String ? sourceFolder,
537
492
Wrapper wrapper = Wrapper .none})
538
493
: super (
@@ -609,7 +564,7 @@ class DioAltProperties extends AdditionalProperties {
609
564
bool sortModelPropertiesByRequiredFlag = true ,
610
565
bool sortParamsByRequiredFlag = true ,
611
566
bool useEnumExtension = true ,
612
- bool enumUnknownDefaultCase = true ,
567
+ bool enumUnknownDefaultCase = false ,
613
568
String ? sourceFolder,
614
569
Wrapper wrapper = Wrapper .none})
615
570
: super (
0 commit comments