Skip to content

Commit e1bea41

Browse files
committed
added support for jaguar
1 parent 43b8062 commit e1bea41

File tree

10 files changed

+48
-53
lines changed

10 files changed

+48
-53
lines changed

example/lib/openAPiConfig.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ import 'package:openapi_generator_annotations/openapi_generator_annotations.dart
77
AdditionalProperties(pubName: 'petstore_api', pubAuthor: 'Johnny dep'),
88
inputSpecFile: 'spec/openapi-spec.yaml',
99
generatorName: 'dart-jaguar',
10-
outputDirectory: 'petstore/api')
10+
outputDirectory: 'api/petstore_api')
1111
class OpenapiGeneratorCo extends OpenapiGeneratorConfig {}

example/pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ dependencies:
2121
sdk: flutter
2222
openapi_generator_annotations:
2323
path: ../openapi-generator-annotations
24-
petstore_api:
25-
path: petstore/api
2624

2725

2826
# The following adds the Cupertino Icons font to your application.

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

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,44 @@
1-
// TODO: Put public facing types in this file.
2-
/// Checks if you are awesome. Spoiler: you are.
3-
class Awesome {
4-
bool get isAwesome => true;
5-
}
6-
7-
abstract class OpenapiGeneratorConfig {
8-
Map<String, String> additionalProperties;
9-
String inputSpecFile;
10-
String generator;
11-
String outputDirectory;
12-
13-
/// specifies if the existing files should be overwritten during the generation
14-
/// -s, --skip-overwrite
15-
bool overwriteExistingFiles;
16-
}
1+
/// Config base class
2+
/// Your annotated class must extend this config class
3+
abstract class OpenapiGeneratorConfig {}
174

185
class Openapi {
19-
final String baseUrl;
20-
6+
/// Additional properties to pass to tge compiler (CSV)
7+
/// --additional-properties
218
final AdditionalProperties additionalProperties;
9+
10+
/// relative path or url to spec file
11+
/// -i
2212
final String inputSpecFile;
2313

24-
/// generator to use (see list command for list)
14+
/// Generator to use (see list command for list)
2515
/// -g, --generator-name
2616
final String generatorName;
2717

28-
/// where to write the generated files (current dir by default)
18+
/// Where to write the generated files (current dir by default)
2919
/// -o, --output
3020
final String outputDirectory;
3121

32-
/// specifies if the existing files should be overwritten during the generation
22+
/// Specifies if the existing files should be overwritten during the generation
3323
/// -s, --skip-overwrite
3424
final bool overwriteExistingFiles;
3525

3626
/// Skips the default behavior of validating an input specification.
3727
/// --skip-validate-spec
38-
final bool validateSpec;
28+
final bool skipValidateSpec;
29+
30+
/// Tells openapi-generator to always run during the build process
31+
/// if set to false (the default), openapi-generator will skip processing if the [outputDirectory] already exists
32+
final bool alwaysRun;
3933

4034
const Openapi(
4135
{this.additionalProperties,
4236
this.overwriteExistingFiles,
43-
this.validateSpec = true,
37+
this.skipValidateSpec = false,
4438
this.inputSpecFile,
4539
this.generatorName,
4640
this.outputDirectory,
47-
this.baseUrl});
41+
this.alwaysRun = false});
4842
}
4943

