From 0ab9f74cfbe3cb7cab0bde199850417f3cdaaccd Mon Sep 17 00:00:00 2001 From: devhl-labs Date: Wed, 6 Dec 2023 01:49:55 -0500 Subject: [PATCH] use keyParamName (#17328) --- .../generichost/ApiTestsBase.mustache | 2 +- .../DependencyInjectionTests.mustache | 8 ++-- .../generichost/README.client.mustache | 10 +++-- .../src/UseSourceGeneration/README.md | 37 +------------------ .../src/Org.OpenAPITools/README.md | 37 +------------------ .../src/Org.OpenAPITools/README.md | 37 +------------------ .../src/Org.OpenAPITools/README.md | 37 +------------------ 7 files changed, 16 insertions(+), 152 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiTestsBase.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiTestsBase.mustache index 529458d3299..3292a1e8668 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiTestsBase.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/ApiTestsBase.mustache @@ -31,7 +31,7 @@ namespace {{packageName}}.Test.{{apiPackage}} {{#lambda.trimTrailingWithNewLine}} {{#apiKeyMethods}} string apiKeyTokenValue{{-index}} = context.Configuration[""] ?? throw new Exception("Token not found."); - ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}(apiKeyTokenValue{{-index}}, ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); + ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}(apiKeyTokenValue{{-index}}, ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{keyParamName}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(apiKeyToken{{-index}}); {{/apiKeyMethods}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DependencyInjectionTests.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DependencyInjectionTests.mustache index 33eea224d5c..9f7b2ea2b3f 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DependencyInjectionTests.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/DependencyInjectionTests.mustache @@ -21,7 +21,7 @@ namespace {{packageName}}.Test.{{apiPackage}} { {{#lambda.trimTrailingWithNewLine}} {{#apiKeyMethods}} - ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); + ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{keyParamName}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(apiKeyToken{{-index}}); {{/apiKeyMethods}} @@ -55,7 +55,7 @@ namespace {{packageName}}.Test.{{apiPackage}} { {{#lambda.trimTrailingWithNewLine}} {{#apiKeyMethods}} - ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); + ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{keyParamName}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(apiKeyToken{{-index}}); {{/apiKeyMethods}} @@ -92,7 +92,7 @@ namespace {{packageName}}.Test.{{apiPackage}} { {{#lambda.trimTrailingWithNewLine}} {{#apiKeyMethods}} - ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); + ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{keyParamName}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(apiKeyToken{{-index}}); {{/apiKeyMethods}} @@ -129,7 +129,7 @@ namespace {{packageName}}.Test.{{apiPackage}} { {{#lambda.trimTrailingWithNewLine}} {{#apiKeyMethods}} - ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); + ApiKeyToken apiKeyToken{{-index}} = new{{^net70OrLater}} ApiKeyToken{{/net70OrLater}}("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{keyParamName}}{{/lambda.titlecase}}, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(apiKeyToken{{-index}}); {{/apiKeyMethods}} diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/README.client.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/README.client.mustache index c7c8bff9282..2f74977652d 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/README.client.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/generichost/README.client.mustache @@ -80,14 +80,18 @@ namespace YourProject public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .Configure{{apiName}}((context, options) => { - {{#authMethods}}// the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}); + {{#authMethods}} + {{#-first}} + // the type of token here depends on the api security specifications + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); options.AddTokens(token); // optionally choose the method the tokens will be provided with, default is RateLimitProvider options.UseProvider, ApiKeyToken>(); - {{/authMethods}}options.ConfigureJsonOptions((jsonOptions) => + {{/-first}} + {{/authMethods}} + options.ConfigureJsonOptions((jsonOptions) => { // your custom converters if any }); diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/README.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/README.md index 42da06e5201..fd8e8c0c374 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/README.md @@ -69,42 +69,7 @@ namespace YourProject .ConfigureApi((context, options) => { // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Petstore_auth); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key_query); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_basic_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Bearer_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_signature_test); + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); options.AddTokens(token); // optionally choose the method the tokens will be provided with, default is RateLimitProvider diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/README.md index a3f095d7b66..a7035fda5db 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/README.md @@ -69,42 +69,7 @@ namespace YourProject .ConfigureApi((context, options) => { // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Petstore_auth); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key_query); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_basic_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Bearer_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_signature_test); + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); options.AddTokens(token); // optionally choose the method the tokens will be provided with, default is RateLimitProvider diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/README.md index 3577b428d32..0642123acc1 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/README.md @@ -69,42 +69,7 @@ namespace YourProject .ConfigureApi((context, options) => { // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Petstore_auth); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key_query); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_basic_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Bearer_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_signature_test); + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); options.AddTokens(token); // optionally choose the method the tokens will be provided with, default is RateLimitProvider diff --git a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/README.md b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/README.md index 25af3bdf008..a957baa422a 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/README.md +++ b/samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/README.md @@ -69,42 +69,7 @@ namespace YourProject .ConfigureApi((context, options) => { // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Petstore_auth); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Api_key_query); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_basic_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Bearer_test); - options.AddTokens(token); - - // optionally choose the method the tokens will be provided with, default is RateLimitProvider - options.UseProvider, ApiKeyToken>(); - - // the type of token here depends on the api security specifications - ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Http_signature_test); + ApiKeyToken token = new("", ClientUtils.ApiKeyHeader.Authorization); options.AddTokens(token); // optionally choose the method the tokens will be provided with, default is RateLimitProvider