Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdks/dotnet/.github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore ${SOLUTION}.sln
Expand Down
2 changes: 2 additions & 0 deletions sdks/dotnet/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd

git_push.sh
global.json
vendor
/api
.openapi-generator
4 changes: 0 additions & 4 deletions sdks/dotnet/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,3 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

git_push.sh
**/Model/*AllOf*
docs/*AllOf*
Empty file modified sdks/dotnet/Dropbox.Sign.sln
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions sdks/dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ directory that corresponds to the file you want updated.
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:

- API version: 3.0.0
- SDK version: 1.8-dev
- Generator version: 7.8.0
- SDK version: 2.0-dev
- Generator version: 7.12.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

### Building
Expand All @@ -49,7 +49,7 @@ this command.
<a id="dependencies"></a>
## Dependencies

- [RestSharp](https://www.nuget.org/packages/RestSharp) - 106.13.0 or later
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 112.0.0 or later
- [Json.NET](https://www.nuget.org/packages/Newtonsoft.Json/) - 13.0.2 or later
- [JsonSubTypes](https://www.nuget.org/packages/JsonSubTypes/) - 1.8.0 or later
- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 5.0.0 or later
Expand Down
2 changes: 1 addition & 1 deletion sdks/dotnet/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8-dev
2.0-dev
64 changes: 64 additions & 0 deletions sdks/dotnet/bin/copy-constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env php
<?php

require_once __DIR__ . '/../vendor/autoload.php';

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

set_error_handler(function ($level, $msg) {
echo "Error: {$msg}";
exit(1);
});

/**
* Between openapi-generator v7.8.0 and v7.12.0 a change was made to the way
* a few generators create constant names from values. The original way was
* actually broken. For example "change-field-visibility" would generate a
* constant name of "TYPE_FIELD_VISIBILITY", dropping the "change" part.
*
* The fix now generates the correct name, "TYPE_CHANGE_FIELD_VISIBILITY".
* However, the fix also gets rid of the previous (incorrect) constant names,
* making the fix a BC break.
*
* This simple script just adds the old constant names back, alongside the new
* ones.
*/
class CopyConstants
{
public function run(): void
{
$file = __DIR__ . '/../src/Dropbox.Sign/Model/SubFormFieldRuleAction.cs';
$contents = file_get_contents($file);

$constant_1 = " ChangeFieldVisibility = 1,";
$replace_1 = implode("\n", [
$constant_1,
' FieldVisibility = ChangeFieldVisibility,',
]);

$constant_2 = " ChangeGroupVisibility = 2";
$replace_2 = implode(",\n", [
$constant_2,
' GroupVisibility = ChangeGroupVisibility',
]);

$contents = str_replace(
$constant_1,
$replace_1,
$contents,
);

$contents = str_replace(
$constant_2,
$replace_2,
$contents,
);

file_put_contents($file, $contents);
}
}

$copier = new CopyConstants();
$copier->run();
2 changes: 1 addition & 1 deletion sdks/dotnet/bin/dotnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ docker run --rm \
-v "${ROOT_DIR}:${WORKING_DIR}" \
-w "${WORKING_DIR}" \
-u root:root \
mcr.microsoft.com/dotnet/sdk:6.0 "$@"
mcr.microsoft.com/dotnet/sdk:8.0 "$@"
5 changes: 3 additions & 2 deletions sdks/dotnet/openapi-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ additionalProperties:
packageCompany: Dropbox Sign API Team
packageCopyright: Dropbox 2024
packageDescription: Client library for using the Dropbox Sign API
packageVersion: 1.8-dev
packageVersion: 2.0-dev
packageTitle: Dropbox Sign .Net SDK
sortModelPropertiesByRequiredFlag: true
optionalEmitDefaultValues: true
targetFramework: net6.0
targetFramework: net8.0
library: restsharp
packageGuid: "{F8C8232D-7020-4603-8E04-18D060AE530B}"
legacyDiscriminatorBehavior: true
useCustomTemplateCode: true
Expand Down
7 changes: 5 additions & 2 deletions sdks/dotnet/run-build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# see https://github.com/OpenAPITools/openapi-generator/tree/v7.8.0/modules/openapi-generator/src/main/resources/csharp
# see https://github.com/OpenAPITools/openapi-generator/tree/v7.12.0/modules/openapi-generator/src/main/resources/csharp

set -e

Expand All @@ -18,7 +18,7 @@ rm -f "${DIR}/src/Dropbox.Sign/Model/"*.cs

