From 08a11c1d75bd84cebf0c5e8b03c5d897d3ef082b Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 1 Jun 2017 07:53:35 +0800 Subject: [PATCH] fix c# net35 issue, add xml doc to new C# class (#5756) --- .../languages/CSharpClientCodegen.java | 1 + .../resources/csharp/Configuration.mustache | 14 +++-- .../csharp/IReadableConfiguration.mustache | 63 ++++++++++++++++++- .../src/main/resources/csharp/api.mustache | 2 +- .../csharp/SwaggerClient/docs/PetApi.md | 4 +- .../csharp/SwaggerClient/docs/StoreApi.md | 4 +- .../src/IO.Swagger/Client/Configuration.cs | 4 +- .../Client/IReadableConfiguration.cs | 63 ++++++++++++++++++- .../SwaggerClientNetStandard/docs/PetApi.md | 4 +- .../SwaggerClientNetStandard/docs/StoreApi.md | 4 +- .../src/IO.Swagger/Client/Configuration.cs | 4 +- .../Client/IReadableConfiguration.cs | 63 ++++++++++++++++++- .../docs/PetApi.md | 4 +- .../docs/StoreApi.md | 4 +- .../src/IO.Swagger/Client/Configuration.cs | 4 +- .../Client/IReadableConfiguration.cs | 63 ++++++++++++++++++- 16 files changed, 272 insertions(+), 33 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index eecc93de1d3..b34cbe12766 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -212,6 +212,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { additionalProperties.remove("supportsAsync"); } additionalProperties.put("validatable", false); + additionalProperties.put("net35", true); } else if (NETSTANDARD.equals(this.targetFramework)){ setTargetFrameworkNuget("netstandard1.3"); setSupportsAsync(Boolean.TRUE); diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index e7aafa2c327..9e4cf95b55d 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -1,7 +1,9 @@ {{>partial_header}} using System; using System.Reflection; +{{^net35}} using System.Collections.Concurrent; +{{/net35}} using System.Collections.Generic; using System.IO; using System.Linq; @@ -107,9 +109,9 @@ namespace {{packageName}}.Client { UserAgent = "{{#httpUserAgent}}{{.}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{packageVersion}}/csharp{{/httpUserAgent}}"; BasePath = "{{{basePath}}}"; - DefaultHeader = new ConcurrentDictionary(); - ApiKey = new ConcurrentDictionary(); - ApiKeyPrefix = new ConcurrentDictionary(); + DefaultHeader = new {{^net35}}Concurrent{{/net35}}Dictionary(); + ApiKey = new {{^net35}}Concurrent{{/net35}}Dictionary(); + ApiKeyPrefix = new {{^net35}}Concurrent{{/net35}}Dictionary(); // Setting Timeout has side effects (forces ApiClient creation). Timeout = 100000; @@ -124,7 +126,7 @@ namespace {{packageName}}.Client IDictionary apiKeyPrefix, string basePath = "{{{basePath}}}") : this() { - if (string.IsNullOrWhiteSpace(basePath)) + if (string.{{^net35}}IsNullOrWhiteSpace{{/net35}}{{#net35}}IsNullOrEmpty{{/net35}}(basePath)) throw new ArgumentException("The provided basePath is invalid.", "basePath"); if (defaultHeader == null) throw new ArgumentNullException("defaultHeader"); @@ -264,11 +266,11 @@ namespace {{packageName}}.Client public virtual string Password { get; set; } /// - /// Gets or sets the access token for OAuth2 authentication. + /// Gets the API key with prefix. /// /// API key identifier (authentication scheme). /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) + public string GetApiKeyWithPrefix(string apiKeyIdentifier) { var apiKeyValue = ""; ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); diff --git a/modules/swagger-codegen/src/main/resources/csharp/IReadableConfiguration.mustache b/modules/swagger-codegen/src/main/resources/csharp/IReadableConfiguration.mustache index ae2692f5d4a..ce165e0c81d 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/IReadableConfiguration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/IReadableConfiguration.mustache @@ -9,18 +9,77 @@ namespace {{packageName}}.Client /// public interface IReadableConfiguration { + /// + /// Gets the access token. + /// + /// Access token. string AccessToken { get; } + + /// + /// Gets the API key. + /// + /// API key. IDictionary ApiKey { get; } + + /// + /// Gets the API key prefix. + /// + /// API key prefix. IDictionary ApiKeyPrefix { get; } + + /// + /// Gets the base path. + /// + /// Base path. string BasePath { get; } + + /// + /// Gets the date time format. + /// + /// Date time foramt. string DateTimeFormat { get; } + + /// + /// Gets the default header. + /// + /// Default header. IDictionary DefaultHeader { get; } - string Password { get; } + + /// + /// Gets the temp folder path. + /// + /// Temp folder path. string TempFolderPath { get; } + + /// + /// Gets the HTTP connection timeout (in milliseconds) + /// + /// HTTP connection timeout. int Timeout { get; } + + /// + /// Gets the user agent. + /// + /// User agent. string UserAgent { get; } + + /// + /// Gets the username. + /// + /// Username. string Username { get; } + /// + /// Gets the password. + /// + /// Password. + string Password { get; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. string GetApiKeyWithPrefix(string apiKeyIdentifier); } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 4ea57bca477..9a9f99f26b8 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -157,7 +157,7 @@ namespace {{packageName}}.{{apiPackage}} [Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")] public IDictionary DefaultHeader() { - return new ReadOnlyDictionary(this.Configuration.DefaultHeader); + return new {{^net35}}ReadOnly{{/net35}}Dictionary(this.Configuration.DefaultHeader); } /// diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md index 148d49b8b88..6b6450a12ab 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md @@ -293,9 +293,9 @@ namespace Example public void main() { // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new PetApi(); var petId = 789; // long? | ID of pet to return diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md index 1509a03158f..113032c257b 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md @@ -93,9 +93,9 @@ namespace Example public void main() { // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/Configuration.cs index 1e1e12c3522..531d240482a 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/Configuration.cs @@ -272,11 +272,11 @@ namespace IO.Swagger.Client public virtual string Password { get; set; } /// - /// Gets or sets the access token for OAuth2 authentication. + /// Gets the API key with prefix. /// /// API key identifier (authentication scheme). /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) + public string GetApiKeyWithPrefix(string apiKeyIdentifier) { var apiKeyValue = ""; ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/IReadableConfiguration.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/IReadableConfiguration.cs index ed1b6eddeac..32e87d6bd9a 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/IReadableConfiguration.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Client/IReadableConfiguration.cs @@ -18,18 +18,77 @@ namespace IO.Swagger.Client /// public interface IReadableConfiguration { + /// + /// Gets the access token. + /// + /// Access token. string AccessToken { get; } + + /// + /// Gets the API key. + /// + /// API key. IDictionary ApiKey { get; } + + /// + /// Gets the API key prefix. + /// + /// API key prefix. IDictionary ApiKeyPrefix { get; } + + /// + /// Gets the base path. + /// + /// Base path. string BasePath { get; } + + /// + /// Gets the date time format. + /// + /// Date time foramt. string DateTimeFormat { get; } + + /// + /// Gets the default header. + /// + /// Default header. IDictionary DefaultHeader { get; } - string Password { get; } + + /// + /// Gets the temp folder path. + /// + /// Temp folder path. string TempFolderPath { get; } + + /// + /// Gets the HTTP connection timeout (in milliseconds) + /// + /// HTTP connection timeout. int Timeout { get; } + + /// + /// Gets the user agent. + /// + /// User agent. string UserAgent { get; } + + /// + /// Gets the username. + /// + /// Username. string Username { get; } + /// + /// Gets the password. + /// + /// Password. + string Password { get; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. string GetApiKeyWithPrefix(string apiKeyIdentifier); } -} \ No newline at end of file +} diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md index 148d49b8b88..6b6450a12ab 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md @@ -293,9 +293,9 @@ namespace Example public void main() { // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new PetApi(); var petId = 789; // long? | ID of pet to return diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md index 1509a03158f..113032c257b 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md @@ -93,9 +93,9 @@ namespace Example public void main() { // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/Configuration.cs index bfea3c89bba..8c3926fa453 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/Configuration.cs @@ -267,11 +267,11 @@ namespace IO.Swagger.Client public virtual string Password { get; set; } /// - /// Gets or sets the access token for OAuth2 authentication. + /// Gets the API key with prefix. /// /// API key identifier (authentication scheme). /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) + public string GetApiKeyWithPrefix(string apiKeyIdentifier) { var apiKeyValue = ""; ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/IReadableConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/IReadableConfiguration.cs index ed1b6eddeac..32e87d6bd9a 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/IReadableConfiguration.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Client/IReadableConfiguration.cs @@ -18,18 +18,77 @@ namespace IO.Swagger.Client /// public interface IReadableConfiguration { + /// + /// Gets the access token. + /// + /// Access token. string AccessToken { get; } + + /// + /// Gets the API key. + /// + /// API key. IDictionary ApiKey { get; } + + /// + /// Gets the API key prefix. + /// + /// API key prefix. IDictionary ApiKeyPrefix { get; } + + /// + /// Gets the base path. + /// + /// Base path. string BasePath { get; } + + /// + /// Gets the date time format. + /// + /// Date time foramt. string DateTimeFormat { get; } + + /// + /// Gets the default header. + /// + /// Default header. IDictionary DefaultHeader { get; } - string Password { get; } + + /// + /// Gets the temp folder path. + /// + /// Temp folder path. string TempFolderPath { get; } + + /// + /// Gets the HTTP connection timeout (in milliseconds) + /// + /// HTTP connection timeout. int Timeout { get; } + + /// + /// Gets the user agent. + /// + /// User agent. string UserAgent { get; } + + /// + /// Gets the username. + /// + /// Username. string Username { get; } + /// + /// Gets the password. + /// + /// Password. + string Password { get; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. string GetApiKeyWithPrefix(string apiKeyIdentifier); } -} \ No newline at end of file +} diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md index 148d49b8b88..6b6450a12ab 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md @@ -293,9 +293,9 @@ namespace Example public void main() { // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new PetApi(); var petId = 789; // long? | ID of pet to return diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md index 1509a03158f..113032c257b 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md @@ -93,9 +93,9 @@ namespace Example public void main() { // Configure API key authorization: api_key - Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); + Configuration.Default.AddApiKey("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("api_key", "Bearer"); + // Configuration.Default.AddApiKeyPrefix("api_key", "Bearer"); var apiInstance = new StoreApi(); diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/Configuration.cs index 1e1e12c3522..531d240482a 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/Configuration.cs @@ -272,11 +272,11 @@ namespace IO.Swagger.Client public virtual string Password { get; set; } /// - /// Gets or sets the access token for OAuth2 authentication. + /// Gets the API key with prefix. /// /// API key identifier (authentication scheme). /// API key with prefix. - public string GetApiKeyWithPrefix (string apiKeyIdentifier) + public string GetApiKeyWithPrefix(string apiKeyIdentifier) { var apiKeyValue = ""; ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue); diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/IReadableConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/IReadableConfiguration.cs index ed1b6eddeac..32e87d6bd9a 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/IReadableConfiguration.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Client/IReadableConfiguration.cs @@ -18,18 +18,77 @@ namespace IO.Swagger.Client /// public interface IReadableConfiguration { + /// + /// Gets the access token. + /// + /// Access token. string AccessToken { get; } + + /// + /// Gets the API key. + /// + /// API key. IDictionary ApiKey { get; } + + /// + /// Gets the API key prefix. + /// + /// API key prefix. IDictionary ApiKeyPrefix { get; } + + /// + /// Gets the base path. + /// + /// Base path. string BasePath { get; } + + /// + /// Gets the date time format. + /// + /// Date time foramt. string DateTimeFormat { get; } + + /// + /// Gets the default header. + /// + /// Default header. IDictionary DefaultHeader { get; } - string Password { get; } + + /// + /// Gets the temp folder path. + /// + /// Temp folder path. string TempFolderPath { get; } + + /// + /// Gets the HTTP connection timeout (in milliseconds) + /// + /// HTTP connection timeout. int Timeout { get; } + + /// + /// Gets the user agent. + /// + /// User agent. string UserAgent { get; } + + /// + /// Gets the username. + /// + /// Username. string Username { get; } + /// + /// Gets the password. + /// + /// Password. + string Password { get; } + + /// + /// Gets the API key with prefix. + /// + /// API key identifier (authentication scheme). + /// API key with prefix. string GetApiKeyWithPrefix(string apiKeyIdentifier); } -} \ No newline at end of file +}