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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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: 2.1.0
- SDK version: 2.2.0
- Generator version: 7.12.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen

Expand Down Expand Up @@ -214,6 +214,7 @@ Class | Method | HTTP request | Description
- [Model.AccountGetResponse](docs/AccountGetResponse.md)
- [Model.AccountResponse](docs/AccountResponse.md)
- [Model.AccountResponseQuotas](docs/AccountResponseQuotas.md)
- [Model.AccountResponseSettings](docs/AccountResponseSettings.md)
- [Model.AccountResponseUsage](docs/AccountResponseUsage.md)
- [Model.AccountUpdateRequest](docs/AccountUpdateRequest.md)
- [Model.AccountVerifyRequest](docs/AccountVerifyRequest.md)
Expand Down Expand Up @@ -357,7 +358,6 @@ Class | Method | HTTP request | Description
- [Model.TemplateCreateRequest](docs/TemplateCreateRequest.md)
- [Model.TemplateCreateResponse](docs/TemplateCreateResponse.md)
- [Model.TemplateCreateResponseTemplate](docs/TemplateCreateResponseTemplate.md)
- [Model.TemplateEditResponse](docs/TemplateEditResponse.md)
- [Model.TemplateGetResponse](docs/TemplateGetResponse.md)
- [Model.TemplateListResponse](docs/TemplateListResponse.md)
- [Model.TemplateRemoveUserRequest](docs/TemplateRemoveUserRequest.md)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.2.0
180 changes: 159 additions & 21 deletions bin/copy-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,26 @@
});

/**
* 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.
* Post-generation patch for SubFormFieldRuleAction.cs.
*
* 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.
* 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 broken: "change-field-visibility" generated a constant named
* "TYPE_FIELD_VISIBILITY", dropping the "change" part. The fix generates
* the correct name, "TYPE_CHANGE_FIELD_VISIBILITY", but also removes the
* previous (incorrect) names, which is a BC break.
*
* This simple script just adds the old constant names back, alongside the new
* ones.
* To preserve source compatibility this script adds the old names back
* as aliases (FieldVisibility = ChangeFieldVisibility, etc.). The aliases
* share a numeric value with their canonical counterparts, which breaks
* StringEnumConverter: Enum.GetName is not guaranteed to pick the
* canonical name for ties, and Newtonsoft rejects duplicate
* [EnumMember] values on the same enum. To make the aliases serialize
* to the correct OpenAPI wire values under all circumstances, this
* script also:
* - swaps StringEnumConverter for a dedicated TypeEnumJsonConverter
* that maps by underlying numeric value, and
* - injects that nested converter class into SubFormFieldRuleAction.
*/
class CopyConstants
{
Expand All @@ -32,6 +41,57 @@ public function run(): void
$file = __DIR__ . '/../src/Dropbox.Sign/Model/SubFormFieldRuleAction.cs';
$contents = file_get_contents($file);

$contents = $this->addAliases($contents);
$contents = $this->swapConverter($contents);
$contents = $this->injectConverterClass($contents);

file_put_contents($file, $contents);

$this->stopEmittingDefaultIntValues(__DIR__ . '/../src/Dropbox.Sign/Model');
}

/**
* For optional non-nullable int properties on request-side models
* openapi-generator emits
* [DataMember(Name = "foo", EmitDefaultValue = true)]
* public int Foo { get; set; }
* which forces `"foo": 0` onto the wire whenever the caller never
* set a value (C# default for int is 0). For fields like font_size
* the server rejects the default with a 400 ("'font_size' must be
* between 7 and 49"), and more generally any optional int whose
* server-side default is not 0 is misrepresented.
*
* Scope:
* - Only request-side models are patched. Response models keep
* EmitDefaultValue = true so that round-trip serialization
* preserves explicit zero values that the server sent (tests
* under Dropbox.Sign.Test.Api rely on this fidelity). Response
* models are identified by the "Response" substring in the
* file name, which is the convention for all generated
* response types in this SDK.
* - Required int properties are left alone: openapi-generator
* inserts `IsRequired = true,` between the Name and
* EmitDefaultValue tokens, which this regex does not match.
*/
private function stopEmittingDefaultIntValues(string $modelDir): void
{
$pattern = '/(\[DataMember\(Name = "[^"]+", EmitDefaultValue = )true(\)\]\s*\r?\n\s+public int [A-Za-z_][A-Za-z0-9_]* \{ get; set; \})/';

foreach (glob($modelDir . '/*.cs') as $path) {
if (strpos(basename($path), 'Response') !== false) {
continue;
}

$contents = file_get_contents($path);
$patched = preg_replace($pattern, '$1false$2', $contents);
if ($patched !== null && $patched !== $contents) {
file_put_contents($path, $patched);
}
}
}