docker run --rm \
-v "${DIR}/:/local" \
openapitools/openapi-generator-cli:v7.8.0 generate \
openapitools/openapi-generator-cli:v7.12.0 generate \
-i "/local/openapi-sdk.yaml" \
-c "/local/openapi-config.yaml" \
-t "/local/templates" \
Expand Down Expand Up @@ -46,6 +46,9 @@ docker run --rm \
-w "${WORKING_DIR}" \
perl bash ./bin/scan_for

printf "Adding old-style constant names ...\n"
bash "${DIR}/bin/php" ./bin/copy-constants.php

# avoid docker messing with permissions
if [[ -z "$GITHUB_ACTIONS" ]]; then
chmod 644 "${DIR}/README.md"
Expand Down
2 changes: 1 addition & 1 deletion sdks/dotnet/src/Dropbox.Sign.Test/Dropbox.Sign.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>Dropbox.Sign.Test</AssemblyName>
<RootNamespace>Dropbox.Sign.Test</RootNamespace>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<PackageId>Dropbox.Sign.Test</PackageId>
</PropertyGroup>
Expand Down
24 changes: 16 additions & 8 deletions sdks/dotnet/src/Dropbox.Sign/Client/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ internal object Deserialize(RestResponse response, Type type)
if (response.Headers != null)
{
var filePath = string.IsNullOrEmpty(_configuration.TempFolderPath)
? Path.GetTempPath()
? global::System.IO.Path.GetTempPath()
: _configuration.TempFolderPath;
var regex = new Regex(@"Content-Disposition=.*filename=['""]?([^'""\s]+)['""]?$");
foreach (var header in response.Headers)
Expand Down Expand Up @@ -334,7 +334,7 @@ private RestRequest NewRequest(
{
foreach (var value in headerParam.Value)
{
request.AddHeader(headerParam.Key, value);
request.AddOrUpdateHeader(headerParam.Key, value);
}
}
}
Expand Down Expand Up @@ -394,13 +394,21 @@ private RestRequest NewRequest(
var bytes = ClientUtils.ReadAsBytes(file);
var fileStream = file as FileStream;
if (fileStream != null)
request.AddFile(fileParam.Key, bytes, Path.GetFileName(fileStream.Name));
request.AddFile(fileParam.Key, bytes, global::System.IO.Path.GetFileName(fileStream.Name));
else
request.AddFile(fileParam.Key, bytes, "no_file_name_provided");
}
}
}

if (options.HeaderParameters != null)
{
if (options.HeaderParameters.TryGetValue("Content-Type", out var contentTypes) && contentTypes.Any(header => header.Contains("multipart/form-data")))
{
request.AlwaysMultipartFormData = true;
}
}

return request;
}

Expand Down Expand Up @@ -472,7 +480,7 @@ private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<Rest
var clientOptions = new RestClientOptions(baseUrl)
{
ClientCertificates = configuration.ClientCertificates,
MaxTimeout = configuration.Timeout,
Timeout = configuration.Timeout,
Proxy = configuration.Proxy,
UserAgent = configuration.UserAgent,
UseDefaultCredentials = configuration.UseDefaultCredentials,
Expand Down Expand Up @@ -557,11 +565,11 @@ private async Task<ApiResponse<T>> ExecClientAsync<T>(Func<RestClient, Task<Rest
}
}

