forked from loafle/openapi-generator-original
fix issue with api key (query) in c# (#6199)
This commit is contained in:
parent
e4e9a985e3
commit
82835db670
@ -262,7 +262,7 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
{{#isKeyInQuery}}
|
{{#isKeyInQuery}}
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||||
{
|
{
|
||||||
localVarQueryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "{{keyParamName}}", Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||||
}
|
}
|
||||||
{{/isKeyInQuery}}
|
{{/isKeyInQuery}}
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
@ -278,7 +278,8 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
if (!String.IsNullOrEmpty(Configuration.AccessToken))
|
||||||
{
|
{
|
||||||
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||||
}{{/isOAuth}}
|
}
|
||||||
|
{{/isOAuth}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
@ -397,7 +398,7 @@ namespace {{packageName}}.{{apiPackage}}
|
|||||||
{{#isKeyInQuery}}
|
{{#isKeyInQuery}}
|
||||||
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("{{keyParamName}}")))
|
||||||
{
|
{
|
||||||
localVarQueryParams["{{keyParamName}}"] = Configuration.GetApiKeyWithPrefix("{{keyParamName}}");
|
localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "{{keyParamName}}", Configuration.GetApiKeyWithPrefix("{{keyParamName}}")));
|
||||||
}
|
}
|
||||||
{{/isKeyInQuery}}
|
{{/isKeyInQuery}}
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
|
@ -583,6 +583,8 @@ paths:
|
|||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/Client'
|
$ref: '#/definitions/Client'
|
||||||
|
security:
|
||||||
|
- api_key_query: []
|
||||||
/fake:
|
/fake:
|
||||||
patch:
|
patch:
|
||||||
tags:
|
tags:
|
||||||
@ -908,6 +910,10 @@ securityDefinitions:
|
|||||||
type: apiKey
|
type: apiKey
|
||||||
name: api_key
|
name: api_key
|
||||||
in: header
|
in: header
|
||||||
|
api_key_query:
|
||||||
|
type: apiKey
|
||||||
|
name: api_key_query
|
||||||
|
in: query
|
||||||
http_basic_test:
|
http_basic_test:
|
||||||
type: basic
|
type: basic
|
||||||
definitions:
|
definitions:
|
||||||
|
@ -175,6 +175,13 @@ Class | Method | HTTP request | Description
|
|||||||
- **API key parameter name**: api_key
|
- **API key parameter name**: api_key
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
<a name="api_key_query"></a>
|
||||||
|
### api_key_query
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key_query
|
||||||
|
- **Location**: URL query string
|
||||||
|
|
||||||
<a name="http_basic_test"></a>
|
<a name="http_basic_test"></a>
|
||||||
### http_basic_test
|
### http_basic_test
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@ namespace Example
|
|||||||
{
|
{
|
||||||
public void main()
|
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 apiInstance = new Fake_classname_tags123Api();
|
||||||
var body = new ModelClient(); // ModelClient | client model
|
var body = new ModelClient(); // ModelClient | client model
|
||||||
|
|
||||||
@ -57,7 +62,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
No authorization required
|
[api_key_query](../README.md#api_key_query)
|
||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
|
@ -1355,7 +1355,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -223,6 +223,11 @@ namespace IO.Swagger.Api
|
|||||||
localVarPostBody = body; // byte array
|
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
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
@ -298,6 +303,11 @@ namespace IO.Swagger.Api
|
|||||||
localVarPostBody = body; // byte array
|
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
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
||||||
|
@ -1144,7 +1144,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -470,7 +470,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -155,6 +155,13 @@ Class | Method | HTTP request | Description
|
|||||||
- **API key parameter name**: api_key
|
- **API key parameter name**: api_key
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
<a name="api_key_query"></a>
|
||||||
|
### api_key_query
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key_query
|
||||||
|
- **Location**: URL query string
|
||||||
|
|
||||||
<a name="http_basic_test"></a>
|
<a name="http_basic_test"></a>
|
||||||
### http_basic_test
|
### http_basic_test
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@ namespace Example
|
|||||||
{
|
{
|
||||||
public void main()
|
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 apiInstance = new Fake_classname_tags123Api();
|
||||||
var body = new ModelClient(); // ModelClient | client model
|
var body = new ModelClient(); // ModelClient | client model
|
||||||
|
|
||||||
@ -57,7 +62,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
No authorization required
|
[api_key_query](../README.md#api_key_query)
|
||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
|
@ -1355,7 +1355,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -223,6 +223,11 @@ namespace IO.Swagger.Api
|
|||||||
localVarPostBody = body; // byte array
|
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
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
@ -298,6 +303,11 @@ namespace IO.Swagger.Api
|
|||||||
localVarPostBody = body; // byte array
|
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
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
||||||
|
@ -1144,7 +1144,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -470,7 +470,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -175,6 +175,13 @@ Class | Method | HTTP request | Description
|
|||||||
- **API key parameter name**: api_key
|
- **API key parameter name**: api_key
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
|
<a name="api_key_query"></a>
|
||||||
|
### api_key_query
|
||||||
|
|
||||||
|
- **Type**: API key
|
||||||
|
- **API key parameter name**: api_key_query
|
||||||
|
- **Location**: URL query string
|
||||||
|
|
||||||
<a name="http_basic_test"></a>
|
<a name="http_basic_test"></a>
|
||||||
### http_basic_test
|
### http_basic_test
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@ namespace Example
|
|||||||
{
|
{
|
||||||
public void main()
|
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 apiInstance = new Fake_classname_tags123Api();
|
||||||
var body = new ModelClient(); // ModelClient | client model
|
var body = new ModelClient(); // ModelClient | client model
|
||||||
|
|
||||||
@ -57,7 +62,7 @@ Name | Type | Description | Notes
|
|||||||
|
|
||||||
### Authorization
|
### Authorization
|
||||||
|
|
||||||
No authorization required
|
[api_key_query](../README.md#api_key_query)
|
||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
|
@ -1355,7 +1355,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(Configuration.Username + ":" + Configuration.Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -223,6 +223,11 @@ namespace IO.Swagger.Api
|
|||||||
localVarPostBody = body; // byte array
|
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
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
@ -298,6 +303,11 @@ namespace IO.Swagger.Api
|
|||||||
localVarPostBody = body; // byte array
|
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
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
||||||
|
@ -1144,7 +1144,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
@ -470,7 +470,6 @@ namespace IO.Swagger.Api
|
|||||||
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||||
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user