mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-29 20:20:53 +00:00
better style for model, add <value> to all properties
This commit is contained in:
parent
b1b0e28f59
commit
e49fe7a12f
@ -34,11 +34,13 @@ namespace {{packageName}}.Client
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public string BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient.
|
||||
/// </summary>
|
||||
/// <value>An instance of the RestClient</value>
|
||||
public RestClient RestClient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -205,28 +207,34 @@ namespace {{packageName}}.Client
|
||||
{
|
||||
if (type == typeof(Object)) // return an object
|
||||
{
|
||||
return (Object)content;
|
||||
} else if (type == typeof(Stream))
|
||||
{
|
||||
String fileName, filePath;
|
||||
if (String.IsNullOrEmpty (Configuration.TempFolderPath))
|
||||
filePath = System.IO.Path.GetTempPath ();
|
||||
else
|
||||
filePath = Configuration.TempFolderPath;
|
||||
|
||||
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
Match match = regex.Match(headers.ToString());
|
||||
if (match.Success) // replace first and last " or ', if found
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
||||
else
|
||||
fileName = filePath + Guid.NewGuid().ToString();
|
||||
return content;
|
||||
}
|
||||
|
||||
File.WriteAllText (fileName, content);
|
||||
if (type == typeof(Stream))
|
||||
{
|
||||
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
|
||||
? Path.GetTempPath()
|
||||
: Configuration.TempFolderPath;
|
||||
|
||||
var fileName = filePath + Guid.NewGuid();
|
||||
if (headers != null)
|
||||
{
|
||||
var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
var match = regex.Match(headers.ToString());
|
||||
if (match.Success)
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
|
||||
}
|
||||
File.WriteAllText(fileName, content);
|
||||
return new FileStream(fileName, FileMode.Open);
|
||||
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||
|
||||
}
|
||||
|
||||
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||
{
|
||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||
}
|
||||
|
||||
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||
{
|
||||
return ConvertType(content, type);
|
||||
}
|
||||
|
@ -82,10 +82,9 @@ namespace {{packageName}}.Client
|
||||
/// <summary>
|
||||
/// Returns a string with essential information for debugging.
|
||||
/// </summary>
|
||||
/// <value>Debugging Report</value>
|
||||
public static String ToDebugReport()
|
||||
{
|
||||
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
|
||||
String report = "C# SDK ({{packageName}}) Debug Report:\n";
|
||||
report += " OS: " + Environment.OSVersion + "\n";
|
||||
report += " .NET Framework Version: " + Assembly
|
||||
.GetExecutingAssembly()
|
||||
|
@ -59,6 +59,7 @@ namespace {{packageName}}.Api
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
@ -68,6 +69,7 @@ namespace {{packageName}}.Api
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath)
|
||||
{
|
||||
@ -77,7 +79,7 @@ namespace {{packageName}}.Api
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
/// <value>An instance of the ApiClient</param>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
{{#operation}}
|
||||
|
@ -15,7 +15,10 @@ namespace {{packageName}}.Model {
|
||||
[DataContract]
|
||||
public class {{classname}}{{#parent}} : {{{parent}}}{{/parent}} {
|
||||
{{#vars}}
|
||||
{{#description}}/* {{{description}}} */{{/description}}
|
||||
/// <summary>
|
||||
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
/// <value>{{{description}}}</value>{{/description}}
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue=false)]
|
||||
public {{{datatype}}} {{name}} { get; set; }
|
||||
|
||||
|
@ -166,6 +166,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
@ -175,6 +176,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath)
|
||||
{
|
||||
@ -184,7 +186,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
/// <value>An instance of the ApiClient</param>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
|
@ -98,6 +98,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
@ -107,6 +108,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath)
|
||||
{
|
||||
@ -116,7 +118,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
/// <value>An instance of the ApiClient</param>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
|
@ -158,6 +158,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
@ -167,6 +168,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path</param>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath(String basePath)
|
||||
{
|
||||
@ -176,7 +178,7 @@ namespace IO.Swagger.Api
|
||||
/// <summary>
|
||||
/// Gets or sets the API client.
|
||||
/// </summary>
|
||||
/// <value>The API client.</value>
|
||||
/// <value>An instance of the ApiClient</param>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
|
@ -34,11 +34,13 @@ namespace IO.Swagger.Client
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public string BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient.
|
||||
/// </summary>
|
||||
/// <value>An instance of the RestClient</value>
|
||||
public RestClient RestClient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@ -205,28 +207,34 @@ namespace IO.Swagger.Client
|
||||
{
|
||||
if (type == typeof(Object)) // return an object
|
||||
{
|
||||
return (Object)content;
|
||||
} else if (type == typeof(Stream))
|
||||
{
|
||||
String fileName, filePath;
|
||||
if (String.IsNullOrEmpty (Configuration.TempFolderPath))
|
||||
filePath = System.IO.Path.GetTempPath ();
|
||||
else
|
||||
filePath = Configuration.TempFolderPath;
|
||||
|
||||
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
Match match = regex.Match(headers.ToString());
|
||||
if (match.Success) // replace first and last " or ', if found
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
||||
else
|
||||
fileName = filePath + Guid.NewGuid().ToString();
|
||||
return content;
|
||||
}
|
||||
|
||||
File.WriteAllText (fileName, content);
|
||||
if (type == typeof(Stream))
|
||||
{
|
||||
var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
|
||||
? Path.GetTempPath()
|
||||
: Configuration.TempFolderPath;
|
||||
|
||||
var fileName = filePath + Guid.NewGuid();
|
||||
if (headers != null)
|
||||
{
|
||||
var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
var match = regex.Match(headers.ToString());
|
||||
if (match.Success)
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
|
||||
}
|
||||
File.WriteAllText(fileName, content);
|
||||
return new FileStream(fileName, FileMode.Open);
|
||||
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||
|
||||
}
|
||||
|
||||
if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||
{
|
||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||
}
|
||||
|
||||
if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||
{
|
||||
return ConvertType(content, type);
|
||||
}
|
||||
|
@ -82,10 +82,9 @@ namespace IO.Swagger.Client
|
||||
/// <summary>
|
||||
/// Returns a string with essential information for debugging.
|
||||
/// </summary>
|
||||
/// <value>Debugging Report</value>
|
||||
public static String ToDebugReport()
|
||||
{
|
||||
String report = "C# SDK () Debug Report:\n";
|
||||
String report = "C# SDK (IO.Swagger) Debug Report:\n";
|
||||
report += " OS: " + Environment.OSVersion + "\n";
|
||||
report += " .NET Framework Version: " + Assembly
|
||||
.GetExecutingAssembly()
|
||||
|
@ -13,12 +13,16 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Category {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -13,32 +13,45 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Order {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PetId
|
||||
/// </summary>
|
||||
[DataMember(Name="petId", EmitDefaultValue=false)]
|
||||
public long? PetId { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Quantity
|
||||
/// </summary>
|
||||
[DataMember(Name="quantity", EmitDefaultValue=false)]
|
||||
public int? Quantity { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets ShipDate
|
||||
/// </summary>
|
||||
[DataMember(Name="shipDate", EmitDefaultValue=false)]
|
||||
public DateTime? ShipDate { get; set; }
|
||||
|
||||
|
||||
/* Order Status */
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
/// <value>Order Status</value>
|
||||
[DataMember(Name="status", EmitDefaultValue=false)]
|
||||
public string Status { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Complete
|
||||
/// </summary>
|
||||
[DataMember(Name="complete", EmitDefaultValue=false)]
|
||||
public bool? Complete { get; set; }
|
||||
|
||||
|
@ -13,32 +13,45 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Pet {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Category
|
||||
/// </summary>
|
||||
[DataMember(Name="category", EmitDefaultValue=false)]
|
||||
public Category Category { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets PhotoUrls
|
||||
/// </summary>
|
||||
[DataMember(Name="photoUrls", EmitDefaultValue=false)]
|
||||
public List<string> PhotoUrls { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Tags
|
||||
/// </summary>
|
||||
[DataMember(Name="tags", EmitDefaultValue=false)]
|
||||
public List<Tag> Tags { get; set; }
|
||||
|
||||
|
||||
/* pet status in the store */
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
/// <value>pet status in the store</value>
|
||||
[DataMember(Name="status", EmitDefaultValue=false)]
|
||||
public string Status { get; set; }
|
||||
|
||||
|
@ -13,12 +13,16 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class Tag {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -13,42 +13,59 @@ namespace IO.Swagger.Model {
|
||||
[DataContract]
|
||||
public class User {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Username
|
||||
/// </summary>
|
||||
[DataMember(Name="username", EmitDefaultValue=false)]
|
||||
public string Username { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets FirstName
|
||||
/// </summary>
|
||||
[DataMember(Name="firstName", EmitDefaultValue=false)]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets LastName
|
||||
/// </summary>
|
||||
[DataMember(Name="lastName", EmitDefaultValue=false)]
|
||||
public string LastName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Email
|
||||
/// </summary>
|
||||
[DataMember(Name="email", EmitDefaultValue=false)]
|
||||
public string Email { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Password
|
||||
/// </summary>
|
||||
[DataMember(Name="password", EmitDefaultValue=false)]
|
||||
public string Password { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Phone
|
||||
/// </summary>
|
||||
[DataMember(Name="phone", EmitDefaultValue=false)]
|
||||
public string Phone { get; set; }
|
||||
|
||||
|
||||
/* User Status */
|
||||
/// <summary>
|
||||
/// User Status
|
||||
/// </summary>
|
||||
/// <value>User Status</value>
|
||||
[DataMember(Name="userStatus", EmitDefaultValue=false)]
|
||||
public int? UserStatus { get; set; }
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
||||
<Files>
|
||||
<File FileName="TestPet.cs" Line="31" Column="19" />
|
||||
<File FileName="TestPet.cs" Line="28" Column="64" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user