Skip to content

Commit 373fb8e

Browse files
committed
feat: Added partial methods for constructors te set up/validate things.
1 parent c73b1aa commit 373fb8e

File tree

396 files changed

+1675
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

396 files changed

+1675
-0
lines changed

src/libs/OpenApiGenerator.Core/Generation/Sources.Authorizations.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,19 @@ public sealed partial class {authorization.Settings.ClassName}
106106
global::System.Net.Http.HttpClient? httpClient = null,
107107
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
108108
{{
109+
Authorizing(_httpClient, {string.Join(", ", parameters.Select(x => $"ref {x}"))});
110+
109111
{methodName}({string.Join(", ", parameters.Select(x => $"{x}"))});
112+
113+
Authorized(_httpClient);
110114
}}
115+
116+
partial void Authorizing(
117+
global::System.Net.Http.HttpClient client,
118+
{string.Join("\n", parameters.Select(x => $@"
119+
ref string {x},")).TrimEnd(',')});
120+
partial void Authorized(
121+
global::System.Net.Http.HttpClient client);
111122
}}
112123
}}".RemoveBlankLinesWhereOnlyWhitespaces();
113124
}

src/libs/OpenApiGenerator.Core/Generation/Sources.Clients.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public sealed partial class {endPoint.ClassName} : global::System.IDisposable
5050
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
5151
{(hasOptions ? $@"
5252
_jsonSerializerOptions = _jsonSerializerOptions ?? {(endPoint.Id == "MainConstructor" ? serializer.CreateDefaultSettings(endPoint.Converters) : $"new {serializer.GetOptionsType()}()")};" : " ")}
53+
54+
Initialized(_httpClient);
5355
}}
5456
5557
/// <inheritdoc/>
@@ -58,6 +60,8 @@ public void Dispose()
5860
_httpClient.Dispose();
5961
}}
6062
63+
partial void Initialized(
64+
global::System.Net.Http.HttpClient client);
6165
partial void PrepareArguments(
6266
global::System.Net.Http.HttpClient client);
6367
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.Api.Constructors.Bearer.g.verified.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ public Api(
1212
global::System.Net.Http.HttpClient? httpClient = null,
1313
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
1414
{
15+
Authorizing(_httpClient, ref apiKey);
16+
1517
AuthorizeUsingBearer(apiKey);
18+
19+
Authorized(_httpClient);
1620
}
21+
22+
partial void Authorizing(
23+
global::System.Net.Http.HttpClient client,
24+
ref string apiKey);
25+
partial void Authorized(
26+
global::System.Net.Http.HttpClient client);
1727
}
1828
}

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.Api.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public Api(
9797
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
9898
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
9999
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
100+
101+
Initialized(_httpClient);
100102
}
101103

102104
/// <inheritdoc/>
@@ -105,6 +107,8 @@ public void Dispose()
105107
_httpClient.Dispose();
106108
}
107109

110+
partial void Initialized(
111+
global::System.Net.Http.HttpClient client);
108112
partial void PrepareArguments(
109113
global::System.Net.Http.HttpClient client);
110114
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.ChatClient.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public ChatClient(
3636
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
3737
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
3838
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
39+
40+
Initialized(_httpClient);
3941
}
4042

4143
/// <inheritdoc/>
@@ -44,6 +46,8 @@ public void Dispose()
4446
_httpClient.Dispose();
4547
}
4648

49+
partial void Initialized(
50+
global::System.Net.Http.HttpClient client);
4751
partial void PrepareArguments(
4852
global::System.Net.Http.HttpClient client);
4953
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CompletionClient.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public CompletionClient(
3636
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
3737
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
3838
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
39+
40+
Initialized(_httpClient);
3941
}
4042

4143
/// <inheritdoc/>
@@ -44,6 +46,8 @@ public void Dispose()
4446
_httpClient.Dispose();
4547
}
4648

49+
partial void Initialized(
50+
global::System.Net.Http.HttpClient client);
4751
partial void PrepareArguments(
4852
global::System.Net.Http.HttpClient client);
4953
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.CustomModelsClient.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public CustomModelsClient(
3636
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
3737
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
3838
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
39+
40+
Initialized(_httpClient);
3941
}
4042

4143
/// <inheritdoc/>
@@ -44,6 +46,8 @@ public void Dispose()
4446
_httpClient.Dispose();
4547
}
4648

49+
partial void Initialized(
50+
global::System.Net.Http.HttpClient client);
4751
partial void PrepareArguments(
4852
global::System.Net.Http.HttpClient client);
4953
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.DatasetsClient.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public DatasetsClient(
3636
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
3737
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
3838
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
39+
40+
Initialized(_httpClient);
3941
}
4042

4143
/// <inheritdoc/>
@@ -44,6 +46,8 @@ public void Dispose()
4446
_httpClient.Dispose();
4547
}
4648

49+
partial void Initialized(
50+
global::System.Net.Http.HttpClient client);
4751
partial void PrepareArguments(
4852
global::System.Net.Http.HttpClient client);
4953
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.GrammaticalErrorCorrectionsClient.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public GrammaticalErrorCorrectionsClient(
3636
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
3737
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
3838
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
39+
40+
Initialized(_httpClient);
3941
}
4042

4143
/// <inheritdoc/>
@@ -44,6 +46,8 @@ public void Dispose()
4446
_httpClient.Dispose();
4547
}
4648

49+
partial void Initialized(
50+
global::System.Net.Http.HttpClient client);
4751
partial void PrepareArguments(
4852
global::System.Net.Http.HttpClient client);
4953
partial void PrepareRequest(

src/tests/OpenApiGenerator.SnapshotTests/Snapshots/Ai21/NewtonsoftJson/_#G.JambaCompleteClient.g.verified.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public JambaCompleteClient(
3636
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
3737
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
3838
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();
39+
40+
Initialized(_httpClient);
3941
}
4042

4143
/// <inheritdoc/>
@@ -44,6 +46,8 @@ public void Dispose()
4446
_httpClient.Dispose();
4547
}
4648

49+
partial void Initialized(
50+
global::System.Net.Http.HttpClient client);
4751
partial void PrepareArguments(
4852
global::System.Net.Http.HttpClient client);
4953
partial void PrepareRequest(

0 commit comments

Comments
 (0)