jfcote87 / esign

DocuSign REST API
BSD 3-Clause "New" or "Revised" License
23 stars 27 forks source link

Bug preventing signer from editting text tab with default value #15

Open dcemmerson opened 3 years ago

dcemmerson commented 3 years ago

Using v2.1 of the esign library, the "omitempty" portion of Locked DSBool `json:"locked,omitempty"` at https://github.com/jfcote87/esign/blob/5064b2fe6847296edf1df5b4dc4cb68150775257/v2.1/model/model.go#L13620 is problematic and results in undesired behavior.

Per the docs https://pkg.go.dev/encoding/json, "The 'omitempty' option specifies that the field should be omitted from encoding if the field has an empty value, defined as false, ..."

Using v2.1 of the library, the problem arises when setting TabValue.Value in model.Text when creating an editable text tab (model.Text) for a signer and setting a non-empty string value (TabValue.Value).

I cannot find this explicitly stated in DocuSign docs, but based off the API behavior, when the json values for a request to Docusign contains a non-empty string for model.Text.TabValue.Value and model.Text.Locked is not set in the request, model.Text.Locked defaults to true in DocuSign's end of the API. Essentially, the 'omitempty' part of Locked DSBool `json:"locked,omitempty"` prevents one from setting a non-empty string value for model.Text.TabValue.Value and model.Text.Locked = false to allow a signer to edit a text tab (since the json form of model.Text.Locked = false is excluded from the request due to "omitempty"). Removing "omitempty" from Locked DSBooljson:"locked,omitempty"`` resolves the problem.

From Go docs https://pkg.go.dev/encoding/json:

Screen Shot 2021-09-23 at 4 08 04 PM