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;
|
BasePath = basePath;
|
||||||
RestClient = new RestClient(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>
|
/// <summary>
|
||||||
/// Gets or sets the base path.
|
/// Gets or sets the base path.
|
||||||
|
@ -12,6 +12,17 @@ namespace {{packageName}}.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Configuration
|
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>
|
/// <summary>
|
||||||
/// Version of the package.
|
/// Version of the package.
|
||||||
@ -20,16 +31,16 @@ namespace {{packageName}}.Client
|
|||||||
public const string Version = "{{packageVersion}}";
|
public const string Version = "{{packageVersion}}";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default API client for making HTTP calls.
|
/// Gets or sets the default Configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client.</value>
|
/// <value>Configuration.</value>
|
||||||
public static Configuration DefaultConfiguration = new Configuration();
|
public static Configuration Default = new Configuration();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default API client for making HTTP calls.
|
/// Gets or sets the default API client for making HTTP calls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client.</value>
|
/// <value>The API client.</value>
|
||||||
public ApiClient ApiClient = new ApiClient();
|
public ApiClient ApiClient;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the username (HTTP basic authentication).
|
/// Gets or sets the username (HTTP basic authentication).
|
||||||
|
@ -49,7 +49,7 @@ namespace {{packageName}}.Api
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public {{classname}}(String basePath)
|
public {{classname}}(String basePath)
|
||||||
{
|
{
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
this.SetBasePath(basePath);
|
this.SetBasePath(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace {{packageName}}.Api
|
|||||||
public {{classname}}(Configuration configuration = null)
|
public {{classname}}(Configuration configuration = null)
|
||||||
{
|
{
|
||||||
if (configuration == null) // use the default one in Configuration
|
if (configuration == null) // use the default one in Configuration
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
else
|
else
|
||||||
this.Configuration = configuration;
|
this.Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
@ -198,20 +198,20 @@ namespace IO.Swagger.Api
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public PetApi(String basePath)
|
public PetApi(String basePath)
|
||||||
{
|
{
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
this.SetBasePath(basePath);
|
this.SetBasePath(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PetApi"/> class
|
/// Initializes a new instance of the <see cref="PetApi"/> class
|
||||||
/// using Configuration object.
|
/// using Configuration object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="configuration">An instance of Configuration</param>
|
/// <param name="configuration">An instance of Configuration</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public PetApi(Configuration configuration = null)
|
public PetApi(Configuration configuration = null)
|
||||||
{
|
{
|
||||||
if (configuration == null) // use the default one in Configuration
|
if (configuration == null) // use the default one in Configuration
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
else
|
else
|
||||||
this.Configuration = configuration;
|
this.Configuration = configuration;
|
||||||
}
|
}
|
||||||
@ -236,20 +236,21 @@ namespace IO.Swagger.Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the configuration object.
|
/// Gets or sets the configuration object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>An instance of the Configuration</value>
|
/// <value>An instance of the Configuration</value>
|
||||||
public Configuration Configuration {get; set;}
|
public Configuration Configuration {get; set;}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the status code of the previous request.
|
/// Gets the status code of the previous request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int StatusCode { get; private set; }
|
public int StatusCode { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the response headers of the previous request.
|
/// Gets the response headers of the previous request
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<String, String> ResponseHeaders { get; private set; }
|
public Dictionary<String, String> ResponseHeaders { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update an existing pet
|
/// Update an existing pet
|
||||||
|
@ -106,7 +106,7 @@ namespace IO.Swagger.Api
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public StoreApi(String basePath)
|
public StoreApi(String basePath)
|
||||||
{
|
{
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
this.SetBasePath(basePath);
|
this.SetBasePath(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ namespace IO.Swagger.Api
|
|||||||
public StoreApi(Configuration configuration = null)
|
public StoreApi(Configuration configuration = null)
|
||||||
{
|
{
|
||||||
if (configuration == null) // use the default one in Configuration
|
if (configuration == null) // use the default one in Configuration
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
else
|
else
|
||||||
this.Configuration = configuration;
|
this.Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ namespace IO.Swagger.Api
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public UserApi(String basePath)
|
public UserApi(String basePath)
|
||||||
{
|
{
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
this.SetBasePath(basePath);
|
this.SetBasePath(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ namespace IO.Swagger.Api
|
|||||||
public UserApi(Configuration configuration = null)
|
public UserApi(Configuration configuration = null)
|
||||||
{
|
{
|
||||||
if (configuration == null) // use the default one in Configuration
|
if (configuration == null) // use the default one in Configuration
|
||||||
this.Configuration = Configuration.DefaultConfiguration;
|
this.Configuration = Configuration.Default;
|
||||||
else
|
else
|
||||||
this.Configuration = configuration;
|
this.Configuration = configuration;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,12 @@ namespace IO.Swagger.Client
|
|||||||
BasePath = basePath;
|
BasePath = basePath;
|
||||||
RestClient = new RestClient(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>
|
/// <summary>
|
||||||
/// Gets or sets the base path.
|
/// Gets or sets the base path.
|
||||||
|
@ -12,6 +12,17 @@ namespace IO.Swagger.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Configuration
|
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>
|
/// <summary>
|
||||||
/// Version of the package.
|
/// Version of the package.
|
||||||
@ -20,16 +31,16 @@ namespace IO.Swagger.Client
|
|||||||
public const string Version = "1.0.0";
|
public const string Version = "1.0.0";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default API client for making HTTP calls.
|
/// Gets or sets the default Configuration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client.</value>
|
/// <value>Configuration.</value>
|
||||||
public static Configuration DefaultConfiguration = new Configuration();
|
public static Configuration Default = new Configuration();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the default API client for making HTTP calls.
|
/// Gets or sets the default API client for making HTTP calls.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client.</value>
|
/// <value>The API client.</value>
|
||||||
public ApiClient ApiClient = new ApiClient();
|
public ApiClient ApiClient;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the username (HTTP basic authentication).
|
/// Gets or sets the username (HTTP basic authentication).
|
||||||
|
@ -1,9 +1,28 @@
|
|||||||
<Properties StartupItem="SwaggerClientTest.csproj">
|
<Properties StartupItem="SwaggerClientTest.csproj">
|
||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="TestConfiguration.cs">
|
||||||
<Files>
|
<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>
|
</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.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
<BreakpointStore />
|
<BreakpointStore />
|
||||||
|
@ -27,7 +27,7 @@ namespace SwaggerClient.TestConfiguration
|
|||||||
{
|
{
|
||||||
PetApi p = new PetApi ("http://new-basepath.com");
|
PetApi p = new PetApi ("http://new-basepath.com");
|
||||||
Assert.AreEqual (p.Configuration.ApiClient.BasePath, "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 ();
|
PetApi p2 = new PetApi ();
|
||||||
Assert.AreSame (p1.Configuration, p2.Configuration);
|
Assert.AreSame (p1.Configuration, p2.Configuration);
|
||||||
// same as the default
|
// same as the default
|
||||||
Assert.AreSame (p1.Configuration, Configuration.DefaultConfiguration);
|
Assert.AreSame (p1.Configuration, Configuration.Default);
|
||||||
|
|
||||||
Configuration c = new Configuration ();
|
Configuration c = new Configuration ();
|
||||||
Assert.AreNotSame (c, p1.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