diff --git a/modules/openapi-generator/src/main/resources/dart-dio/api.mustache b/modules/openapi-generator/src/main/resources/dart-dio/api.mustache index a7f830a51352..82b6057a683e 100644 --- a/modules/openapi-generator/src/main/resources/dart-dio/api.mustache +++ b/modules/openapi-generator/src/main/resources/dart-dio/api.mustache @@ -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}} diff --git a/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart b/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart index c975d10e631f..4e37f1e056a1 100644 --- a/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart @@ -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; @@ -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; diff --git a/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart b/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart index eb62c2dc17f5..260956e42153 100644 --- a/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart +++ b/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart @@ -205,7 +205,8 @@ class StoreApi { final List contentTypes = []; - final serializedBody = _serializers.serialize(body); + final bodySerializer = _serializers.serializerForType(Order); + final serializedBody = _serializers.serializeWith(bodySerializer, body); final jsonbody = json.encode(serializedBody); bodyData = jsonbody; diff --git a/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart b/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart index 9183e1f5a76a..64d597726099 100644 --- a/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart +++ b/samples/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart @@ -37,7 +37,8 @@ class UserApi { final List contentTypes = []; - final serializedBody = _serializers.serialize(body); + final bodySerializer = _serializers.serializerForType(User); + final serializedBody = _serializers.serializeWith(bodySerializer, body); final jsonbody = json.encode(serializedBody); bodyData = jsonbody; @@ -394,7 +395,8 @@ class UserApi { final List contentTypes = []; - final serializedBody = _serializers.serialize(body); + final bodySerializer = _serializers.serializerForType(User); + final serializedBody = _serializers.serializeWith(bodySerializer, body); final jsonbody = json.encode(serializedBody); bodyData = jsonbody; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart index 29837e6354be..646a68b206ec 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/pet_api.dart @@ -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; @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart index cc30e5b55972..e7f61eb64090 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/store_api.dart @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart index c7ba72a9a88a..b3291c98cda8 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib/lib/api/user_api.dart @@ -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; @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart index bb7458c32f1e..b0a1bb7491b8 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/another_fake_api.dart @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart index 4347da0f2542..4e054b7de8a1 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_api.dart @@ -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; @@ -164,7 +165,7 @@ class FakeApi { 'application/json', ]; - final serializedBody = _serializers.serialize(body); + var serializedBody = body; final jsonbody = json.encode(serializedBody); bodyData = jsonbody; @@ -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; @@ -291,7 +293,7 @@ class FakeApi { 'application/json', ]; - final serializedBody = _serializers.serialize(body); + var serializedBody = body; final jsonbody = json.encode(serializedBody); bodyData = jsonbody; @@ -354,7 +356,7 @@ class FakeApi { 'application/json', ]; - final serializedBody = _serializers.serialize(body); + var serializedBody = body; final jsonbody = json.encode(serializedBody); bodyData = jsonbody; @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart index 568b5043f6d9..ce622874e326 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/fake_classname_tags123_api.dart @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/pet_api.dart index 7f79f93ca0af..e340d126ccf6 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/pet_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/pet_api.dart @@ -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; @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/store_api.dart index 98f0a4f507b7..ea1d9cbdd4f6 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/store_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/store_api.dart @@ -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; diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/user_api.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/user_api.dart index 52a48e251df7..63865bc24438 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/user_api.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/lib/api/user_api.dart @@ -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; @@ -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;