Skip to content

Commit 5b14a32

Browse files
HavenDVgithub-actions[bot]
andauthored
feat: Updated OpenAPI spec (#36)
Co-authored-by: github-actions[bot] <dependabot@bot.com>
1 parent d8c9c5c commit 5b14a32

20 files changed

Lines changed: 2016 additions & 80 deletions

src/libs/DeepL/Generated/DeepL.CorrectTextClient.CorrectText.g.cs

Lines changed: 754 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
2+
#nullable enable
3+
4+
namespace DeepL
5+
{
6+
/// <summary>
7+
/// The `correct` endpoint fixes spelling and grammar errors without broader rephrasing. Use it when you want<br/>
8+
/// a minimal-change correction pass rather than the broader rewriting performed by `rephrase`.<br/>
9+
/// If no httpClient is provided, a new one will be created.<br/>
10+
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
11+
/// </summary>
12+
public sealed partial class CorrectTextClient : global::DeepL.ICorrectTextClient, global::System.IDisposable
13+
{
14+
/// <summary>
15+
/// DeepL API Pro
16+
/// </summary>
17+
public const string DefaultBaseUrl = "https://api.deepl.com/";
18+
19+
private bool _disposeHttpClient = true;
20+
21+
/// <inheritdoc/>
22+
public global::System.Net.Http.HttpClient HttpClient { get; }
23+
24+
/// <inheritdoc/>
25+
public System.Uri? BaseUri => ResolveDisplayedBaseUri();
26+
27+
/// <inheritdoc/>
28+
public global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization> Authorizations { get; }
29+
30+
/// <inheritdoc/>
31+
public bool ReadResponseAsString { get; set; }
32+
#if DEBUG
33+
= true;
34+
#endif
35+
36+
/// <inheritdoc/>
37+
public global::DeepL.AutoSDKClientOptions Options { get; }
38+
39+
40+
internal global::DeepL.AutoSDKServerConfiguration AutoSDKServerConfiguration { get; set; } = new global::DeepL.AutoSDKServerConfiguration();
41+
/// <summary>
42+
///
43+
/// </summary>
44+
public global::System.Text.Json.Serialization.JsonSerializerContext JsonSerializerContext { get; set; } = global::DeepL.SourceGenerationContext.Default;
45+
46+
47+
48+
private static readonly global::DeepL.AutoSDKServer[] s_availableServers = new global::DeepL.AutoSDKServer[]
49+
{ new global::DeepL.AutoSDKServer(
50+
id: "https-api-deepl-com",
51+
name: "DeepL API Pro",
52+
url: "https://api.deepl.com/",
53+
description: "DeepL API Pro"),
54+
new global::DeepL.AutoSDKServer(
55+
id: "https-api-free-deepl-com",
56+
name: "DeepL API Free",
57+
url: "https://api-free.deepl.com/",
58+
description: "DeepL API Free"),
59+
};
60+
61+
/// <summary>
62+
/// The server options available for this client.
63+
/// </summary>
64+
public global::System.Collections.Generic.IReadOnlyList<global::DeepL.AutoSDKServer> AvailableServers => s_availableServers;
65+
66+
/// <summary>
67+
/// The currently selected server for this client, if any.
68+
/// </summary>
69+
public global::DeepL.AutoSDKServer? SelectedServer
70+
{
71+
get => ResolveSelectedServer();
72+
set => SelectServer(value);
73+
}
74+
75+
/// <summary>
76+
/// Creates a new instance of the CorrectTextClient.
77+
/// If no httpClient is provided, a new one will be created.
78+
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
79+
/// </summary>
80+
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
81+
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
82+
/// <param name="authorizations">The authorizations to use for the requests.</param>
83+
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
84+
public CorrectTextClient(
85+
global::System.Net.Http.HttpClient? httpClient = null,
86+
global::System.Uri? baseUri = null,
87+
global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>? authorizations = null,
88+
bool disposeHttpClient = true) : this(
89+
httpClient,
90+
baseUri,
91+
authorizations,
92+
options: null,
93+
disposeHttpClient: disposeHttpClient)
94+
{
95+
}
96+
97+
/// <summary>
98+
/// Creates a new instance of the CorrectTextClient with explicit options but no base URL override.
99+
/// Skips passing <c>baseUri</c> so the default base URL from the OpenAPI spec applies.
100+
/// </summary>
101+
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
102+
/// <param name="authorizations">The authorizations to use for the requests.</param>
103+
/// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
104+
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
105+
public CorrectTextClient(
106+
global::System.Net.Http.HttpClient? httpClient,
107+
global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>? authorizations,
108+
global::DeepL.AutoSDKClientOptions? options,
109+
bool disposeHttpClient = true) : this(
110+
httpClient,
111+
baseUri: null,
112+
authorizations,
113+
options,
114+
disposeHttpClient: disposeHttpClient)
115+
{
116+
}
117+
118+
/// <summary>
119+
/// Creates a new instance of the CorrectTextClient.
120+
/// If no httpClient is provided, a new one will be created.
121+
/// If no baseUri is provided, the default baseUri from OpenAPI spec will be used.
122+
/// </summary>
123+
/// <param name="httpClient">The HttpClient instance. If not provided, a new one will be created.</param>
124+
/// <param name="baseUri">The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used.</param>
125+
/// <param name="authorizations">The authorizations to use for the requests.</param>
126+
/// <param name="options">Client-wide request defaults such as headers, query parameters, retries, and timeout.</param>
127+
/// <param name="disposeHttpClient">Dispose the HttpClient when the instance is disposed. True by default.</param>
128+
public CorrectTextClient(
129+
global::System.Net.Http.HttpClient? httpClient,
130+
global::System.Uri? baseUri,
131+
global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>? authorizations,
132+
global::DeepL.AutoSDKClientOptions? options,
133+
bool disposeHttpClient = true)
134+
{
135+
136+
HttpClient = httpClient ?? new global::System.Net.Http.HttpClient();
137+
if (baseUri is not null)
138+
{
139+
HttpClient.BaseAddress ??= baseUri;
140+
}
141+
Authorizations = authorizations ?? new global::System.Collections.Generic.List<global::DeepL.EndPointAuthorization>();
142+
Options = options ?? new global::DeepL.AutoSDKClientOptions();
143+
_disposeHttpClient = disposeHttpClient;
144+
145+
AutoSDKServerConfiguration.ExplicitBaseUri = baseUri ?? httpClient?.BaseAddress;
146+
147+
Initialized(HttpClient);
148+
}
149+
150+
/// <inheritdoc/>
151+
public void Dispose()
152+
{
153+
if (_disposeHttpClient)
154+
{
155+
HttpClient.Dispose();
156+
}
157+
}
158+
159+
partial void Initialized(
160+
global::System.Net.Http.HttpClient client);
161+
partial void PrepareArguments(
162+
global::System.Net.Http.HttpClient client);
163+
partial void PrepareRequest(
164+
global::System.Net.Http.HttpClient client,
165+
global::System.Net.Http.HttpRequestMessage request);
166+
partial void ProcessResponse(
167+
global::System.Net.Http.HttpClient client,
168+
global::System.Net.Http.HttpResponseMessage response);
169+
partial void ProcessResponseContent(
170+
global::System.Net.Http.HttpClient client,
171+
global::System.Net.Http.HttpResponseMessage response,
172+
ref string content);
173+
174+
175+
/// <summary>
176+
/// Selects one of the generated server options by id.
177+
/// </summary>
178+
public bool TrySelectServer(string serverId)
179+
{
180+
if (string.IsNullOrWhiteSpace(serverId))
181+
{
182+
return false;
183+
}
184+
185+
foreach (var server in s_availableServers)
186+
{
187+
if (string.Equals(server.Id, serverId, global::System.StringComparison.OrdinalIgnoreCase))
188+
{
189+
AutoSDKServerConfiguration.SelectedServer = server;
190+
AutoSDKServerConfiguration.ExplicitBaseUri = null;
191+
return true;
192+
}
193+
}
194+
195+
return false;
196+
}
197+
198+
/// <summary>
199+
/// Clears the currently selected server.
200+
/// </summary>
201+
public void ClearSelectedServer()
202+
{
203+
AutoSDKServerConfiguration.SelectedServer = null;
204+
}
205+
206+
private global::DeepL.AutoSDKServer? ResolveSelectedServer()
207+
{
208+
var selectedServer = AutoSDKServerConfiguration.SelectedServer;
209+
if (selectedServer is null)
210+
{
211+
return null;
212+
}
213+
214+
foreach (var server in s_availableServers)
215+
{
216+
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
217+
{
218+
return server;
219+
}
220+
}
221+
222+
return null;
223+
}
224+
225+
private void SelectServer(global::DeepL.AutoSDKServer? server)
226+
{
227+
if (server is null)
228+
{
229+
AutoSDKServerConfiguration.SelectedServer = null;
230+
return;
231+
}
232+
233+
foreach (var candidate in s_availableServers)
234+
{
235+
if (string.Equals(candidate.Id, server.Id, global::System.StringComparison.Ordinal))
236+
{
237+
AutoSDKServerConfiguration.SelectedServer = candidate;
238+
AutoSDKServerConfiguration.ExplicitBaseUri = null;
239+
return;
240+
}
241+
}
242+
243+
throw new global::System.ArgumentException("The provided server is not available for this client.", nameof(server));
244+
}
245+
246+
private global::System.Uri? ResolveDisplayedBaseUri()
247+
{
248+
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
249+
{
250+
return explicitBaseUri;
251+
}
252+
253+
return ResolveSelectedServer()?.Uri ?? (s_availableServers.Length > 0 ? s_availableServers[0].Uri : HttpClient.BaseAddress);
254+
}
255+
256+
private global::System.Uri? ResolveBaseUri(
257+
global::DeepL.AutoSDKServer[] servers,
258+
string defaultBaseUrl)
259+
{
260+
if (AutoSDKServerConfiguration.ExplicitBaseUri is global::System.Uri explicitBaseUri)
261+
{
262+
return explicitBaseUri;
263+
}
264+
265+
if (AutoSDKServerConfiguration.SelectedServer is global::DeepL.AutoSDKServer selectedServer)
266+
{
267+
foreach (var server in servers)
268+
{
269+
if (string.Equals(server.Id, selectedServer.Id, global::System.StringComparison.Ordinal))
270+
{
271+
return server.Uri;
272+
}
273+
}
274+
}
275+
276+
if (servers.Length > 0)
277+
{
278+
return servers[0].Uri;
279+
}
280+
281+
return string.IsNullOrWhiteSpace(defaultBaseUrl)
282+
? HttpClient.BaseAddress
283+
: new global::System.Uri(defaultBaseUrl, global::System.UriKind.RelativeOrAbsolute);
284+
}
285+
}
286+
}

src/libs/DeepL/Generated/DeepL.DeepLClient.g.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ public sealed partial class DeepLClient : global::DeepL.IDeepLClient, global::Sy
5454
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
5555
};
5656

