Skip to content

Commit

Permalink
Fix conflict if swagger paramName is data (#4266)
Browse files Browse the repository at this point in the history
* Fix conflict if swagger paramName is data

* Updated petstore as per PR requirements
  • Loading branch information
lingster authored and wing328 committed Oct 26, 2019
1 parent 288c69f commit 2d2a266
Show file tree
Hide file tree
Showing 12 changed files with 878 additions and 885 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class {{classname}} {
{{^isListContainer}}
var serializedBody = _serializers.serialize({{paramName}});
{{/isListContainer}}
var data = json.encode(serializedBody);
var json{{paramName}} = json.encode(serializedBody);
{{/bodyParam}}

return _dio.request(
path,
queryParameters: queryParams,
{{#bodyParam}}
data: data,
data: json{{paramName}},
{{/bodyParam}}
options: Options(
method: '{{httpMethod}}'.toUpperCase(),
Expand Down
49 changes: 28 additions & 21 deletions samples/client/petstore/dart-dio/lib/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,52 @@ 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}) {
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);
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() {
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() {
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() {
UserApi getUserApi() {
return UserApi(dio, serializers);
}
}
}


}
Loading

0 comments on commit 2d2a266

Please sign in to comment.