Browse Source

dynamite: Add constructor to create client from another client

pull/439/head
jld3103 1 year ago
parent
commit
e4d2352b02
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 26
      packages/dynamite/dynamite/lib/src/openapi_builder.dart

26
packages/dynamite/dynamite/lib/src/openapi_builder.dart

@ -202,7 +202,7 @@ class OpenAPIBuilder implements Builder {
if (isRootClient) { if (isRootClient) {
b b
..extend = refer('DynamiteClient') ..extend = refer('DynamiteClient')
..constructors.add( ..constructors.addAll([
Constructor( Constructor(
(final b) => b (final b) => b
..requiredParameters.add( ..requiredParameters.add(
@ -247,7 +247,29 @@ class OpenAPIBuilder implements Builder {
], ],
]), ]),
), ),
); Constructor(
(final b) => b
..name = 'fromClient'
..requiredParameters.add(
Parameter(
(final b) => b
..name = 'client'
..type = refer('DynamiteClient'),
),
)
..initializers.add(
const Code('''
super(
client.baseURL,
baseHeaders: client.baseHeaders,
httpClient: client.httpClient,
cookieJar: client.cookieJar,
authentications: client.authentications,
)
'''),
),
),
]);
} else { } else {
b b
..fields.add( ..fields.add(

Loading…
Cancel
Save