5044
class AdditionalProperties {

openapi-generator-annotations/test/openapi_generator_annotations_test.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import 'package:test/test.dart';
33

44
void main() {
55
group('A group of tests', () {
6-
Awesome awesome;
7-
8-
setUp(() {
9-
awesome = Awesome();
10-
});
11-
12-
test('First Test', () {
13-
expect(awesome.isAwesome, isTrue);
14-
});
6+
// Awesome awesome;
7+
//
8+
// setUp(() {
9+
// awesome = Awesome();
10+
// });
11+
//
12+
// test('First Test', () {
13+
// expect(awesome.isAwesome, isTrue);
14+
// });
1515
});
1616
}

openapi-generator/bin/main.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import 'dart:io';
22
import 'dart:isolate';
33

4-
import 'package:openapi_generator/openapi_generator.dart' as openapi_generator;
5-
64
void main(List<String> arguments) async{
75
exitCode = 0; // presume success
86

@@ -13,7 +11,7 @@ void main(List<String> arguments) async{
1311
print("$binPath exists ===>");
1412
}
1513
print(Platform.resolvedExecutable);
16-
Process.run('java', ["-jar", "${"${binPath}"}", ...arguments,])
14+
await Process.run('java', ['-jar', "${"${binPath}"}", ...arguments,])
1715
.then((ProcessResult pr) {
1816
print(pr.exitCode);
1917
print(pr.stdout);

openapi-generator/build.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ targets:
66

77
builders:
88
openapi_generator:
9+
# runs_before: ["jaguarRetrofitBuilder"]
910
target: ":openapi_generator"
1011
import: "package:openapi_generator/src/builder.dart"
1112
builder_factories: ["openApiClientSdk"]
1213
build_extensions: {".dart": [".g.part"]}
1314
auto_apply: dependents
1415
build_to: cache
15-
applies_builders: ["source_gen|combining_builder"]
16+
applies_builders: ["source_gen|combining_builder","jaguarRetrofitBuilder"]

openapi-generator/lib/openapi_generator.dart

Lines changed: 0 additions & 3 deletions
This file was deleted.

openapi-generator/lib/src/openapi_generator_runner.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
8484
command =
8585
'$command$separator--additional-properties=${additionalProperties}';
8686
}
87-
command = '$command$separator-Dcolor';
8887

8988
print(command);
9089
var binPath = await Isolate.resolvePackageUri(
@@ -104,6 +103,18 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
104103
print(pr.stdout);
105104
print(pr.stderr);
106105
});
106+
107+
var c='pub run build_runner build --delete-conflicting-outputs';
108+
await Process.run('flutter', ['pub','get'],workingDirectory: '$outputDirectory').then((ProcessResult pr) {
109+
print(pr.exitCode);
110+
print(pr.stdout);
111+
print(pr.stderr);
112+
});
113+
await Process.run('flutter', c.split(' ').toList(),workingDirectory: '$outputDirectory').then((ProcessResult pr) {
114+
print(pr.exitCode);
115+
print(pr.stdout);
116+
print(pr.stderr);
117+
});
107118
return '';
108119
}
109120

@@ -115,13 +126,6 @@ class OpenapiGenerator extends GeneratorForAnnotation<Openapi> {
115126
String getMapAsString(Map<dynamic, dynamic> data) {
116127
return data.entries.map((entry) => '${entry.key}=${entry.value}').join(',');
117128
}
118-
119-
AdditionalProperties _reviveAdditionalProperties(ConstantReader read) {
120-
var reviveable = read.revive();
121-
return AdditionalProperties(
122-
allowUnicodeIdentifiers:
123-
reviveable.namedArguments['allowUnicodeIdentifiers'].toBoolValue());
124-
}
125129
}
126130

127131
//abstract class RevivableInstance implements ConstantReader {

openapi-generator/pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ dependencies:
1414
source_gen: ^0.9.0
1515
path: ^1.6.4
1616
cli_util: ^0.1.3+2
17+
jaguar_retrofit: ^2.8.8
18+
jaguar_serializer: ^2.2.12
1719
openapi_generator_annotations:
1820
path: ../openapi-generator-annotations/
1921

@@ -22,6 +24,8 @@ dev_dependencies:
2224
build_config: ^0.4.2
2325
build_runner: ^1.7.4
2426
test: ^1.6.0
27+
jaguar_retrofit_gen: ^2.8.10
28+
jaguar_serializer_cli: ^2.2.8
2529

2630
executables:
2731
openapi-generator: main
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import 'package:openapi_generator/openapi_generator.dart';
21
import 'package:test/test.dart';
32

43
void main() {
54
test('calculate', () {
6-
expect(calculate(), 42);
5+
// expect(calculate(), 42);
76
});
87
}

0 commit comments

Comments
 (0)