Skip to content

Commit

Permalink
feat: Added partial methods for constructors te set up/validate things.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Aug 29, 2024
1 parent c73b1aa commit 373fb8e
Show file tree
Hide file tree
Showing 396 changed files with 1,675 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,19 @@ public sealed partial class {authorization.Settings.ClassName}
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
{{
Authorizing(_httpClient, {string.Join(", ", parameters.Select(x => $"ref {x}"))});
{methodName}({string.Join(", ", parameters.Select(x => $"{x}"))});
Authorized(_httpClient);
}}
partial void Authorizing(
global::System.Net.Http.HttpClient client,
{string.Join("\n", parameters.Select(x => $@"
ref string {x},")).TrimEnd(',')});
partial void Authorized(
global::System.Net.Http.HttpClient client);
}}
}}".RemoveBlankLinesWhereOnlyWhitespaces();
}
Expand Down
4 changes: 4 additions & 0 deletions src/libs/OpenApiGenerator.Core/Generation/Sources.Clients.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public sealed partial class {endPoint.ClassName} : global::System.IDisposable
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
{(hasOptions ? $@"
_jsonSerializerOptions = _jsonSerializerOptions ?? {(endPoint.Id == "MainConstructor" ? serializer.CreateDefaultSettings(endPoint.Converters) : $"new {serializer.GetOptionsType()}()")};" : " ")}
Initialized(_httpClient);
}}
/// <inheritdoc/>
Expand All @@ -58,6 +60,8 @@ public void Dispose()
_httpClient.Dispose();
}}
partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ public Api(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
{
Authorizing(_httpClient, ref apiKey);

AuthorizeUsingBearer(apiKey);

Authorized(_httpClient);
}

partial void Authorizing(
global::System.Net.Http.HttpClient client,
ref string apiKey);
partial void Authorized(
global::System.Net.Http.HttpClient client);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public Api(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -105,6 +107,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public ChatClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public CompletionClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public CustomModelsClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public DatasetsClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public GrammaticalErrorCorrectionsClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public JambaCompleteClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public LibraryManagementClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public ParaphraseClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public RAGEngineClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public SegmentationClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public SummarizeClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public TokenizeClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::Newtonsoft.Json.JsonSerializerSettings();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ public Api(
global::System.Net.Http.HttpClient? httpClient = null,
global::System.Uri? baseUri = null) : this(httpClient, baseUri)
{
Authorizing(_httpClient, ref apiKey);

AuthorizeUsingBearer(apiKey);

Authorized(_httpClient);
}

partial void Authorizing(
global::System.Net.Http.HttpClient client,
ref string apiKey);
partial void Authorized(
global::System.Net.Http.HttpClient client);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public Api(
new global::OpenApiGenerator.JsonConverters.OneOfJsonConverterFactory4(),
}
};

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -161,6 +163,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public ChatClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::System.Text.Json.JsonSerializerOptions();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public CompletionClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::System.Text.Json.JsonSerializerOptions();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public CustomModelsClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::System.Text.Json.JsonSerializerOptions();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public DatasetsClient(
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient();
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(BaseUrl);
_jsonSerializerOptions = _jsonSerializerOptions ?? new global::System.Text.Json.JsonSerializerOptions();

Initialized(_httpClient);
}

/// <inheritdoc/>
Expand All @@ -44,6 +46,8 @@ public void Dispose()
_httpClient.Dispose();
}

partial void Initialized(
global::System.Net.Http.HttpClient client);
partial void PrepareArguments(
global::System.Net.Http.HttpClient client);
partial void PrepareRequest(
Expand Down
Loading

0 comments on commit 373fb8e

Please sign in to comment.