openapi-generator-dart icon indicating copy to clipboard operation
openapi-generator-dart copied to clipboard

How to set a custom serializer for a single type?

Open WilkoThomassen opened this issue 2 years ago • 0 comments

The api client constructor gets generated as follows:

ShuttelApiClient({ Dio? dio, Serializers? serializers, String? basePathOverride, List<Interceptor>? interceptors, }) : this.serializers = serializers ?? standardSerializers, this.dio = dio ?? Dio(BaseOptions( baseUrl: basePathOverride ?? basePath, connectTimeout: 5000, receiveTimeout: 3000, )) { if (interceptors == null) { this.dio.interceptors.addAll([ OAuthInterceptor(), BasicAuthInterceptor(), BearerAuthInterceptor(), ApiKeyAuthInterceptor(), ]); } else { this.dio.interceptors.addAll(interceptors); } }

When we create an instance of the api client we want so set a custom serializer for a single type. Is this possible? the way I see it I can only create an override for all type serializers. This means I would have to copy all the generated serializers to the project referring the generated api client.

Tested it in the latest version 3.3.0

WilkoThomassen avatar Apr 13 '22 14:04 WilkoThomassen