private function addAliases(string $contents): string
{
$constant_1 = " ChangeFieldVisibility = 1,";
$replace_1 = implode("\n", [
$constant_1,
Expand All @@ -44,21 +104,99 @@ public function run(): void
' GroupVisibility = ChangeGroupVisibility',
]);

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

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

file_put_contents($file, $contents);
private function swapConverter(string $contents): string
{
$needle = " [JsonConverter(typeof(StringEnumConverter))]\n"
. " public enum TypeEnum";

$replacement = <<<'CS'
// A dedicated converter is used instead of StringEnumConverter
// because this enum intentionally carries alias members
// (FieldVisibility, GroupVisibility) that share a numeric value
// with their canonical counterparts. StringEnumConverter goes
// through Enum.GetName, which is not guaranteed to pick the
// canonical name when multiple members share a value, and
// Newtonsoft rejects duplicate [EnumMember] values on the same
// enum. Mapping by numeric value here is unambiguous: both the
// canonical name and its alias produce the same wire string.
[JsonConverter(typeof(TypeEnumJsonConverter))]
public enum TypeEnum
CS;

return str_replace($needle, $replacement, $contents);
}

private function injectConverterClass(string $contents): string
{
// Inject the nested converter immediately after the enum's
// closing brace. Anchor on the enum's tail, which is unique in
// the file.
$needle = " GroupVisibility = ChangeGroupVisibility\n"
. " }\n";

$converter = <<<'CS'
GroupVisibility = ChangeGroupVisibility
}

/// <summary>
/// Serializes SubFormFieldRuleAction.TypeEnum to and from the
/// OpenAPI wire values (change-field-visibility,
/// change-group-visibility). The switch is driven by the
/// underlying numeric value so that legacy alias members
/// (FieldVisibility, GroupVisibility) serialize identically to
/// their canonical counterparts.
/// </summary>
public class TypeEnumJsonConverter : JsonConverter<TypeEnum>
{
public override void WriteJson(JsonWriter writer, TypeEnum value, JsonSerializer serializer)
{
switch (value)
{
case TypeEnum.ChangeFieldVisibility:
writer.WriteValue("change-field-visibility");
return;
case TypeEnum.ChangeGroupVisibility:
writer.WriteValue("change-group-visibility");
return;
default:
throw new JsonSerializationException(
$"Unknown value for SubFormFieldRuleAction.TypeEnum: {(int)value}");
}
}

public override TypeEnum ReadJson(JsonReader reader, Type objectType, TypeEnum existingValue, bool hasExistingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null)
{
throw new JsonSerializationException(
"Cannot deserialize null into SubFormFieldRuleAction.TypeEnum");
}

var raw = reader.Value?.ToString();
switch (raw)
{
case "change-field-visibility":
return TypeEnum.ChangeFieldVisibility;
case "change-group-visibility":
return TypeEnum.ChangeGroupVisibility;
default:
throw new JsonSerializationException(
$"Unknown wire value for SubFormFieldRuleAction.TypeEnum: {raw}");
}
}
}

CS;

return str_replace($needle, $converter, $contents);
}
}

