Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dart-dio] Serializes request bodies using a specific serializer #6384

Merged
merged 2 commits into from
Jan 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,7 +43,8 @@ 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;

Expand Down Expand Up @@ -347,7 +348,8 @@ 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ class StoreApi {

final List<String> contentTypes = [];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class UserApi {

final List<String> contentTypes = [];

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

Expand Down Expand Up @@ -394,7 +395,8 @@ class UserApi {

final List<String> contentTypes = [];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ 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;

Expand Down Expand Up @@ -360,7 +361,8 @@ 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ class StoreApi {
'application/json',
];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class UserApi {
'application/json',
];

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

Expand Down Expand Up @@ -437,7 +438,8 @@ class UserApi {
'application/json',
];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class AnotherFakeApi {
'application/json',
];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class FakeApi {
'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;

Expand Down Expand Up @@ -164,7 +165,7 @@ class FakeApi {
'application/json',
];

final serializedBody = _serializers.serialize(body);
var serializedBody = body;
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;

Expand Down Expand Up @@ -227,7 +228,8 @@ class FakeApi {
'application/json',
];

final serializedBody = _serializers.serialize(outerComposite);
final bodySerializer = _serializers.serializerForType(OuterComposite);
final serializedBody = _serializers.serializeWith(bodySerializer, outerComposite);
final jsonouterComposite = json.encode(serializedBody);
bodyData = jsonouterComposite;

Expand Down Expand Up @@ -291,7 +293,7 @@ class FakeApi {
'application/json',
];

final serializedBody = _serializers.serialize(body);
var serializedBody = body;
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;

Expand Down Expand Up @@ -354,7 +356,7 @@ class FakeApi {
'application/json',
];

final serializedBody = _serializers.serialize(body);
var serializedBody = body;
final jsonbody = json.encode(serializedBody);
bodyData = jsonbody;

Expand Down Expand Up @@ -417,7 +419,8 @@ class FakeApi {
'application/json',
];

final serializedBody = _serializers.serialize(fileSchemaTestClass);
final bodySerializer = _serializers.serializerForType(FileSchemaTestClass);
final serializedBody = _serializers.serializeWith(bodySerializer, fileSchemaTestClass);
final jsonfileSchemaTestClass = json.encode(serializedBody);
bodyData = jsonfileSchemaTestClass;

Expand Down Expand Up @@ -470,7 +473,8 @@ class FakeApi {
'application/json',
];

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

Expand Down Expand Up @@ -521,7 +525,8 @@ class FakeApi {
'application/json',
];

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

Expand Down Expand Up @@ -793,7 +798,8 @@ class FakeApi {
'application/json',
];

final serializedBody = _serializers.serialize(requestBody);
final bodySerializer = _serializers.serializerForType(String);
final serializedBody = _serializers.serializeWith(bodySerializer, requestBody);
final jsonrequestBody = json.encode(serializedBody);
bodyData = jsonrequestBody;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class FakeClassnameTags123Api {
'application/json',
];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ 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;

Expand Down Expand Up @@ -347,7 +348,8 @@ 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ class StoreApi {
'application/json',
];

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class UserApi {
'application/json',
];

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

Expand Down Expand Up @@ -402,7 +403,8 @@ class UserApi {
'application/json',
];

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

Expand Down