private RestResponse<T> DeserializeRestResponseFromPolicy<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult)
private async Task<RestResponse<T>> DeserializeRestResponseFromPolicyAsync<T>(RestClient client, RestRequest request, PolicyResult<RestResponse> policyResult, CancellationToken cancellationToken = default)
{
if (policyResult.Outcome == OutcomeType.Successful)
{
return client.Deserialize<T>(policyResult.Result);
return await client.Deserialize<T>(policyResult.Result, cancellationToken);
}
else
{
Expand Down Expand Up @@ -594,7 +602,7 @@ private ApiResponse<T> Exec<T>(RestRequest request, RequestOptions options, IRea
{
var policy = RetryConfiguration.RetryPolicy;
var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
return Task.FromResult(DeserializeRestResponseFromPolicy<T>(client, request, policyResult));
return DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult);
}
else
{
Expand All @@ -618,7 +626,7 @@ private ApiResponse<T> Exec<T>(RestRequest request, RequestOptions options, IRea
{
var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
return DeserializeRestResponseFromPolicy<T>(client, request, policyResult);
return await DeserializeRestResponseFromPolicyAsync<T>(client, request, policyResult, cancellationToken);
}
else
{
Expand Down
6 changes: 6 additions & 0 deletions sdks/dotnet/src/Dropbox.Sign/Client/ClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public static string ParameterToString(object obj, IReadableConfiguration config
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is DateOnly dateOnly)
// Return a formatted date string - Can be customized with Configuration.DateTimeFormat
// Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o")
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15
return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is bool boolean)
return boolean ? "true" : "false";
if (obj is ICollection collection)
Expand Down
12 changes: 6 additions & 6 deletions sdks/dotnet/src/Dropbox.Sign/Client/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class Configuration : IReadableConfiguration
/// Version of the package.
/// </summary>
/// <value>Version of the package.</value>
public const string Version = "1.8-dev";
public const string Version = "2.0-dev";

/// <summary>
/// Identifier for ISO 8601 DateTime Format
Expand Down Expand Up @@ -120,7 +120,7 @@ public class Configuration : IReadableConfiguration
public Configuration()
{
Proxy = null;
UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.8-dev/csharp");
UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/2.0-dev/csharp");
BasePath = "https://api.hellosign.com/v3";
DefaultHeaders = new ConcurrentDictionary<string, string>();
ApiKey = new ConcurrentDictionary<string, string>();
Expand Down Expand Up @@ -163,7 +163,7 @@ public Configuration()
};

// Setting Timeout has side effects (forces ApiClient creation).
Timeout = 100000;
Timeout = TimeSpan.FromSeconds(100);
}

/// <summary>
Expand Down Expand Up @@ -247,9 +247,9 @@ public virtual IDictionary<string, string> DefaultHeader
public virtual IDictionary<string, string> DefaultHeaders { get; set; }

/// <summary>
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
/// Gets or sets the HTTP timeout of ApiClient. Defaults to 100 seconds.
/// </summary>
public virtual int Timeout { get; set; }
public virtual TimeSpan Timeout { get; set; }

/// <summary>
/// Gets or sets the proxy
Expand Down Expand Up @@ -567,7 +567,7 @@ public static string ToDebugReport()
report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: 3.0.0\n";
report += " SDK Package Version: 1.8-dev\n";
report += " SDK Package Version: 2.0-dev\n";

return report;
}
Expand Down
4 changes: 2 additions & 2 deletions sdks/dotnet/src/Dropbox.Sign/Client/IReadableConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public interface IReadableConfiguration
string TempFolderPath { get; }

/// <summary>
/// Gets the HTTP connection timeout (in milliseconds)
/// Gets the HTTP connection timeout.
/// </summary>
/// <value>HTTP connection timeout.</value>
int Timeout { get; }
TimeSpan Timeout { get; }

/// <summary>
/// Gets the proxy.
Expand Down
4 changes: 2 additions & 2 deletions sdks/dotnet/src/Dropbox.Sign/Dropbox.Sign.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo><!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 -->
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Dropbox.Sign</AssemblyName>
<PackageId>Dropbox.Sign</PackageId>
<OutputType>Library</OutputType>
Expand All @@ -12,7 +12,7 @@
<Description>Client library for using the Dropbox Sign API</Description>
<Copyright>Dropbox 2024</Copyright>
<RootNamespace>Dropbox.Sign</RootNamespace>
<Version>1.8-dev</Version>
<Version>2.0-dev</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Dropbox.Sign.xml</DocumentationFile>
<RepositoryUrl>https://github.com/hellosign/dropbox-sign-dotnet.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
10 changes: 6 additions & 4 deletions sdks/dotnet/src/Dropbox.Sign/Model/SubFormFieldRuleAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ public partial class SubFormFieldRuleAction : IEquatable<SubFormFieldRuleAction>
public enum TypeEnum
{
/// <summary>
/// Enum FieldVisibility for value: change-field-visibility
/// Enum ChangeFieldVisibility for value: change-field-visibility
/// </summary>
[EnumMember(Value = "change-field-visibility")]
FieldVisibility = 1,
ChangeFieldVisibility = 1,
FieldVisibility = ChangeFieldVisibility,

/// <summary>
/// Enum GroupVisibility for value: change-group-visibility
/// Enum ChangeGroupVisibility for value: change-group-visibility
/// </summary>
[EnumMember(Value = "change-group-visibility")]
GroupVisibility = 2
ChangeGroupVisibility = 2,
GroupVisibility = ChangeGroupVisibility
}


Expand Down
Loading