Skip to content

Commit e94dca3

Browse files
committed
test: fix openapi smoke test for open_api and enable it for the normal smoke pipeline. Also, switch the syntax in the bash files to use subshells.
1 parent 584bad7 commit e94dca3

File tree

6 files changed

+34
-27
lines changed

6 files changed

+34
-27
lines changed

smoke/smoke.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ set -e
2121
# Provides test covering the core
2222
# library as well as the default
2323
# generator backend.
24-
cd test0; bash smoke.sh; cd ../
24+
(cd test0; bash smoke.sh;)
2525

2626
# ======== Smoke Test 1 ========
2727
# Provides test covering the
2828
# built_value interop library.
29-
cd test1; bash smoke.sh; cd ../
29+
(cd test1; bash smoke.sh;)
3030

3131
# ==== test_empty_library ======
32-
cd test_empty_library; bash smoke.sh; cd ../
32+
(cd test_empty_library; bash smoke.sh;)
33+
34+
# ======= test_openapi =========
35+
(cd test_openapi; bash smoke.sh;)

smoke/test_openapi/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
openapi

smoke/test_openapi/lib/test.dart

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import 'package:dogs_core/dogs_core.dart';
88
import 'package:logging/logging.dart';
99
import 'dart:io';
1010

11-
import 'package:openapi_generator_annotations/openapi_generator_annotations.dart';
12-
13-
@SerializableLibrary(include: ["package:petstore_api/src/model/.*"])
14-
import 'package:petstore_api/petstore_api.dart';
11+
@SerializableLibrary(include: ["package:openapi/src/model/.*"])
12+
import 'package:openapi/openapi.dart';
1513

1614
import 'dogs.g.dart';
1715

1816
Future main() async {
19-
await initialiseDogs();
20-
installBuiltSerializers(PetstoreApi().serializers);
17+
configureDogs(plugins: [
18+
GeneratedModelsPlugin(),
19+
BuiltInteropPlugin(serializers: Openapi().serializers),
20+
]);
2121

2222
// Does the generated api actually kinda work?
2323
Pet pet = (PetBuilder()
@@ -27,18 +27,9 @@ Future main() async {
2727

2828
// Rebuilt using generated field maps
2929
var petStructure = dogs.findStructureByType(Pet);
30-
var extractFields = petStructure!.getFieldMap(pet);
31-
var rebuilt = dogs.project<Pet>(extractFields);
30+
var encoded = dogs.toJson(pet);
31+
var rebuilt = dogs.fromJson<Pet>(encoded);
3232

33+
print("OpenAPI test succeeded");
34+
exit(0);
3335
}
34-
35-
@Openapi(
36-
additionalProperties:
37-
DioProperties(pubName: 'petstore_api'),
38-
inputSpec:
39-
RemoteSpec(path: 'https://petstore.swagger.io/v2/swagger.json'),
40-
generatorName: Generator.dio,
41-
runSourceGenOnOutput: true,
42-
outputDirectory: 'api/petstore_api',
43-
)
44-
class OpenApiGenerator {}

smoke/test_openapi/pubspec.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@ dependencies:
1313
dogs_built: any
1414
built_collection: ^5.1.1
1515
built_value: ^8.8.1
16-
openapi_generator_annotations: ^5.0.2
17-
petstore_api:
18-
path: api/petstore_api
16+
openapi:
17+
path: openapi
1918

2019
dev_dependencies:
2120
build_runner: any
2221
dogs_generator: any
2322
built_value_generator: ^8.8.1
24-
openapi_generator: ^5.0.2
2523

2624
lints: ^2.0.1
2725
test: ^1.23.1

smoke/test_openapi/pubspec_overrides.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ dependency_overrides:
44
dogs_generator:
55
path: ../../packages/dogs_generator
66
dogs_built:
7-
path: ../../packages/dogs_built
7+
path: ../../packages/dogs_built
8+
analyzer: any

smoke/test_openapi/smoke.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515
# limitations under the License.
1616
#
1717

18+
# Setup OpenAPI Generator CLI
19+
pub global activate openapi_generator_cli
20+
21+
(
22+
rm -rf "openapi"
23+
mkdir "openapi"
24+
cd "openapi"
25+
openapi-generator generate -i https://petstore.swagger.io/v2/swagger.json -g dart-dio
26+
flutter pub get
27+
flutter pub run build_runner build --delete-conflicting-outputs --verbose
28+
)
29+
30+
# Run the test
1831
flutter pub get
1932
flutter pub upgrade
2033
flutter pub run build_runner build --delete-conflicting-outputs --verbose

0 commit comments

Comments
 (0)