Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions docs/generators/csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|useDateTimeForDate|Use DateTime to model date properties even if DateOnly supported. (.net 6.0+ only)| |false|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useIntForTimeout|Use int for Timeout (fall back to v7.9.0 templates). This option (for restsharp only) will be deprecated so please migrated to TimeSpan instead.| |false|
|throwOnAnyError|Configure RestSharp to rethrow deserialization and transport errors instead of swallowing them into RestResponse.ErrorException (which the default ToApiResponse<T> discards as null Data). Recommended for production use to surface bugs that would otherwise be invisible. (restsharp only)| |false|
|useOneOfDiscriminatorLookup|Use the discriminator's mapping in oneOf to speed up the model lookup. IMPORTANT: Validation (e.g. one and only one match in oneOf's schemas) will be skipped.| |false|
|useSourceGeneration|Use source generation where available (only `generichost` library supports this option).| |false|
|useVirtualForHooks|Generate code that exposes public virtual hooks on ApiClient to customize low-level HTTP requests (only `restsharp`. `httpclient` libraries support this option).| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
protected boolean supportsFileParameters = Boolean.TRUE;
protected boolean supportsDateOnly = Boolean.FALSE;
protected boolean useIntForTimeout = Boolean.FALSE;
protected boolean throwOnAnyError = Boolean.FALSE;

@Setter protected boolean validatable = Boolean.TRUE;
@Setter protected boolean equatable = Boolean.FALSE;
Expand All @@ -132,6 +133,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
private static final String OPERATION_PARAMETER_SORTING_KEY = "operationParameterSorting";
private static final String MODEL_PROPERTY_SORTING_KEY = "modelPropertySorting";
private static final String USE_INT_FOR_TIMEOUT = "useIntForTimeout";
private static final String THROW_ON_ANY_ERROR = "throwOnAnyError";

enum SortingMethod {
DEFAULT,
Expand Down Expand Up @@ -249,6 +251,10 @@ public CSharpClientCodegen() {
"Use int for Timeout (fall back to v7.9.0 templates). This option (for restsharp only) will be deprecated so please migrated to TimeSpan instead.",
String.valueOf(this.useIntForTimeout));

addSwitch(CSharpClientCodegen.THROW_ON_ANY_ERROR,
"Configure RestSharp to rethrow deserialization and transport errors instead of swallowing them into RestResponse.ErrorException (which the default ToApiResponse<T> discards as null Data). Recommended for production use to surface bugs that would otherwise be invisible. (restsharp only)",
this.throwOnAnyError);

CliOption framework = new CliOption(
CodegenConstants.DOTNET_FRAMEWORK,
CodegenConstants.DOTNET_FRAMEWORK_DESC
Expand Down Expand Up @@ -871,6 +877,7 @@ public void processOpts() {
syncBooleanProperty(additionalProperties, "useSourceGeneration", this::setUseSourceGeneration, this.useSourceGeneration);
syncBooleanProperty(additionalProperties, "supportsDateOnly", this::setSupportsDateOnly, this.supportsDateOnly);
syncBooleanProperty(additionalProperties, "useIntForTimeout", this::setUseIntForTimeout, this.useIntForTimeout);
syncBooleanProperty(additionalProperties, "throwOnAnyError", this::setThrowOnAnyError, this.throwOnAnyError);

final String testPackageName = testPackageName();
String packageFolder = sourceFolder + File.separator + packageName;
Expand Down Expand Up @@ -1244,6 +1251,10 @@ public void setUseIntForTimeout(Boolean useIntForTimeout) {
this.useIntForTimeout = useIntForTimeout;
}

public void setThrowOnAnyError(Boolean throwOnAnyError) {
this.throwOnAnyError = throwOnAnyError;
}

public void setSupportsRetry(Boolean supportsRetry) {
this.supportsRetry = supportsRetry;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ namespace {{packageName}}.Client
Proxy = configuration.Proxy,
UserAgent = configuration.UserAgent,
UseDefaultCredentials = configuration.UseDefaultCredentials,
RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback
RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback{{#throwOnAnyError}},
ThrowOnAnyError = true{{/throwOnAnyError}}
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
};
setOptions(clientOptions);

Expand Down
Loading