[csharp] Add interface for API config aspects

This allows developers to gain access to each API's
Configuration and  GetBasePath without need for reflection.
This commit is contained in:
Jim Schubert 2016-05-12 22:06:30 -04:00
parent 726228a27d
commit 993a21ed5f
3 changed files with 29 additions and 1 deletions

View File

@ -218,6 +218,8 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
binRelativePath += "vendor";
additionalProperties.put("binRelativePath", binRelativePath);
supportingFiles.add(new SupportingFile("IApiAccessor.mustache",
clientPackageDir, "IApiAccessor.cs"));
supportingFiles.add(new SupportingFile("Configuration.mustache",
clientPackageDir, "Configuration.cs"));
supportingFiles.add(new SupportingFile("ApiClient.mustache",

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using RestSharp;
namespace {{packageName}}.Client
{
/// <summary>
/// Represents configuration aspects required to interact with the API endpoints.
/// </summary>
public interface IApiAccessor
{
/// <summary>
/// Gets or sets the configuration object
/// </summary>
/// <value>An instance of the Configuration</value>
Configuration Configuration {get; set;}
/// <summary>
/// Gets the base path of the API client.
/// </summary>
/// <value>The base path</value>
String GetBasePath();
}
}

View File

@ -13,7 +13,7 @@ namespace {{packageName}}.Api
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface I{{classname}}
public interface I{{classname}} : IApiAccessor
{
#region Synchronous Operations
{{#operation}}