diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 9a9f99f26b8..d97abd81589 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -262,7 +262,7 @@ namespace {{packageName}}.{{apiPackage}} {{#isKeyInQuery}} if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) { - localVarQueryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "{{keyParamName}}", Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); } {{/isKeyInQuery}} {{/isApiKey}} @@ -278,7 +278,8 @@ namespace {{packageName}}.{{apiPackage}} if (!String.IsNullOrEmpty(Configuration.AccessToken)) { localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken; - }{{/isOAuth}} + } + {{/isOAuth}} {{/authMethods}} // make the HTTP request @@ -397,7 +398,7 @@ namespace {{packageName}}.{{apiPackage}} {{#isKeyInQuery}} if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))) { - localVarQueryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}"); + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "{{keyParamName}}", Configuration.GetApiKeyWithPrefix("{{keyParamName}}"))); } {{/isKeyInQuery}} {{/isApiKey}} diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml index 6245293d798..3aeec9ea4ad 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml @@ -583,6 +583,8 @@ paths: description: successful operation schema: $ref: '#/definitions/Client' + security: + - api_key_query: [] /fake: patch: tags: @@ -908,6 +910,10 @@ securityDefinitions: type: apiKey name: api_key in: header + api_key_query: + type: apiKey + name: api_key_query + in: query http_basic_test: type: basic definitions: diff --git a/samples/client/petstore/csharp/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClient/README.md index 0973f0a9f40..257a7e86293 100644 --- a/samples/client/petstore/csharp/SwaggerClient/README.md +++ b/samples/client/petstore/csharp/SwaggerClient/README.md @@ -175,6 +175,13 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + ### http_basic_test diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/Fake_classname_tags123Api.md b/samples/client/petstore/csharp/SwaggerClient/docs/Fake_classname_tags123Api.md index 9db41af1c5d..d79ca65f1f9 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/Fake_classname_tags123Api.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/Fake_classname_tags123Api.md @@ -27,6 +27,11 @@ namespace Example { public void main() { + // Configure API key authorization: api_key_query + Configuration.Default.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.AddApiKeyPrefix("api_key_query", "Bearer"); + var apiInstance = new Fake_classname_tags123Api(); var body = new ModelClient(); // ModelClient | client model @@ -57,7 +62,7 @@ Name | Type | Description | Notes ### Authorization -No authorization required +[api_key_query](../README.md#api_key_query) ### HTTP request headers diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs index ea1a909a981..d74183aa9ee 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs @@ -1355,7 +1355,6 @@ namespace IO.Swagger.Api localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/Fake_classname_tags123Api.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/Fake_classname_tags123Api.cs index 72d9b04836b..d33366a6fc7 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/Fake_classname_tags123Api.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/Fake_classname_tags123Api.cs @@ -223,6 +223,11 @@ namespace IO.Swagger.Api localVarPostBody = body; // byte array } + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, @@ -298,6 +303,11 @@ namespace IO.Swagger.Api localVarPostBody = body; // byte array } + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/PetApi.cs index 6ebddb476f4..36594a68e1c 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/PetApi.cs @@ -1144,7 +1144,6 @@ namespace IO.Swagger.Api localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/StoreApi.cs index 1317209a857..ea0f02ce8cc 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/StoreApi.cs @@ -470,7 +470,6 @@ namespace IO.Swagger.Api localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md index 79f1f405209..a153e0e12e4 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md @@ -155,6 +155,13 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + ### http_basic_test diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/Fake_classname_tags123Api.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/Fake_classname_tags123Api.md index 9db41af1c5d..d79ca65f1f9 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/Fake_classname_tags123Api.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/Fake_classname_tags123Api.md @@ -27,6 +27,11 @@ namespace Example { public void main() { + // Configure API key authorization: api_key_query + Configuration.Default.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.AddApiKeyPrefix("api_key_query", "Bearer"); + var apiInstance = new Fake_classname_tags123Api(); var body = new ModelClient(); // ModelClient | client model @@ -57,7 +62,7 @@ Name | Type | Description | Notes ### Authorization -No authorization required +[api_key_query](../README.md#api_key_query) ### HTTP request headers diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs index b3451484ef0..ce9fef9c385 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs @@ -1355,7 +1355,6 @@ namespace IO.Swagger.Api localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/Fake_classname_tags123Api.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/Fake_classname_tags123Api.cs index 8c9f9c83fe1..a62ce556d4b 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/Fake_classname_tags123Api.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/Fake_classname_tags123Api.cs @@ -223,6 +223,11 @@ namespace IO.Swagger.Api localVarPostBody = body; // byte array } + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, @@ -298,6 +303,11 @@ namespace IO.Swagger.Api localVarPostBody = body; // byte array } + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/PetApi.cs index 0a95c0e99ba..63c520824f9 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/PetApi.cs @@ -1144,7 +1144,6 @@ namespace IO.Swagger.Api localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/StoreApi.cs index c48bee75632..d1abfb9a83b 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/StoreApi.cs @@ -470,7 +470,6 @@ namespace IO.Swagger.Api localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md index 0973f0a9f40..257a7e86293 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md @@ -175,6 +175,13 @@ Class | Method | HTTP request | Description - **API key parameter name**: api_key - **Location**: HTTP header + +### api_key_query + +- **Type**: API key +- **API key parameter name**: api_key_query +- **Location**: URL query string + ### http_basic_test diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/Fake_classname_tags123Api.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/Fake_classname_tags123Api.md index 9db41af1c5d..d79ca65f1f9 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/Fake_classname_tags123Api.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/Fake_classname_tags123Api.md @@ -27,6 +27,11 @@ namespace Example { public void main() { + // Configure API key authorization: api_key_query + Configuration.Default.AddApiKey("api_key_query", "YOUR_API_KEY"); + // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed + // Configuration.Default.AddApiKeyPrefix("api_key_query", "Bearer"); + var apiInstance = new Fake_classname_tags123Api(); var body = new ModelClient(); // ModelClient | client model @@ -57,7 +62,7 @@ Name | Type | Description | Notes ### Authorization -No authorization required +[api_key_query](../README.md#api_key_query) ### HTTP request headers diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs index ea1a909a981..d74183aa9ee 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs @@ -1355,7 +1355,6 @@ namespace IO.Swagger.Api localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/Fake_classname_tags123Api.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/Fake_classname_tags123Api.cs index 72d9b04836b..d33366a6fc7 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/Fake_classname_tags123Api.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/Fake_classname_tags123Api.cs @@ -223,6 +223,11 @@ namespace IO.Swagger.Api localVarPostBody = body; // byte array } + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, @@ -298,6 +303,11 @@ namespace IO.Swagger.Api localVarPostBody = body; // byte array } + // authentication (api_key_query) required + if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query"))) + { + localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query"))); + } // make the HTTP request IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/PetApi.cs index 6ebddb476f4..36594a68e1c 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/PetApi.cs @@ -1144,7 +1144,6 @@ namespace IO.Swagger.Api localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/StoreApi.cs index 1317209a857..ea0f02ce8cc 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/StoreApi.cs @@ -470,7 +470,6 @@ namespace IO.Swagger.Api localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key"); } - // make the HTTP request IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,