$copier = new CopyConstants();
$copier->run();
$copier->run();
2 changes: 1 addition & 1 deletion docs/AccountResponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**AccountId** | **string** | The ID of the Account | [optional] **EmailAddress** | **string** | The email address associated with the Account. | [optional] **IsLocked** | **bool** | Returns `true` if the user has been locked out of their account by a team admin. | [optional] **IsPaidHs** | **bool** | Returns `true` if the user has a paid Dropbox Sign account. | [optional] **IsPaidHf** | **bool** | Returns `true` if the user has a paid HelloFax account. | [optional] **Quotas** | [**AccountResponseQuotas**](AccountResponseQuotas.md) | | [optional] **CallbackUrl** | **string** | The URL that Dropbox Sign events will `POST` to. | [optional] **RoleCode** | **string** | The membership role for the team. | [optional] **TeamId** | **string** | The id of the team account belongs to. | [optional] **Locale** | **string** | The locale used in this Account. Check out the list of [supported locales](/api/reference/constants/#supported-locales) to learn more about the possible values. | [optional] **Usage** | [**AccountResponseUsage**](AccountResponseUsage.md) | | [optional]
**AccountId** | **string** | The ID of the Account | [optional] **EmailAddress** | **string** | The email address associated with the Account. | [optional] **IsLocked** | **bool** | Returns `true` if the user has been locked out of their account by a team admin. | [optional] **IsPaidHs** | **bool** | Returns `true` if the user has a paid Dropbox Sign account. | [optional] **IsPaidHf** | **bool** | Returns `true` if the user has a paid HelloFax account. | [optional] **Quotas** | [**AccountResponseQuotas**](AccountResponseQuotas.md) | | [optional] **CallbackUrl** | **string** | The URL that Dropbox Sign events will `POST` to. | [optional] **RoleCode** | **string** | The membership role for the team. | [optional] **TeamId** | **string** | The id of the team account belongs to. | [optional] **Locale** | **string** | The locale used in this Account. Check out the list of [supported locales](/api/reference/constants/#supported-locales) to learn more about the possible values. | [optional] **Usage** | [**AccountResponseUsage**](AccountResponseUsage.md) | | [optional] **Settings** | [**AccountResponseSettings**](AccountResponseSettings.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

11 changes: 11 additions & 0 deletions docs/AccountResponseSettings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dropbox.Sign.Model.AccountResponseSettings
Subset of configured settings

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**SignerAccessCodes** | **bool** | Returns `true` if _Custom access codes_ is enabled in Admin Console. [Read more](https://developers.hellosign.com/docs/sms-tools/walkthrough). | [optional] **SmsDelivery** | **bool** | Returns `true` if _Text message_ is enabled in Admin Console. [Read more](https://developers.hellosign.com/docs/sms-tools/walkthrough). | [optional] **SmsAuthentication** | **bool** | Returns `true` if _Signer authentication_ is enabled in Admin Console. [Read more](https://developers.hellosign.com/docs/sms-tools/walkthrough). | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

2 changes: 1 addition & 1 deletion docs/OAuthTokenRefreshRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**GrantType** | **string** | When refreshing an existing token use `refresh_token`. | [default to "refresh_token"]**RefreshToken** | **string** | The token provided when you got the expired access token. | **ClientId** | **string** | The client ID for your API app. Mandatory from August 1st, 2025. Until then, required if the &quot;Client Credentials Required&quot; setting is enabled for token refresh; optional if disabled. | [optional] **ClientSecret** | **string** | The client secret for your API app. Mandatory from August 1st, 2025. Until then, required if the &quot;Client Credentials Required&quot; setting is enabled for token refresh; optional if disabled. | [optional]
**GrantType** | **string** | When refreshing an existing token use `refresh_token`. | [default to "refresh_token"]**RefreshToken** | **string** | The token provided when you got the expired access token. | **ClientId** | **string** | The client ID for your API app. Required for new API apps. To enhance security, we recommend making it required for existing apps in your app settings. | [optional] **ClientSecret** | **string** | The client secret for your API app. Required for new API apps. To enhance security, we recommend making it required for existing apps in your app settings. | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

12 changes: 8 additions & 4 deletions docs/SignatureRequestApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ public class SignatureRequestCreateEmbeddedExample
draw: true,
phone: false,
type: true,
upload: true
upload: true,
force_advanced_signature_details: false
);

var signers1 = new SubSignatureRequestSigner(
Expand Down Expand Up @@ -647,7 +648,8 @@ public class SignatureRequestCreateEmbeddedWithTemplateExample
draw: true,
phone: false,
type: true,
upload: true
upload: true,
force_advanced_signature_details: false
);

var signers1 = new SubSignatureRequestTemplateSigner(
Expand Down Expand Up @@ -2137,7 +2139,8 @@ public class SignatureRequestSendExample
draw: true,
phone: false,
type: true,
upload: true
upload: true,
force_advanced_signature_details: false,
);

var signers1 = new SubSignatureRequestSigner(
Expand Down Expand Up @@ -2286,7 +2289,8 @@ public class SignatureRequestSendWithTemplateExample
draw: true,
phone: false,
type: true,
upload: true
upload: true,
force_advanced_signature_details: false,
);

var signers1 = new SubSignatureRequestTemplateSigner(
Expand Down
Loading
Loading