Skip to content

Commit 9da6858

Browse files
authored
Merge pull request #84 from nicholasphair/dio_serialization_lib
add support for serialization lib in dio
2 parents 63e248e + 753a8ae commit 9da6858

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,15 @@ class JaguarProperties extends AdditionalProperties {
216216
class DioProperties extends AdditionalProperties {
217217
/// Choose serialization format JSON or PROTO is supported
218218
final DioDateLibrary? dateLibrary;
219+
final DioSerializationLibrary? serializationLibrary;
219220

220221
/// Is the null fields should be in the JSON payload
221222
final bool? nullableFields;
222223

223224
const DioProperties(
224225
{this.dateLibrary,
225226
this.nullableFields,
227+
this.serializationLibrary,
226228
bool allowUnicodeIdentifiers = false,
227229
bool ensureUniqueParams = true,
228230
bool prependFormOrBodyParameters = false,
@@ -318,6 +320,8 @@ enum DioDateLibrary {
318320
timemachine
319321
}
320322

323+
enum DioSerializationLibrary { built_value, json_serializable }
324+
321325
enum SerializationFormat { JSON, PROTO }
322326

323327
/// The name of the generator to use

openapi-generator/lib/src/openapi_generator_runner.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ class OpenapiGenerator extends GeneratorForAnnotation<annots.Openapi> {
328328
return value.toStringValue() ??
329329
value.toBoolValue()?.toString() ??
330330
value.toIntValue()?.toString() ??
331+
value.getField('_name')?.toStringValue() ??
331332
'';
332333
}
333334
}

openapi-generator/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ dependencies:
1515
openapi_generator_cli: ^4.0.0
1616

1717
dev_dependencies:
18+
test: ^1.23.1
1819
pedantic:
1920

openapi-generator/test/test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import 'package:openapi_generator/src/openapi_generator_runner.dart';
2+
import 'package:test/test.dart';
3+
4+
5+
void main() {
6+
group('convertToPropertyKey()', () {
7+
final generator = OpenapiGenerator();
8+
9+
test('convert "nullSafeArrayDefault"', () {
10+
expect(generator.convertToPropertyKey('nullSafeArrayDefault'),
11+
equals('nullSafe-array-default'));
12+
});
13+
14+
test('convert "pubspecDependencies"', () {
15+
expect(generator.convertToPropertyKey('pubspecDependencies'),
16+
equals('pubspec-dependencies'));
17+
});
18+
19+
test('convert "pubspecDevDependencies"', () {
20+
expect(generator.convertToPropertyKey('pubspecDevDependencies'),
21+
equals('pubspec-dev-dependencies'));
22+
});
23+
24+
group('convertToPropertyValue()', () {
25+
// TODO.
26+
});
27+
});
28+
}

0 commit comments

Comments
 (0)