Skip to content

Commit 2ff3b99

Browse files
authored
Merge pull request #149 from DmitrySboychakov/master
fix: Bump generator versions and add support for --name-mappings
2 parents 639cf5b + f5c6aed commit 2ff3b99

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ class Openapi {
8484
/// --type-mappings
8585
final Map<String, String>? typeMappings;
8686

87+
/// sets mappings between OpenAPI spec properties name and generated code
88+
/// var/param/model in the format of OpenAPIName=generatedName.
89+
/// For example: update=updatable,_=underscore.
90+
91+
/// --name-mappings
92+
final Map<String, String>? nameMappings;
93+
8794
/// specifies mappings between a given class and the import that should
8895
/// be used for that class in the format of type=import,type=import. You
8996
/// can also have multiple occurrences of this option.
@@ -129,6 +136,7 @@ class Openapi {
129136
this.outputDirectory,
130137
this.cleanSubOutputDirectory,
131138
this.typeMappings,
139+
this.nameMappings,
132140
this.importMappings,
133141
this.reservedWordsMappings,
134142
this.inlineSchemaNameMappings,
@@ -532,14 +540,6 @@ class DioProperties extends AdditionalProperties {
532540
}
533541

534542
class DioAltProperties extends AdditionalProperties {
535-
/// Changes the minimum version of Dart to 2.12 and generate null safe code
536-
final bool? nullSafe;
537-
538-
/// nullSafe-array-default
539-
/// Makes even arrays that are not listed as being required in your OpenAPI "required"
540-
/// but making them always generate a default value of []
541-
final bool? nullSafeArrayDefault;
542-
543543
/// This will turn off AnyOf support. This would be a bit weird, but you can do it if you want.
544544
final bool? listAnyOf;
545545

@@ -552,9 +552,7 @@ class DioAltProperties extends AdditionalProperties {
552552
final String? pubspecDevDependencies;
553553

554554
const DioAltProperties(
555-
{this.nullSafe,
556-
this.nullSafeArrayDefault,
557-
this.pubspecDependencies,
555+
{this.pubspecDependencies,
558556
this.pubspecDevDependencies,
559557
this.listAnyOf,
560558
bool allowUnicodeIdentifiers = false,
@@ -591,18 +589,13 @@ class DioAltProperties extends AdditionalProperties {
591589
wrapper: wrapper);
592590

593591
DioAltProperties.fromMap(Map<String, dynamic> map)
594-
: nullSafe = map['nullSafe'],
595-
nullSafeArrayDefault = map['nullSafeArrayDefault'],
596-
listAnyOf = map['listAnyOf'],
592+
: listAnyOf = map['listAnyOf'],
597593
pubspecDependencies = map['pubspecDependencies'],
598594
pubspecDevDependencies = map['pubspecDevDependencies'],
599595
super.fromMap(map);
600596

601597
Map<String, dynamic> toMap() => Map.from(super.toMap())
602598
..addAll({
603-
if (nullSafe != null) 'nullSafe': nullSafe,
604-
if (nullSafeArrayDefault != null)
605-
'nullSafeArrayDefault': nullSafeArrayDefault,
606599
if (listAnyOf != null) 'listAnyOf': listAnyOf,
607600
if (pubspecDependencies != null)
608601
'pubspecDependencies': pubspecDependencies,
2.56 MB
Binary file not shown.

openapi-generator-cli/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
<dependency>
4848
<groupId>org.openapitools</groupId>
4949
<artifactId>openapi-generator-cli</artifactId>
50-
<version>7.2.0</version>
50+
<version>7.7.0</version>
5151
</dependency>
5252

5353
<dependency>
5454
<groupId>com.bluetrainsoftware.maven</groupId>
5555
<artifactId>openapi-dart-generator</artifactId>
56-
<version>7.2</version>
56+
<version>8.1</version>
5757
</dependency>
5858
</dependencies>
5959
</project>

openapi-generator/lib/src/models/generator_arguments.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ class GeneratorArguments {
7878
/// Defines mappings between OpenAPI spec types and generated types.
7979
final Map<String, String>? typeMappings;
8080

81+
/// Defines mappings between OpenAPI spec var/param/model and generated code.
82+
final Map<String, String>? nameMappings;
83+
8184
/// Adds reserved words mappings.
8285
///
8386
/// Supported by [Generator.dio] & [Generator.dioAlt] generators.
@@ -97,6 +100,7 @@ class GeneratorArguments {
97100
generator =
98101
annotations.readPropertyOrDefault('generatorName', Generator.dart),
99102
typeMappings = annotations.readPropertyOrNull('typeMappings'),
103+
nameMappings = annotations.readPropertyOrNull('nameMappings'),
100104
importMappings = annotations.readPropertyOrNull('importMappings'),
101105
reservedWordsMappings =
102106
annotations.readPropertyOrNull('reservedWordsMappings'),
@@ -179,6 +183,8 @@ class GeneratorArguments {
179183
'--import-mappings=${importMappings!.entries.fold('', foldStringMap())}',
180184
if (typeMappings?.isNotEmpty ?? false)
181185
'--type-mappings=${typeMappings!.entries.fold('', foldStringMap())}',
186+
if (nameMappings?.isNotEmpty ?? false)
187+
'--name-mappings=${nameMappings!.entries.fold('', foldStringMap())}',
182188
if (inlineSchemaOptions != null)
183189
'--inline-schema-options=${inlineSchemaOptions!.toMap().entries.fold('', foldStringMap(keyModifier: convertToPropertyKey))}',
184190
if (additionalProperties != null)

0 commit comments

Comments
 (0)