Đào Hoàng Sơn 3a8e598ca2 [dart-dio] Various fixes (#5027)
* [dart-dio+time_machine] Add missing import, serializer

* [dart-dio] Remove bad import from `http` package

* [dart-dio] Use raw strings for those that contain variable name.

This should eliminate potential issue with variables like `$ref`.

* [dart-dio] Use `_path` instead of `path` to avoid potential conflict with op params.

See 1bec0b47b1/Kubernetes.json, there are a few with `{path}` param.

* [dart-dio+time_machine] Use `OffsetXxx` classes for date time values
2020-01-20 11:56:24 +08:00

58 lines
1.4 KiB
Dart

library openapi.api;
import 'package:dio/dio.dart';
import 'package:built_value/serializer.dart';
import 'package:openapi/serializers.dart';
import 'package:openapi/api/pet_api.dart';
import 'package:openapi/api/store_api.dart';
import 'package:openapi/api/user_api.dart';
class Openapi {
Dio dio;
Serializers serializers;
String basePath = "http://petstore.swagger.io/v2";
Openapi({this.dio, Serializers serializers}) {
if (dio == null) {
BaseOptions options = new BaseOptions(
baseUrl: basePath,
connectTimeout: 5000,
receiveTimeout: 3000,
);
this.dio = new Dio(options);
}
this.serializers = serializers ?? standardSerializers;
}
/**
* Get PetApi instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
PetApi getPetApi() {
return PetApi(dio, serializers);
}
/**
* Get StoreApi instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
StoreApi getStoreApi() {
return StoreApi(dio, serializers);
}
/**
* Get UserApi instance, base route and serializer can be overridden by a given but be careful,
* by doing that all interceptors will not be executed
*/
UserApi getUserApi() {
return UserApi(dio, serializers);
}
}