Skip to content

Commit ef87f8b

Browse files
committed
added null safety
1 parent 8c9c9ac commit ef87f8b

File tree

11 files changed

+128
-126
lines changed

11 files changed

+128
-126
lines changed

example/lib/generated/i18n.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ class GeneratedLocalizationsDelegate extends LocalizationsDelegate<S> {
123123
}
124124
}
125125

126-
String getLang(Locale l) =>
127-
l == null
128-
? null
129-
: l.countryCode != null && l.countryCode.isEmpty
126+
String getLang(Locale l) => l == null
127+
? null
128+
: l.countryCode != null && l.countryCode.isEmpty
130129
? l.languageCode
131130
: l.toString();

openapi-generator-annotations/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.0-nullsafety.0
2+
3+
- Added null safety
4+
15
## 1.1.4
26

37
- Updated dart_2 api to version 3.10

openapi-generator-annotations/lib/src/openapi_generator_annotations_base.dart

Lines changed: 71 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ class Openapi {
66
/// Additional properties to pass to the compiler (CSV)
77
///
88
/// --additional-properties
9-
final AdditionalProperties additionalProperties;
9+
final AdditionalProperties? additionalProperties;
1010

1111
/// The package of the api. defaults to lib.api
1212
///
1313
/// --api-package
14-
final String apiPackage;
14+
final String? apiPackage;
1515

1616
/// relative path or url to spec file
1717
///
@@ -21,7 +21,7 @@ class Openapi {
2121
/// folder containing the template files
2222
///
2323
/// -t
24-
final String templateDirectory;
24+
final String? templateDirectory;
2525

2626
/// Generator to use (dart|dart2-api|dart-jaguar|dart-dio)
2727
///
@@ -31,45 +31,45 @@ class Openapi {
3131
/// Where to write the generated files (current dir by default)
3232
///
3333
/// -o, --output
34-
final String outputDirectory;
34+
final String? outputDirectory;
3535

3636
/// Specifies if the existing files should be overwritten during the generation
3737
///
3838
/// -s, --skip-overwrite
39-
final bool overwriteExistingFiles;
39+
final bool? overwriteExistingFiles;
4040

4141
/// Skips the default behavior of validating an input specification.
4242
///
4343
/// --skip-validate-spec
44-
final bool skipSpecValidation;
44+
final bool? skipSpecValidation;
4545

4646
/// Add reserver words mappings as reservedWord=replacement format.
4747
/// It is supported by the dart2-api and dart-dio generator.
4848
///
4949
/// --reserved-words-mappings
50-
final Map<String, String> reservedWordsMappings;
50+
final Map<String, String>? reservedWordsMappings;
5151

5252
/// Tells openapi-generator to always run during the build process
5353
/// if set to false (the default), openapi-generator will skip processing if the [outputDirectory] already exists
54-
final bool alwaysRun;
54+
final bool? alwaysRun;
5555

5656
/// if set to true, flutter pub get will be run on the [outputDirectory] after the code has been generated.
5757
/// Defaults to true for backwards compatibility
58-
final bool fetchDependencies;
58+
final bool? fetchDependencies;
5959

6060
///if set to true, source gen will be run on the output of openapi-generator
6161
///Defaults to true
62-
final bool runSourceGenOnOutput;
62+
final bool? runSourceGenOnOutput;
6363

64-
final Map<String, String> typeMappings;
64+
final Map<String, String>? typeMappings;
6565

6666
const Openapi(
6767
{this.additionalProperties,
6868
this.overwriteExistingFiles,
6969
this.skipSpecValidation = false,
70-
this.inputSpecFile,
70+
required this.inputSpecFile,
7171
this.templateDirectory,
72-
this.generatorName,
72+
required this.generatorName,
7373
this.outputDirectory,
7474
this.typeMappings,
7575
this.reservedWordsMappings,
@@ -81,53 +81,52 @@ class Openapi {
8181

8282
class AdditionalProperties {
8383
/// toggles whether unicode identifiers are allowed in names or not, default is false
84-
final bool allowUnicodeIdentifiers;
84+
final bool? allowUnicodeIdentifiers;
8585

8686
/// Whether to ensure parameter names are unique in an operation (rename parameters that are not).
87-
final bool ensureUniqueParams;
87+
final bool? ensureUniqueParams;
8888

8989
/// Add form or body parameters to the beginning of the parameter list.
90-
final bool prependFormOrBodyParameters;
90+
final bool? prependFormOrBodyParameters;
9191

9292
/// Author name in generated pubspec
93-
final String pubAuthor;
93+
final String? pubAuthor;
9494

9595
/// Email address of the author in generated pubspec
96-
final String pubAuthorEmail;
96+
final String? pubAuthorEmail;
9797

9898
/// Description in generated pubspec
99-
final String pubDescription;
99+
final String? pubDescription;
100100

101101
/// Homepage in generated pubspec
102-
final String pubHomepage;
102+
final String? pubHomepage;
103103

104104
/// Name in generated pubspec
105-
final String pubName;
105+
final String? pubName;
106106

107107
/// Version in generated pubspec
108-
final String pubVersion;
108+
final String? pubVersion;
109109

110110
/// Sort model properties to place required parameters before optional parameters.
111-
final bool sortModelPropertiesByRequiredFlag;
111+
final bool? sortModelPropertiesByRequiredFlag;
112112

113113
/// Sort method arguments to place required parameters before optional parameters.
114-
final bool sortParamsByRequiredFlag;
114+
final bool? sortParamsByRequiredFlag;
115115

116116
/// Source folder for generated code
117-
final String sourceFolder;
117+
final String? sourceFolder;
118118

119119
/// Allow the 'x-enum-values' extension for enums
120-
final bool useEnumExtension;
121-
122-
const AdditionalProperties(
123-
{this.allowUnicodeIdentifiers = false,
124-
this.ensureUniqueParams = true,
125-
this.useEnumExtension = false,
126-
this.prependFormOrBodyParameters = false,
127-
this.pubAuthor,
128-
this.pubAuthorEmail,
129-
this.pubDescription,
130-
this.pubHomepage,
120+
final bool? useEnumExtension;
121+
122+
const AdditionalProperties({this.allowUnicodeIdentifiers = false,
123+
this.ensureUniqueParams = true,
124+
this.useEnumExtension = false,
125+
this.prependFormOrBodyParameters = false,
126+
this.pubAuthor,
127+
this.pubAuthorEmail,
128+
this.pubDescription,
129+
this.pubHomepage,
131130
this.pubName,
132131
this.pubVersion,
133132
this.sortModelPropertiesByRequiredFlag = true,
@@ -137,27 +136,26 @@ class AdditionalProperties {
137136

138137
class JaguarProperties extends AdditionalProperties {
139138
/// Choose serialization format JSON or PROTO is supported
140-
final SerializationFormat serialization;
139+
final SerializationFormat? serialization;
141140

142141
/// Is the null fields should be in the JSON payload
143-
final bool nullableFields;
144-
145-
const JaguarProperties(
146-
{this.serialization,
147-
this.nullableFields,
148-
bool allowUnicodeIdentifiers = false,
149-
bool ensureUniqueParams = true,
150-
bool prependFormOrBodyParameters = false,
151-
String pubAuthor,
152-
String pubAuthorEmail,
153-
String pubDescription,
154-
String pubHomepage,
155-
String pubName,
156-
String pubVersion,
157-
bool sortModelPropertiesByRequiredFlag = true,
158-
bool sortParamsByRequiredFlag = true,
159-
bool useEnumExtension = true,
160-
String sourceFolder})
142+
final bool? nullableFields;
143+
144+
const JaguarProperties({this.serialization,
145+
this.nullableFields,
146+
bool allowUnicodeIdentifiers = false,
147+
bool ensureUniqueParams = true,
148+
bool prependFormOrBodyParameters = false,
149+
String? pubAuthor,
150+
String? pubAuthorEmail,
151+
String? pubDescription,
152+
String? pubHomepage,
153+
String? pubName,
154+
String? pubVersion,
155+
bool sortModelPropertiesByRequiredFlag = true,
156+
bool sortParamsByRequiredFlag = true,
157+
bool useEnumExtension = true,
158+
String? sourceFolder})
161159
: super(
162160
allowUnicodeIdentifiers: allowUnicodeIdentifiers,
163161
ensureUniqueParams: ensureUniqueParams,
@@ -177,27 +175,26 @@ class JaguarProperties extends AdditionalProperties {
177175

178176
class DioProperties extends AdditionalProperties {
179177
/// Choose serialization format JSON or PROTO is supported
180-
final DioDateLibrary dateLibrary;
178+
final DioDateLibrary? dateLibrary;
181179

182180
/// Is the null fields should be in the JSON payload
183-
final bool nullableFields;
184-
185-
const DioProperties(
186-
{this.dateLibrary,
187-
this.nullableFields,
188-
bool allowUnicodeIdentifiers = false,
189-
bool ensureUniqueParams = true,
190-
bool prependFormOrBodyParameters = false,
191-
String pubAuthor,
192-
String pubAuthorEmail,
193-
String pubDescription,
194-
String pubHomepage,
195-
String pubName,
196-
String pubVersion,
197-
bool sortModelPropertiesByRequiredFlag = true,
198-
bool sortParamsByRequiredFlag = true,
199-
bool useEnumExtension = true,
200-
String sourceFolder})
181+
final bool? nullableFields;
182+
183+
const DioProperties({this.dateLibrary,
184+
this.nullableFields,
185+
bool allowUnicodeIdentifiers = false,
186+
bool ensureUniqueParams = true,
187+
bool prependFormOrBodyParameters = false,
188+
String? pubAuthor,
189+
String? pubAuthorEmail,
190+
String? pubDescription,
191+
String? pubHomepage,
192+
String? pubName,
193+
String? pubVersion,
194+
bool sortModelPropertiesByRequiredFlag = true,
195+
bool sortParamsByRequiredFlag = true,
196+
bool useEnumExtension = true,
197+
String? sourceFolder})
201198
: super(
202199
allowUnicodeIdentifiers: allowUnicodeIdentifiers,
203200
ensureUniqueParams: ensureUniqueParams,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
name: openapi_generator_annotations
22
description: Annotation package for openapi_generator https://pub.dev/packages/openapi_generator.
3-
version: 1.1.4
3+
version: 2.0.0-nullsafety.0
44
homepage: https://github.com/gibahjoe/openapi-generator-dart
55

66

77
environment:
8-
sdk: '>=2.7.0 <3.0.0'
8+
sdk: '>=2.12.0-133.2.beta <3.0.0'
99

1010
dev_dependencies:
11-
pedantic: ^1.9.2
12-
test: ^1.15.7
11+
pedantic: ^1.10.0-nullsafety.3
12+
test: ^1.16.0-nullsafety.13

openapi-generator-cli/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.0-nullsafety.0
2+
3+
- Added null safety
4+
15
## 1.1.4
26

37
- Updated dart_2 api to version 3.10

openapi-generator-cli/bin/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void main(List<String> arguments) async {
66
exitCode = 0; // presume success
77

88
var binPath = (await Isolate.resolvePackageUri(
9-
Uri.parse('package:openapi_generator_cli/openapi-generator.jar')))
9+
Uri.parse('package:openapi_generator_cli/openapi-generator.jar')))!
1010
.toFilePath(windows: Platform.isWindows);
1111
var JAVA_OPTS = Platform.environment['JAVA_OPTS'] ?? '';
1212

openapi-generator-cli/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: openapi_generator_cli
22
description: A dart wrapper around openapi-generator inspired by the node implementation.
3-
version: 1.1.4
3+
version: 2.0.0-nullsafety.0
44
homepage: https://github.com/gibahjoe/openapi-generator-dart
55

66
environment:
7-
sdk: '>=2.7.0 <3.0.0'
7+
sdk: '>=2.12.0-133.2.beta <3.0.0'
88

99
dev_dependencies:
10-
pedantic: ^1.9.2
11-
test: ^1.15.7
10+
pedantic: ^1.10.0-nullsafety.3
11+
test: ^1.16.0-nullsafety.13
1212

1313
executables:
1414
openapi-generator: main

openapi-generator/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.0-nullsafety.0
2+
3+
- Migrated to null safety
4+
15
## 1.1.4
26

37
- Updated dart_2 api to version 3.10

0 commit comments

Comments
 (0)