Skip to content

Commit

Permalink
Handles primitive types
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-burton committed Dec 19, 2020
1 parent 5ff5dc3 commit c5e7cce
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 265 deletions.
16 changes: 11 additions & 5 deletions modules/openapi-generator/src/main/resources/dart-dio/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,19 @@ class {{classname}} {
{{/hasFormParams}}
{{#bodyParam}}

{{#isArray}}
{{#isArray}}
const type = FullType(BuiltList, [FullType({{baseType}})]);
final serializedBody = _serializers.serialize({{paramName}}, specifiedType: type);
{{/isArray}}
{{^isArray}}
final serializedBody = _serializers.serialize({{paramName}});
{{/isArray}}
{{/isArray}}
{{^isArray}}
{{#isPrimitiveType}}
var serializedBody = {{paramName}};
{{/isPrimitiveType}}
{{^isPrimitiveType}}
final bodySerializer = _serializers.serializerForType({{baseType}});
final serializedBody = _serializers.serializeWith(bodySerializer, {{paramName}});
{{/isPrimitiveType}}
{{/isArray}}
final json{{paramName}} = json.encode(serializedBody);
bodyData = json{{paramName}};
{{/bodyParam}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,10 @@ class PetApi {
'application/xml',
];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(body);
final bodySerializer = _serializers.serializerForType(Pet);
final serializedBody = _serializers.serializeWith(bodySerializer, body);
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
=======

var bodySerializer = _serializers.serializerForType(Pet);
var serializedBody = _serializers.serializeWith(bodySerializer, body);
var jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down Expand Up @@ -355,21 +348,12 @@ class PetApi {
'application/xml',
];

final serializedBody = _serializers.serialize(body);
final bodySerializer = _serializers.serializerForType(Pet);
final serializedBody = _serializers.serializeWith(bodySerializer, body);
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;

<<<<<<< HEAD
return _dio.request(
=======

var bodySerializer = _serializers.serializerForType(Pet);
var serializedBody = _serializers.serializeWith(bodySerializer, body);
var jsonbody = json.encode(serializedBody);
bodyData = jsonbody;

return _dio.request(
>>>>>>> Updates samples
_path,
queryParameters: queryParams,
data: bodyData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,10 @@ class StoreApi {

final List<String> contentTypes = [];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(body);
final bodySerializer = _serializers.serializerForType(Order);
final serializedBody = _serializers.serializeWith(bodySerializer, body);
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
=======

var bodySerializer = _serializers.serializerForType(Order);
var serializedBody = _serializers.serializeWith(bodySerializer, body);
var jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,10 @@ class UserApi {

final List<String> contentTypes = [];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(body);
final bodySerializer = _serializers.serializerForType(User);
final serializedBody = _serializers.serializeWith(bodySerializer, body);
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
=======

var bodySerializer = _serializers.serializerForType(User);
var serializedBody = _serializers.serializeWith(bodySerializer, body);
var jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down Expand Up @@ -402,17 +395,10 @@ class UserApi {

final List<String> contentTypes = [];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(body);
final bodySerializer = _serializers.serializerForType(User);
final serializedBody = _serializers.serializeWith(bodySerializer, body);
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
=======

var bodySerializer = _serializers.serializerForType(User);
var serializedBody = _serializers.serializeWith(bodySerializer, body);
var jsonbody = json.encode(serializedBody);
bodyData = jsonbody;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,10 @@ class PetApi {
'application/xml',
];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(pet);
final bodySerializer = _serializers.serializerForType(Pet);
final serializedBody = _serializers.serializeWith(bodySerializer, pet);
final jsonpet = json.encode(serializedBody);
bodyData = jsonpet;
=======

var bodySerializer = _serializers.serializerForType(Pet);
var serializedBody = _serializers.serializeWith(bodySerializer, pet);
var jsonpet = json.encode(serializedBody);
bodyData = jsonpet;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down Expand Up @@ -368,21 +361,12 @@ class PetApi {
'application/xml',
];

final serializedBody = _serializers.serialize(pet);
final bodySerializer = _serializers.serializerForType(Pet);
final serializedBody = _serializers.serializeWith(bodySerializer, pet);
final jsonpet = json.encode(serializedBody);
bodyData = jsonpet;

<<<<<<< HEAD
return _dio.request(
=======

var bodySerializer = _serializers.serializerForType(Pet);
var serializedBody = _serializers.serializeWith(bodySerializer, pet);
var jsonpet = json.encode(serializedBody);
bodyData = jsonpet;

return _dio.request(
>>>>>>> Updates samples
_path,
queryParameters: queryParams,
data: bodyData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,10 @@ class StoreApi {
'application/json',
];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(order);
final bodySerializer = _serializers.serializerForType(Order);
final serializedBody = _serializers.serializeWith(bodySerializer, order);
final jsonorder = json.encode(serializedBody);
bodyData = jsonorder;
=======

var bodySerializer = _serializers.serializerForType(Order);
var serializedBody = _serializers.serializeWith(bodySerializer, order);
var jsonorder = json.encode(serializedBody);
bodyData = jsonorder;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,10 @@ class UserApi {
'application/json',
];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(user);
final bodySerializer = _serializers.serializerForType(User);
final serializedBody = _serializers.serializeWith(bodySerializer, user);
final jsonuser = json.encode(serializedBody);
bodyData = jsonuser;
=======

var bodySerializer = _serializers.serializerForType(User);
var serializedBody = _serializers.serializeWith(bodySerializer, user);
var jsonuser = json.encode(serializedBody);
bodyData = jsonuser;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down Expand Up @@ -445,17 +438,10 @@ class UserApi {
'application/json',
];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(user);
final bodySerializer = _serializers.serializerForType(User);
final serializedBody = _serializers.serializeWith(bodySerializer, user);
final jsonuser = json.encode(serializedBody);
bodyData = jsonuser;
=======

var bodySerializer = _serializers.serializerForType(User);
var serializedBody = _serializers.serializeWith(bodySerializer, user);
var jsonuser = json.encode(serializedBody);
bodyData = jsonuser;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ class AnotherFakeApi {
'application/json',
];

<<<<<<< HEAD
final serializedBody = _serializers.serialize(modelClient);
final bodySerializer = _serializers.serializerForType(ModelClient);
final serializedBody = _serializers.serializeWith(bodySerializer, modelClient);
final jsonmodelClient = json.encode(serializedBody);
bodyData = jsonmodelClient;
=======

var bodySerializer = _serializers.serializerForType(Client);
var serializedBody = _serializers.serializeWith(bodySerializer, client);
var jsonclient = json.encode(serializedBody);
bodyData = jsonclient;
>>>>>>> Updates samples

return _dio.request(
_path,
Expand Down
Loading

0 comments on commit c5e7cce

Please sign in to comment.