-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed missing xml docs for clients.
- Loading branch information
Showing
149 changed files
with
777 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/libs/OpenApiGenerator.Core/Generation/Sources.Clients.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using OpenApiGenerator.Core.Extensions; | ||
using OpenApiGenerator.Core.Models; | ||
|
||
namespace OpenApiGenerator.Core.Generation; | ||
|
||
public static partial class Sources | ||
{ | ||
public static string GenerateConstructors( | ||
EndPoint endPoint) | ||
{ | ||
return $@" | ||
#nullable enable | ||
namespace {endPoint.Namespace} | ||
{{ | ||
/// <summary> | ||
/// {endPoint.Summary} | ||
/// If no httpClient is provided, a new one will be created. | ||
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. | ||
/// </summary> | ||
public sealed partial class {endPoint.ClassName} : global::System.IDisposable | ||
{{ | ||
private readonly global::System.Net.Http.HttpClient _httpClient; | ||
{(endPoint.Properties.Length != 0 ? "\n" + endPoint.Properties.Select(x => $@" | ||
{x.Summary.ToXmlDocumentationSummary(level: 8)} | ||
public {x.Type.CSharpType} {x.Name} => new {x.Type.CSharpType}(_httpClient); | ||
").Inject() : " ")} | ||
/// <summary> | ||
/// Creates a new instance of the {endPoint.ClassName}. | ||
/// If no httpClient is provided, a new one will be created. | ||
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. | ||
/// </summary> | ||
/// <param name=""httpClient""></param> | ||
/// <param name=""baseUri""></param> | ||
public {endPoint.ClassName}( | ||
global::System.Net.Http.HttpClient? httpClient = null, | ||
global::System.Uri? baseUri = null) | ||
{{ | ||
_httpClient = httpClient ?? new global::System.Net.Http.HttpClient(); | ||
_httpClient.BaseAddress ??= baseUri ?? new global::System.Uri(""{endPoint.BaseUrl}""); | ||
}} | ||
/// <inheritdoc/> | ||
public void Dispose() | ||
{{ | ||
_httpClient.Dispose(); | ||
}} | ||
}} | ||
}}".RemoveBlankLinesWhereOnlyWhitespaces(); | ||
} | ||
|
||
public static string GenerateAuthorizationMethod( | ||
EndPoint endPoint) | ||
{ | ||
return $@" | ||
#nullable enable | ||
namespace {endPoint.Namespace} | ||
{{ | ||
public sealed partial class {endPoint.ClassName} | ||
{{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name=""apiKey""></param> | ||
public void {endPoint.NotAsyncMethodName}( | ||
string apiKey) | ||
{{ | ||
apiKey = apiKey ?? throw new global::System.ArgumentNullException(nameof(apiKey)); | ||
_httpClient.DefaultRequestHeaders.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( | ||
scheme: ""{endPoint.AuthorizationScheme.ToPropertyName()}"", | ||
parameter: apiKey); | ||
}} | ||
}} | ||
}}".RemoveBlankLinesWhereOnlyWhitespaces(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.