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
1 change: 1 addition & 0 deletions .github/workflows/samples-dotnet8-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
matrix:
sample:
- samples/client/petstore/csharp/restsharp/net8/ParameterMappings/
- samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks/
steps:
- uses: actions/checkout@v4
- uses: actions/[email protected]
Expand Down
10 changes: 10 additions & 0 deletions bin/configs/csharp-restsharp-useVirtualForHooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# for .net standard
generatorName: csharp
library: restsharp
outputDir: samples/client/petstore/csharp/restsharp/net8/useVirtualForHooks
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-addpet-only.yaml
templateDir: modules/openapi-generator/src/main/resources/csharp
additionalProperties:
packageGuid: '{D0A67E81-4061-48EB-B4B8-C73BDF8B2D95}'
targetFramework: net8.0
useVirtualForHooks: true
1 change: 1 addition & 0 deletions docs/generators/csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|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|
|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|
|validatable|Generates self-validatable models.| |true|
|zeroBasedEnums|Enumerations with string values will start from 0 when true, 1 when false. If not set, enumerations with string values will start from 0 if the first value is 'unknown', case insensitive.| |null|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public static enum ENUM_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case,
public static final String SUPPORTS_ASYNC_DESC = "Generate code that supports async operations.";

public static final String USE_VIRTUAL_FOR_HOOKS = "useVirtualForHooks";
public static final String USE_VIRTUAL_FOR_HOOKS_DESC = "Generate code that exposes public virtual hooks on ApiClient to customize low-level HTTP requests.";
public static final String USE_VIRTUAL_FOR_HOOKS_DESC = "Generate code that exposes public virtual hooks on ApiClient to customize low-level HTTP requests (only `restsharp`. `httpclient` libraries support this option).";

public static final String EXCLUDE_TESTS = "excludeTests";
public static final String EXCLUDE_TESTS_DESC = "Specifies that no tests are to be generated.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ public CSharpClientCodegen() {
"Use source generation where available (only `generichost` library supports this option).",
this.getUseSourceGeneration());

addSwitch(CodegenConstants.USE_VIRTUAL_FOR_HOOKS,
CodegenConstants.USE_VIRTUAL_FOR_HOOKS_DESC,
this.useVirtualForHooks);

supportedLibraries.put(GENERICHOST, "HttpClient, Generic Host integration, and System.Text.Json (https://docs.microsoft.com/en-us/dotnet/core/extensions/generic-host)");
supportedLibraries.put(HTTPCLIENT, "HttpClient and Newtonsoft (https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient) "
+ "(Experimental. Subject to breaking changes without notice.)");
Expand Down
Loading
Loading