Skip to content

Commit 979abba

Browse files
committed
updated docs
1 parent 4379a23 commit 979abba

File tree

196 files changed

+2229
-40363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+2229
-40363
lines changed

docs/generators/csharp.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
4444
|packageName|C# package name (convention: Title.Case).| |Org.OpenAPITools|
4545
|packageTags|Tags to identify the package| |null|
4646
|packageVersion|C# package version.| |1.0.0|
47-
|releaseNote|Release note, default to 'Minor update'.| |Minor update|
4847
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
4948
|sourceFolder|source folder for generated code| |src|
5049
|targetFramework|The target .NET framework version. To target multiple frameworks, use `;` as the separator, e.g. `netstandard2.1;netcoreapp3.1`|<dl><dt>**netstandard1.3**</dt><dd>.NET Standard 1.3</dd><dt>**netstandard1.4**</dt><dd>.NET Standard 1.4</dd><dt>**netstandard1.5**</dt><dd>.NET Standard 1.5</dd><dt>**netstandard1.6**</dt><dd>.NET Standard 1.6</dd><dt>**netstandard2.0**</dt><dd>.NET Standard 2.0</dd><dt>**netstandard2.1**</dt><dd>.NET Standard 2.1</dd><dt>**net47**</dt><dd>.NET Framework 4.7</dd><dt>**net48**</dt><dd>.NET Framework 4.8</dd><dt>**net8.0**</dt><dd>.NET 8.0 (End of Support 10 November 2026)</dd><dt>**net9.0**</dt><dd>.NET 9.0 (End of Support 12 May 2026)</dd></dl>|net9.0|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ protected void addParentFromContainer(CodegenModel model, Schema schema) {
241241
public void processOpts() {
242242
super.processOpts();
243243

244+
additionalProperties.put("outputFolder", outputFolder);
245+
244246
if (StringUtils.isEmpty(System.getenv("CSHARP_POST_PROCESS_FILE"))) {
245247
LOGGER.info("Environment variable CSHARP_POST_PROCESS_FILE not defined so the C# code may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To define it, try `export CSHARP_POST_PROCESS_FILE=\"/usr/local/bin/uncrustify --no-backup\" && export UNCRUSTIFY_CONFIG=/path/to/uncrustify-rules.cfg` (Linux/Mac). Note: replace /path/to with the location of uncrustify-rules.cfg");
246248
LOGGER.info("NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).");

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ enum SortingMethod {
134134
private SortingMethod modelPropertySorting = SortingMethod.DEFAULT;
135135

136136
protected boolean caseInsensitiveResponseHeaders = Boolean.FALSE;
137-
protected String releaseNote = "Minor update";
138137
@Setter protected String licenseId;
139138
@Setter protected String packageTags;
140139
@Setter protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
@@ -213,10 +212,6 @@ public CSharpClientCodegen() {
213212
CodegenConstants.LICENSE_ID_DESC,
214213
this.licenseId);
215214

216-
addOption(CodegenConstants.RELEASE_NOTE,
217-
CodegenConstants.RELEASE_NOTE_DESC,
218-
this.releaseNote);
219-
220215
addOption(CodegenConstants.PACKAGE_TAGS,
221216
CodegenConstants.PACKAGE_TAGS_DESC,
222217
this.packageTags);
@@ -1293,11 +1288,6 @@ public void setCaseInsensitiveResponseHeaders(final Boolean caseInsensitiveRespo
12931288
this.caseInsensitiveResponseHeaders = caseInsensitiveResponseHeaders;
12941289
}
12951290

1296-
@Override
1297-
public void setReleaseNote(String releaseNote) {
1298-
this.releaseNote = releaseNote;
1299-
}
1300-
13011291
public boolean getUseOneOfDiscriminatorLookup() {
13021292
return this.useOneOfDiscriminatorLookup;
13031293
}

modules/openapi-generator/src/main/resources/csharp/api_doc.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ All URIs are relative to *{{{basePath}}}*
2121

2222
{{{.}}}{{/notes}}
2323

24+
{{^useGenericHost}}
2425
### Example
2526
```csharp
2627
using System.Collections.Generic;
@@ -122,6 +123,7 @@ catch (ApiException e)
122123
Debug.Print(e.StackTrace);
123124
}
124125
```
126+
{{/useGenericHost}}
125127

126128
### Parameters
127129
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
Lines changed: 62 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,51 @@
11
# Created with Openapi Generator
22

33
<a id="cli"></a>
4-
## Run the following powershell command to generate the library
5-
6-
```ps1
7-
$properties = @(
8-
'apiName={{apiName}}',
9-
'targetFramework={{targetFramework}}',
10-
'validatable={{validatable}}',
11-
'nullableReferenceTypes={{nullableReferenceTypes}}',
12-
'hideGenerationTimestamp={{hideGenerationTimestamp}}',
13-
'packageVersion={{packageVersion}}',
14-
'packageAuthors={{packageAuthors}}',
15-
'packageCompany={{packageCompany}}',
16-
'packageCopyright={{packageCopyright}}',
17-
'packageDescription={{packageDescription}}',{{#licenseId}}
18-
'licenseId={{.}}',{{/licenseId}}
19-
'packageName={{packageName}}',
20-
'packageTags={{packageTags}}',
21-
'packageTitle={{packageTitle}}'
22-
) -join ","
23-
24-
$global = @(
25-
'apiDocs={{generateApiDocs}}',
26-
'modelDocs={{generateModelDocs}}',
27-
'apiTests={{generateApiTests}}',
28-
'modelTests={{generateModelTests}}'
29-
) -join ","
30-
31-
java -jar "<path>/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate `
32-
-g csharp-netcore `
33-
-i <your-swagger-file>.yaml `
34-
-o <your-output-folder> `
35-
--library generichost `
36-
--additional-properties $properties `
37-
--global-property $global `
38-
--git-host "{{gitHost}}" `
39-
--git-repo-id "{{gitRepoId}}" `
40-
--git-user-id "{{gitUserId}}" `
41-
--release-note "{{releaseNote}}"
42-
# -t templates
4+
## Creating the library
5+
Create a config.yaml file similar to what is below, then run the following powershell command to generate the library `java -jar "<path>/openapi-generator/modules/openapi-generator-cli/target/openapi-generator-cli.jar" generate -c config.yaml`
6+
7+
```yaml
8+
generatorName: csharp
9+
inputSpec: {{inputSpec}}
10+
outputDir: {{outputFolder}}
11+
12+
# https://openapi-generator.tech/docs/generators/csharp
13+
additionalProperties:
14+
packageGuid: '{{packageGuid}}'
15+
16+
# https://openapi-generator.tech/docs/integrations/#github-integration
17+
# gitHost:
18+
# gitUserId:
19+
# gitRepoId:
20+
21+
# https://openapi-generator.tech/docs/globals
22+
# globalProperties:
23+
24+
# https://openapi-generator.tech/docs/customization/#inline-schema-naming
25+
# inlineSchemaOptions:
26+
27+
# https://openapi-generator.tech/docs/customization/#name-mapping
28+
# modelNameMappings:
29+
# nameMappings:
30+
31+
# https://openapi-generator.tech/docs/customization/#openapi-normalizer
32+
# openapiNormalizer:
33+
34+
# templateDir: https://openapi-generator.tech/docs/templating/#modifying-templates
35+
36+
# releaseNote:
4337
```
4438

4539
<a id="usage"></a>
4640
## Using the library in your project
4741

4842
```cs
49-
using System;
50-
using System.Threading.Tasks;
5143
using Microsoft.Extensions.Hosting;
5244
using Microsoft.Extensions.DependencyInjection;
5345
using {{packageName}}.Api;
5446
using {{packageName}}.Client;
5547
using {{packageName}}.Model;
48+
using Org.OpenAPITools.Extensions;
5649

5750
namespace YourProject
5851
{
@@ -66,8 +59,8 @@ namespace YourProject
6659
{{#-first}}
6760
{{#operation}}
6861
{{#-first}}
69-
{{operationId}}ApiResponse apiResponse = await api.{{operationId}}Async("todo");
70-
{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}} model = apiResponse.Ok();
62+
{{interfacePrefix}}{{operationId}}ApiResponse apiResponse = await api.{{operationId}}Async("todo");
63+
{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}}{{nrt?}} model = apiResponse.Ok();
7164
{{/-first}}
7265
{{/operation}}
7366
{{/-first}}
@@ -78,16 +71,17 @@ namespace YourProject
7871
}
7972

8073
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
81-
.Configure{{apiName}}((context, options) =>
74+
.Configure{{apiName}}((context, services, options) =>
8275
{
8376
{{#authMethods}}
8477
{{#-first}}
85-
// the type of token here depends on the api security specifications
86-
ApiKeyToken token = new("<your token>", ClientUtils.ApiKeyHeader.Authorization);
78+
// The type of token here depends on the api security specifications
79+
// Available token types are ApiKeyToken, BasicToken, BearerToken, HttpSigningToken, and OAuthToken.
80+
BearerToken token = new("<your token>");
8781
options.AddTokens(token);
8882

8983
// optionally choose the method the tokens will be provided with, default is RateLimitProvider
90-
options.UseProvider<RateLimitProvider<ApiKeyToken>, ApiKeyToken>();
84+
options.UseProvider<RateLimitProvider<BearerToken>, BearerToken>();
9185

9286
{{/-first}}
9387
{{/authMethods}}
@@ -96,11 +90,17 @@ namespace YourProject
9690
// your custom converters if any
9791
});
9892

99-
options.Add{{apiName}}HttpClients(builder: builder => builder
100-
.AddRetryPolicy(2)
101-
.AddTimeoutPolicy(TimeSpan.FromSeconds(5))
102-
.AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30))
103-
// add whatever middleware you prefer
93+
options.Add{{apiName}}HttpClients(client =>
94+
{
95+
// client configuration
96+
}, builder =>
97+
{
98+
builder
99+
.AddRetryPolicy(2)
100+
.AddTimeoutPolicy(TimeSpan.FromSeconds(5))
101+
.AddCircuitBreakerPolicy(10, TimeSpan.FromSeconds(30));
102+
// add whatever middleware you prefer
103+
}
104104
);
105105
});
106106
}
@@ -110,136 +110,28 @@ namespace YourProject
110110
## Questions
111111

112112
- What about HttpRequest failures and retries?
113-
If supportsRetry is enabled, you can configure Polly in the ConfigureClients method.
113+
Configure Polly in the IHttpClientBuilder
114114
- How are tokens used?
115115
Tokens are provided by a TokenProvider class. The default is RateLimitProvider which will perform client side rate limiting.
116116
Other providers can be used with the UseProvider method.
117117
- Does an HttpRequest throw an error when the server response is not Ok?
118-
It depends how you made the request. If the return type is ApiResponse<T> no error will be thrown, though the Content property will be null.
118+
It depends how you made the request. If the return type is ApiResponse<T> no error will be thrown, though the Content property will be null.
119119
StatusCode and ReasonPhrase will contain information about the error.
120120
If the return type is T, then it will throw. If the return type is TOrDefault, it will return null.
121121
- How do I validate requests and process responses?
122-
Use the provided On and After methods in the Api class from the namespace {{packageName}}.Rest.DefaultApi.
123-
Or provide your own class by using the generic Configure{{apiName}} method.
124-
125-
<a id="dependencies"></a>
126-
## Dependencies
127-
128-
- [Microsoft.Extensions.Hosting](https://www.nuget.org/packages/Microsoft.Extensions.Hosting/) - 5.0.0 or later
129-
- [Microsoft.Extensions.Http](https://www.nuget.org/packages/Microsoft.Extensions.Http/) - 5.0.0 or later{{#supportsRetry}}
130-
- [Microsoft.Extensions.Http.Polly](https://www.nuget.org/packages/Microsoft.Extensions.Http.Polly/) - 5.0.1 or later{{/supportsRetry}}{{#useCompareNetObjects}}
131-
- [CompareNETObjects](https://www.nuget.org/packages/CompareNETObjects) - 4.61.0 or later{{/useCompareNetObjects}}{{#validatable}}
132-
- [System.ComponentModel.Annotations](https://www.nuget.org/packages/System.ComponentModel.Annotations) - 4.7.0 or later{{/validatable}}{{#apiDocs}}
133-
134-
<a id="documentation-for-api-endpoints"></a>
135-
## Documentation for API Endpoints
136-
137-
All URIs are relative to *{{{basePath}}}*
138-
139-
Class | Method | HTTP request | Description
140-
------------ | ------------- | ------------- | -------------{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
141-
*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{{summary}}}{{/summary}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}{{/apiDocs}}{{#modelDocs}}
142-
143-
<a id="documentation-for-models"></a>
144-
## Documentation for Models
145-
146-
{{#modelPackage}}{{#models}}{{#model}} - [{{{modelPackage}}}.{{{classname}}}]({{modelDocPath}}{{{classname}}}.md){{/model}}{{/models}}{{/modelPackage}}
147-
{{^modelPackage}}No model defined in this package{{/modelPackage}}{{/modelDocs}}
148-
149-
<a id="documentation-for-authorization"></a>
150-
## Documentation for Authorization
151-
152-
{{^authMethods}}Endpoints do not require authorization.{{/authMethods}}
153-
{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}}
154-
{{#authMethods}}
155-
<a id="{{name}}"></a>
156-
### {{name}}
157-
158-
{{#isApiKey}}- **Type**: API key
159-
- **API key parameter name**: {{keyParamName}}
160-
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
161-
{{/isApiKey}}
162-
{{#isBasicBasic}}
163-
- **Type**: HTTP basic authentication
164-
{{/isBasicBasic}}
165-
{{#isBasicBearer}}
166-
- **Type**: Bearer Authentication
167-
{{/isBasicBearer}}
168-
{{#isHttpSignature}}
169-
- **Type**: HTTP signature authentication
170-
{{/isHttpSignature}}
171-
{{#isOAuth}}
172-
- **Type**: OAuth
173-
- **Flow**: {{flow}}
174-
- **Authorization URL**: {{authorizationUrl}}
175-
- **Scopes**: {{^scopes}}N/A{{/scopes}}{{#scopes}}
176-
- {{scope}}: {{description}}{{/scopes}}
177-
{{/isOAuth}}
178-
179-
{{/authMethods}}
122+
Use the provided On and After partial methods in the api classes.
123+
124+
## Api Information
125+
- appName: {{appName}}
126+
- appVersion: {{appVersion}}
127+
- appDescription: {{appDescription}}
180128

181129
## Build
130+
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
131+
182132
- SDK version: {{packageVersion}}
183133
{{^hideGenerationTimestamp}}
184134
- Build date: {{generatedDate}}
185135
{{/hideGenerationTimestamp}}
186136
- Generator version: {{generatorVersion}}
187137
- Build package: {{generatorClass}}
188-
189-
## Api Information
190-
- appName: {{appName}}
191-
- appVersion: {{appVersion}}
192-
- appDescription: {{appDescription}}
193-
194-
## [OpenApi Global properties](https://openapi-generator.tech/docs/globals)
195-
- generateAliasAsModel: {{generateAliasAsModel}}
196-
- supportingFiles: {{supportingFiles}}
197-
- models: omitted for brevity
198-
- apis: omitted for brevity
199-
- apiDocs: {{generateApiDocs}}
200-
- modelDocs: {{generateModelDocs}}
201-
- apiTests: {{generateApiTests}}
202-
- modelTests: {{generateModelTests}}
203-
204-
## [OpenApi Generator Parameters](https://openapi-generator.tech/docs/generators/csharp-netcore)
205-
- allowUnicodeIdentifiers: {{allowUnicodeIdentifiers}}
206-
- apiName: {{apiName}}
207-
- caseInsensitiveResponseHeaders: {{caseInsensitiveResponseHeaders}}
208-
- conditionalSerialization: {{conditionalSerialization}}
209-
- disallowAdditionalPropertiesIfNotPresent: {{disallowAdditionalPropertiesIfNotPresent}}
210-
- gitHost: {{gitHost}}
211-
- gitRepoId: {{gitRepoId}}
212-
- gitUserId: {{gitUserId}}
213-
- hideGenerationTimestamp: {{hideGenerationTimestamp}}
214-
- interfacePrefix: {{interfacePrefix}}
215-
- library: {{library}}
216-
- licenseId: {{licenseId}}
217-
- modelPropertyNaming: {{modelPropertyNaming}}
218-
- netCoreProjectFile: {{netCoreProjectFile}}
219-
- nonPublicApi: {{nonPublicApi}}
220-
- nullableReferenceTypes: {{nullableReferenceTypes}}
221-
- optionalAssemblyInfo: {{optionalAssemblyInfo}}
222-
- optionalEmitDefaultValues: {{optionalEmitDefaultValues}}
223-
- optionalMethodArgument: {{optionalMethodArgument}}
224-
- optionalProjectFile: {{optionalProjectFile}}
225-
- packageAuthors: {{packageAuthors}}
226-
- packageCompany: {{packageCompany}}
227-
- packageCopyright: {{packageCopyright}}
228-
- packageDescription: {{packageDescription}}
229-
- packageGuid: {{packageGuid}}
230-
- packageName: {{packageName}}
231-
- packageTags: {{packageTags}}
232-
- packageTitle: {{packageTitle}}
233-
- packageVersion: {{packageVersion}}
234-
- releaseNote: {{releaseNote}}
235-
- returnICollection: {{returnICollection}}
236-
- sortParamsByRequiredFlag: {{sortParamsByRequiredFlag}}
237-
- sourceFolder: {{sourceFolder}}
238-
- targetFramework: {{targetFramework}}
239-
- useCollection: {{useCollection}}
240-
- useDateTimeOffset: {{useDateTimeOffset}}
241-
- useOneOfDiscriminatorLookup: {{useOneOfDiscriminatorLookup}}
242-
- validatable: {{validatable}}{{#infoUrl}}
243-
For more information, please visit [{{{.}}}]({{{.}}}){{/infoUrl}}
244-
245-
This C# SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Created with Openapi Generator
2+
See the project's [REAMDE](src/{{packageName}}/README.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# Created with Openapi Generator
2+
See the project's [REAMDE](src/Org.OpenAPITools/README.md)

0 commit comments

Comments
 (0)