forked from loafle/openapi-generator-original
add oauth support to csharp
This commit is contained in:
@@ -319,8 +319,7 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
{{#authMethods}}
|
||||
case "{{name}}":
|
||||
{{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}
|
||||
{{#isOAuth}}//TODO support oauth{{/isOAuth}}
|
||||
{{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}{{#isOAuth}}headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;{{/isOAuth}}
|
||||
break;
|
||||
{{/authMethods}}
|
||||
default:
|
||||
|
||||
@@ -37,6 +37,12 @@ namespace {{packageName}}.Client
|
||||
/// <value>The password.</value>
|
||||
public static String Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the access token for OAuth2 authentication.
|
||||
/// </summary>
|
||||
/// <value>The access token.</value>
|
||||
public static String AccessToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API key based on the authentication name.
|
||||
/// </summary>
|
||||
|
||||
@@ -320,12 +320,10 @@ namespace IO.Swagger.Client
|
||||
|
||||
case "api_key":
|
||||
headerParams["api_key"] = GetApiKeyWithPrefix("api_key");
|
||||
|
||||
break;
|
||||
|
||||
case "petstore_auth":
|
||||
|
||||
//TODO support oauth
|
||||
headerParams["Authorization"] = "Bearer " + Configuration.AccessToken;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -37,6 +37,12 @@ namespace IO.Swagger.Client
|
||||
/// <value>The password.</value>
|
||||
public static String Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the access token for OAuth2 authentication.
|
||||
/// </summary>
|
||||
/// <value>The access token.</value>
|
||||
public static String AccessToken { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API key based on the authentication name.
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user