forked from loafle/openapi-generator-original
add default api client
This commit is contained in:
parent
c9f2380f0f
commit
0abe787b58
@ -29,6 +29,12 @@ namespace {{packageName}}.Client
|
||||
BasePath = basePath;
|
||||
RestClient = new RestClient(BasePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The default API client.</value>
|
||||
public static ApiClient Default = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
|
@ -12,6 +12,17 @@ namespace {{packageName}}.Client
|
||||
/// </summary>
|
||||
public class Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Configuration class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient">Api client.</param>
|
||||
public Configuration(ApiClient apiClient=null)
|
||||
{
|
||||
if (apiClient == null)
|
||||
ApiClient = ApiClient.Default;
|
||||
else
|
||||
ApiClient = apiClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Version of the package.
|
||||
@ -20,16 +31,16 @@ namespace {{packageName}}.Client
|
||||
public const string Version = "{{packageVersion}}";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// Gets or sets the default Configuration.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public static Configuration DefaultConfiguration = new Configuration();
|
||||
/// <value>Configuration.</value>
|
||||
public static Configuration Default = new Configuration();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient = new ApiClient();
|
||||
public ApiClient ApiClient;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication).
|
||||
|
@ -49,7 +49,7 @@ namespace {{packageName}}.Api
|
||||
/// <returns></returns>
|
||||
public {{classname}}(String basePath)
|
||||
{
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
this.SetBasePath(basePath);
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ namespace {{packageName}}.Api
|
||||
public {{classname}}(Configuration configuration = null)
|
||||
{
|
||||
if (configuration == null) // use the default one in Configuration
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
else
|
||||
this.Configuration = configuration;
|
||||
}
|
||||
|
@ -198,20 +198,20 @@ namespace IO.Swagger.Api
|
||||
/// <returns></returns>
|
||||
public PetApi(String basePath)
|
||||
{
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
this.SetBasePath(basePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PetApi"/> class
|
||||
/// using Configuration object.
|
||||
/// using Configuration object
|
||||
/// </summary>
|
||||
/// <param name="configuration">An instance of Configuration</param>
|
||||
/// <returns></returns>
|
||||
public PetApi(Configuration configuration = null)
|
||||
{
|
||||
if (configuration == null) // use the default one in Configuration
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
else
|
||||
this.Configuration = configuration;
|
||||
}
|
||||
@ -236,20 +236,21 @@ namespace IO.Swagger.Api
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration object.
|
||||
/// Gets or sets the configuration object
|
||||
/// </summary>
|
||||
/// <value>An instance of the Configuration</value>
|
||||
public Configuration Configuration {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the status code of the previous request.
|
||||
/// Gets the status code of the previous request
|
||||
/// </summary>
|
||||
public int StatusCode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the response headers of the previous request.
|
||||
/// Gets the response headers of the previous request
|
||||
/// </summary>
|
||||
public Dictionary<String, String> ResponseHeaders { get; private set; }
|
||||
public Dictionary<String, String> ResponseHeaders { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
|
@ -106,7 +106,7 @@ namespace IO.Swagger.Api
|
||||
/// <returns></returns>
|
||||
public StoreApi(String basePath)
|
||||
{
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
this.SetBasePath(basePath);
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ namespace IO.Swagger.Api
|
||||
public StoreApi(Configuration configuration = null)
|
||||
{
|
||||
if (configuration == null) // use the default one in Configuration
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
else
|
||||
this.Configuration = configuration;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ namespace IO.Swagger.Api
|
||||
/// <returns></returns>
|
||||
public UserApi(String basePath)
|
||||
{
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
this.SetBasePath(basePath);
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ namespace IO.Swagger.Api
|
||||
public UserApi(Configuration configuration = null)
|
||||
{
|
||||
if (configuration == null) // use the default one in Configuration
|
||||
this.Configuration = Configuration.DefaultConfiguration;
|
||||
this.Configuration = Configuration.Default;
|
||||
else
|
||||
this.Configuration = configuration;
|
||||
}
|
||||
|
@ -29,6 +29,12 @@ namespace IO.Swagger.Client
|
||||
BasePath = basePath;
|
||||
RestClient = new RestClient(BasePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The default API client.</value>
|
||||
public static ApiClient Default = new ApiClient();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
|
@ -12,6 +12,17 @@ namespace IO.Swagger.Client
|
||||
/// </summary>
|
||||
public class Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the Configuration class.
|
||||
/// </summary>
|
||||
/// <param name="apiClient">Api client.</param>
|
||||
public Configuration(ApiClient apiClient=null)
|
||||
{
|
||||
if (apiClient == null)
|
||||
ApiClient = ApiClient.Default;
|
||||
else
|
||||
ApiClient = apiClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Version of the package.
|
||||
@ -20,16 +31,16 @@ namespace IO.Swagger.Client
|
||||
public const string Version = "1.0.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// Gets or sets the default Configuration.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public static Configuration DefaultConfiguration = new Configuration();
|
||||
/// <value>Configuration.</value>
|
||||
public static Configuration Default = new Configuration();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
public ApiClient ApiClient = new ApiClient();
|
||||
public ApiClient ApiClient;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the username (HTTP basic authentication).
|
||||
|
@ -1,9 +1,28 @@
|
||||
<Properties StartupItem="SwaggerClientTest.csproj">
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestConfiguration.cs">
|
||||
<Files>
|
||||
<File FileName="TestPet.cs" Line="15" Column="3" />
|
||||
<File FileName="TestPet.cs" Line="238" Column="34" />
|
||||
<File FileName="TestConfiguration.cs" Line="26" Column="30" />
|
||||
</Files>
|
||||
<Pads>
|
||||
<Pad Id="MonoDevelop.NUnit.TestPad">
|
||||
<State name="__root__">
|
||||
<Node name="SwaggerClientTest" expanded="True">
|
||||
<Node name="SwaggerClientTest" expanded="True">
|
||||
<Node name="SwaggerClient" expanded="True">
|
||||
<Node name="TestApiClient" expanded="True" />
|
||||
<Node name="TestPet" expanded="True">
|
||||
<Node name="TestPet" expanded="True">
|
||||
<Node name="TestStatusCodeAndHeader" selected="True" />
|
||||
</Node>
|
||||
</Node>
|
||||
</Node>
|
||||
</Node>
|
||||
</Node>
|
||||
</State>
|
||||
</Pad>
|
||||
</Pads>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
|
@ -27,7 +27,7 @@ namespace SwaggerClient.TestConfiguration
|
||||
{
|
||||
PetApi p = new PetApi ("http://new-basepath.com");
|
||||
Assert.AreEqual (p.Configuration.ApiClient.BasePath, "http://new-basepath.com");
|
||||
Assert.AreSame (p.Configuration, Configuration.DefaultConfiguration);
|
||||
Assert.AreSame (p.Configuration, Configuration.Default);
|
||||
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ namespace SwaggerClient.TestConfiguration
|
||||
PetApi p2 = new PetApi ();
|
||||
Assert.AreSame (p1.Configuration, p2.Configuration);
|
||||
// same as the default
|
||||
Assert.AreSame (p1.Configuration, Configuration.DefaultConfiguration);
|
||||
Assert.AreSame (p1.Configuration, Configuration.Default);
|
||||
|
||||
Configuration c = new Configuration ();
|
||||
Assert.AreNotSame (c, p1.Configuration);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user