57+
/// <summary>
58+
/// The `correct` endpoint fixes spelling and grammar errors without broader rephrasing. Use it when you want<br/>
59+
/// a minimal-change correction pass rather than the broader rewriting performed by `rephrase`.
60+
/// </summary>
61+
public CorrectTextClient CorrectText => new CorrectTextClient(HttpClient, baseUri: null, authorizations: Authorizations, options: Options)
62+
{
63+
ReadResponseAsString = ReadResponseAsString,
64+
JsonSerializerContext = JsonSerializerContext,
65+
AutoSDKServerConfiguration = AutoSDKServerConfiguration,
66+
};
67+
5768
/// <summary>
5869
/// Please note that this is the spec for the (old) v2 glossary endpoint.<br/>
5970
/// We recommend users switch to the newer v3 glossary endpoints, which support editability and multilinguality.<br/>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#nullable enable
2+
3+
namespace DeepL
4+
{
5+
public partial interface ICorrectTextClient
6+
{
7+
/// <summary>
8+
/// Correct text<br/>
9+
/// Fix spelling and grammar errors in one or more texts. Unlike `/v2/write/rephrase`, this endpoint applies<br/>
10+
/// a minimal-change correction pass and does not rewrite the text for style or tone.
11+
/// </summary>
12+
/// <param name="request"></param>
13+
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
14+
/// <param name="cancellationToken">The token to cancel the operation with</param>
15+
/// <exception cref="global::DeepL.ApiException"></exception>
16+
global::System.Threading.Tasks.Task<global::DeepL.CorrectTextResponse> CorrectTextAsync(
17+
18+
global::DeepL.CorrectTextRequest request,
19+
global::DeepL.AutoSDKRequestOptions? requestOptions = default,
20+
global::System.Threading.CancellationToken cancellationToken = default);
21+
/// <summary>
22+
/// Correct text<br/>
23+
/// Fix spelling and grammar errors in one or more texts. Unlike `/v2/write/rephrase`, this endpoint applies<br/>
24+
/// a minimal-change correction pass and does not rewrite the text for style or tone.
25+
/// </summary>
26+
/// <param name="request"></param>
27+
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
28+
/// <param name="cancellationToken">The token to cancel the operation with</param>
29+
/// <exception cref="global::DeepL.ApiException"></exception>
30+
global::System.Threading.Tasks.Task<global::DeepL.AutoSDKHttpResponse<global::DeepL.CorrectTextResponse>> CorrectTextAsResponseAsync(
31+
32+
global::DeepL.CorrectTextRequest request,
33+
global::DeepL.AutoSDKRequestOptions? requestOptions = default,
34+
global::System.Threading.CancellationToken cancellationToken = default);
35+
/// <summary>
36+
/// Correct text<br/>
37+
/// Fix spelling and grammar errors in one or more texts. Unlike `/v2/write/rephrase`, this endpoint applies<br/>
38+
/// a minimal-change correction pass and does not rewrite the text for style or tone.
39+
/// </summary>
40+
/// <param name="text">
41+
/// Text to be corrected. Only UTF-8-encoded plain text is supported. Corrections are returned in the same order as they are requested.
42+
/// </param>
43+
/// <param name="targetLang">
44+
/// The language for the text improvement.<br/>
45+
/// Example: de
46+
/// </param>
47+
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
48+
/// <param name="cancellationToken">The token to cancel the operation with</param>
49+
/// <exception cref="global::System.InvalidOperationException"></exception>
50+
global::System.Threading.Tasks.Task<global::DeepL.CorrectTextResponse> CorrectTextAsync(
51+
global::System.Collections.Generic.IList<string> text,
52+
global::DeepL.TargetLanguageWrite? targetLang = default,
53+
global::DeepL.AutoSDKRequestOptions? requestOptions = default,
54+
global::System.Threading.CancellationToken cancellationToken = default);
55+
}
56+
}

0 commit comments

Comments
 (0)