[C#][aspnetcore] Improve generated code (#5257)

* Migrate from Swashbuckle to Swashbuckle.AspNetCore

* Fix typo

* Add SwaggerResponse for all responses

* Remove model constructor

* Add required attribute if available

* Improve whitespace and remove some redundant code

* Remove redundant code from Dockerfile

* Add disable warning 1591 pragma for model utility methods for bringing down compiler warnings to zero

* Add proper model state validation before controller is called

* Regenerate AspNetCore PetStore sample
This commit is contained in:
Sebastian Mandrean 2017-03-30 16:58:25 +02:00 committed by wing328
parent c9182ba00f
commit 7cc20cbeba
28 changed files with 525 additions and 592 deletions

View File

@ -35,7 +35,7 @@ public class CodegenOperation {
public ExternalDocs externalDocs; public ExternalDocs externalDocs;
public Map<String, Object> vendorExtensions; public Map<String, Object> vendorExtensions;
public String nickname; // legacy support public String nickname; // legacy support
public String operationIdLowerCase; // for mardown documentation public String operationIdLowerCase; // for markdown documentation
public String operationIdCamelCase; // for class names public String operationIdCamelCase; // for class names
/** /**

View File

@ -114,6 +114,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("project.json.mustache", packageFolder, "project.json")); supportingFiles.add(new SupportingFile("project.json.mustache", packageFolder, "project.json"));
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs")); supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs")); supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs"));
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config")); supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));
supportingFiles.add(new SupportingFile("Project.xproj.mustache", packageFolder, this.packageName + ".xproj")); supportingFiles.add(new SupportingFile("Project.xproj.mustache", packageFolder, this.packageName + ".xproj"));

View File

@ -2,9 +2,8 @@ FROM microsoft/dotnet:1.0.3-sdk-projectjson
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
RUN mkdir -p /app/{{packageName}}
COPY . /app/{{packageName}}
WORKDIR /app/{{packageName}} WORKDIR /app/{{packageName}}
COPY . /app/{{packageName}}
EXPOSE 5000/tcp EXPOSE 5000/tcp

View File

@ -1,15 +1,17 @@
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
namespace {{packageName}} namespace {{packageName}}
{ {
/// <summary>
/// Program
/// </summary>
public class Program public class Program
{ {
/// <summary>
/// Main
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args) public static void Main(string[] args)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()

View File

@ -11,7 +11,7 @@
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger/ui/index.html", "launchUrl": "swagger/",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
@ -19,7 +19,7 @@
"web": { "web": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "http://localhost:5000/swagger/ui/index.html", "launchUrl": "http://localhost:5000/swagger/",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -1,27 +1,31 @@
{{>partial_header}} {{>partial_header}}
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.XPath;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Swashbuckle.Swagger.Model; using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.SwaggerGen.Annotations; using Swashbuckle.AspNetCore.SwaggerGen;
namespace {{packageName}} namespace {{packageName}}
{ {
/// <summary>
/// Startup
/// </summary>
public class Startup public class Startup
{ {
private readonly IHostingEnvironment _hostingEnv; private readonly IHostingEnvironment _hostingEnv;
public IConfigurationRoot Configuration { get; } private IConfigurationRoot Configuration { get; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="env"></param>
public Startup(IHostingEnvironment env) public Startup(IHostingEnvironment env)
{ {
_hostingEnv = env; _hostingEnv = env;
@ -34,48 +38,59 @@ namespace {{packageName}}
Configuration = builder.Build(); Configuration = builder.Build();
} }
/// <summary>
// This method gets called by the runtime. Use this method to add services to the container. /// This method gets called by the runtime. Use this method to add services to the container.
/// </summary>
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// Add framework services. // Add framework services.
services.AddMvc() services
.AddJsonOptions( .AddMvc()
opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); .AddJsonOptions(opts =>
services.AddSwaggerGen();
services.ConfigureSwaggerGen(options =>
{ {
options.SingleApiVersion(new Info opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
opts.SerializerSettings.Converters.Add(new StringEnumConverter {
CamelCaseText = true
});
});
services
.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
{ {
Version = "v1", Version = "v1",
Title = "{{packageName}}", Title = "{{packageName}}",
Description = "{{packageName}} (ASP.NET Core 1.0)" Description = "{{packageName}} (ASP.NET Core 1.0)"
}); });
c.CustomSchemaIds(type => type.FriendlyId(true));
options.DescribeAllEnumsAsStrings(); c.DescribeAllEnumsAsStrings();
c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
var comments = new XPathDocument($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
options.OperationFilter<XmlCommentsOperationFilter>(comments);
options.ModelFilter<XmlCommentsModelFilter>(comments);
}); });
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
/// <param name="loggerFactory"></param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory
loggerFactory.AddDebug(); .AddConsole(Configuration.GetSection("Logging"))
.AddDebug();
app.UseMvc(); app
.UseMvc()
app.UseDefaultFiles(); .UseDefaultFiles()
app.UseStaticFiles(); .UseStaticFiles()
.UseSwagger()
app.UseSwagger(); .UseSwaggerUI(c =>
app.UseSwaggerUi(); {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "{{packageName}}");
});
} }
} }
} }

View File

@ -1,15 +1,17 @@
{{>partial_header}} {{>partial_header}}
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json; using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations; using {{packageName}}.Attributes;
using {{packageName}}.Models; using {{packageName}}.Models;
namespace {{packageName}}.Controllers namespace {{packageName}}.Controllers
@ -20,7 +22,6 @@ namespace {{packageName}}.Controllers
[Description("{{description}}")]{{/description}} [Description("{{description}}")]{{/description}}
public class {{classname}}Controller : Controller public class {{classname}}Controller : Controller
{ {{#operation}} { {{#operation}}
/// <summary> /// <summary>
/// {{#summary}}{{summary}}{{/summary}} /// {{#summary}}{{summary}}{{/summary}}
/// </summary> /// </summary>
@ -29,8 +30,9 @@ namespace {{packageName}}.Controllers
/// <response code="{{code}}">{{message}}</response>{{/responses}} /// <response code="{{code}}">{{message}}</response>{{/responses}}
[{{httpMethod}}] [{{httpMethod}}]
[Route("{{{basePathWithoutHost}}}{{{path}}}")] [Route("{{{basePathWithoutHost}}}{{{path}}}")]
[SwaggerOperation("{{operationId}}")]{{#returnType}} [ValidateModelState]
[SwaggerResponse(200, type: typeof({{&returnType}}))]{{/returnType}} [SwaggerOperation("{{operationId}}")]{{#responses}}{{#returnType}}
[SwaggerResponse({{code}}, typeof({{&returnType}}), "{{message}}")]{{/returnType}}{{/responses}}
public virtual {{#returnType}}IActionResult{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) public virtual {{#returnType}}IActionResult{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{ {{#returnType}} { {{#returnType}}
string exampleJson = null; string exampleJson = null;
@ -39,7 +41,7 @@ namespace {{packageName}}.Controllers
return new ObjectResult(example);{{/returnType}}{{^returnType}} return new ObjectResult(example);{{/returnType}}{{^returnType}}
throw new NotImplementedException();{{/returnType}} throw new NotImplementedException();{{/returnType}}
} }
{{/operation}} {{/operation}}
} }
{{/operations}} {{/operations}}
} }

View File

@ -3,8 +3,7 @@
/// </summary>{{#description}} /// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}} /// <value>{{{description}}}</value>{{/description}}
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
{ { {{#allowableValues}}{{#enumVars}}
{{#allowableValues}}{{#enumVars}}
/// <summary> /// <summary>
/// Enum {{name}} for {{{value}}} /// Enum {{name}} for {{{value}}}
/// </summary> /// </summary>

View File

@ -6,79 +6,36 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
{{#models}} {{#models}}
{{#model}} {{#model}}
namespace {{packageName}}.Models namespace {{packageName}}.Models
{ { {{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
{{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
/// <summary> /// <summary>
/// {{description}} /// {{description}}
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}> public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}}IEquatable<{{classname}}>
{ { {{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}{{>enumClass}}{{/items}}{{/items.isEnum}}
{{#vars}}
{{#isEnum}}
{{>enumClass}}
{{/isEnum}}
{{#items.isEnum}}
{{#items}}
{{>enumClass}}
{{/items}}
{{/items.isEnum}}
{{/vars}}
{{#vars}}
{{#isEnum}}
/// <summary> /// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}} /// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}} /// <value>{{{description}}}</value>{{/description}}
{{#required}}
[Required]
{{/required}}
[DataMember(Name="{{baseName}}")] [DataMember(Name="{{baseName}}")]
{{#isEnum}}
public {{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}} {{name}} { get; set; } public {{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}} {{name}} { get; set; }
{{/isEnum}} {{/isEnum}}
{{/vars}}
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary>
{{#vars}} /// <param name="{{name}}">{{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}.</param>
{{/vars}}
public {{classname}}({{#readWriteVars}}{{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}} {{name}} = {{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}default({{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}}){{/defaultValue}}{{^-last}}, {{/-last}}{{/readWriteVars}})
{
{{#vars}}{{#required}}// to ensure "{{name}}" is required (not null)
if ({{name}} == null)
{
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
}
else
{
this.{{name}} = {{name}};
}
{{/required}}{{/vars}}{{#vars}}{{^required}}{{#defaultValue}}// use default value if no "{{name}}" provided
if ({{name}} == null)
{
this.{{name}} = {{{defaultValue}}};
}
else
{
this.{{name}} = {{name}};
}
{{/defaultValue}}{{^defaultValue}}this.{{name}} = {{name}};
{{/defaultValue}}{{/required}}{{/vars}}
}
{{#vars}}
{{^isEnum}} {{^isEnum}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>{{#description}}
/// <value>{{description}}</value>{{/description}}
[DataMember(Name="{{baseName}}")]
public {{{datatype}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; } public {{{datatype}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
{{/isEnum}} {{/isEnum}}
{{#hasMore}}
{{/hasMore}}
{{/vars}} {{/vars}}
/// <summary> /// <summary>
@ -114,8 +71,7 @@ namespace {{packageName}}.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals(({{classname}})obj);
return Equals(({{classname}})obj);
} }
/// <summary> /// <summary>
@ -125,20 +81,19 @@ namespace {{packageName}}.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals({{classname}} other) public bool Equals({{classname}} other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return {{#vars}}{{#isNotContainer}} return {{#vars}}{{#isNotContainer}}
( (
this.{{name}} == other.{{name}} || {{name}} == other.{{name}} ||
this.{{name}} != null && {{name}} != null &&
this.{{name}}.Equals(other.{{name}}) {{name}}.Equals(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}} ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
( (
this.{{name}} == other.{{name}} || {{name}} == other.{{name}} ||
this.{{name}} != null && {{name}} != null &&
this.{{name}}.SequenceEqual(other.{{name}}) {{name}}.SequenceEqual(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}}; ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
} }
@ -151,17 +106,18 @@ namespace {{packageName}}.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
{{#vars}} {{#vars}}
if (this.{{name}} != null) if ({{name}} != null)
hash = hash * 59 + this.{{name}}.GetHashCode(); hash = hash * 59 + {{name}}.GetHashCode();
{{/vars}} {{/vars}}
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==({{classname}} left, {{classname}} right) public static bool operator ==({{classname}} left, {{classname}} right)
{ {
@ -173,8 +129,8 @@ namespace {{packageName}}.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
{{/isEnum}} {{/isEnum}}
{{/model}} {{/model}}

View File

@ -21,8 +21,7 @@
"Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.0.0", "Microsoft.EntityFrameworkCore": "1.0.0",
"Swashbuckle.SwaggerGen": "6.0.0-beta901", "Swashbuckle.AspNetCore": "1.0.0-rc3",
"Swashbuckle.SwaggerUi": "6.0.0-beta901",
"Newtonsoft.Json": "9.0.1" "Newtonsoft.Json": "9.0.1"
}, },

View File

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace {{packageName}}.Attributes
{
/// <summary>
/// Model state validation attribute
/// </summary>
public class ValidateModelStateAttribute : ActionFilterAttribute
{
/// <summary>
/// Called before the action method is invoked
/// </summary>
/// <param name="context"></param>
public override void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
context.Result = new BadRequestObjectResult(context.ModelState);
}
}
}
}

View File

@ -1 +1 @@
<meta http-equiv="refresh" content="0;URL='./swagger/ui/index.html'" /> <meta http-equiv="refresh" content="0;URL='./swagger/'" />

View File

@ -0,0 +1,23 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace IO.Swagger.Attributes
{
/// <summary>
/// Model state validation attribute
/// </summary>
public class ValidateModelStateAttribute : ActionFilterAttribute
{
/// <summary>
/// Called before the action method is invoked.
/// </summary>
/// <param name="context"></param>
public override void OnActionExecuting(ActionExecutingContext context)
{
if (!context.ModelState.IsValid)
{
context.Result = new BadRequestObjectResult(context.ModelState);
}
}
}
}

View File

@ -10,15 +10,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json; using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations; using IO.Swagger.Attributes;
using IO.Swagger.Models; using IO.Swagger.Models;
namespace IO.Swagger.Controllers namespace IO.Swagger.Controllers
@ -28,7 +30,6 @@ namespace IO.Swagger.Controllers
/// </summary> /// </summary>
public class PetApiController : Controller public class PetApiController : Controller
{ {
/// <summary> /// <summary>
/// Add a new pet to the store /// Add a new pet to the store
/// </summary> /// </summary>
@ -37,13 +38,13 @@ namespace IO.Swagger.Controllers
/// <response code="405">Invalid input</response> /// <response code="405">Invalid input</response>
[HttpPost] [HttpPost]
[Route("/v2/pet")] [Route("/v2/pet")]
[ValidateModelState]
[SwaggerOperation("AddPet")] [SwaggerOperation("AddPet")]
public virtual void AddPet([FromBody]Pet body) public virtual void AddPet([FromBody]Pet body)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Deletes a pet /// Deletes a pet
/// </summary> /// </summary>
@ -53,13 +54,13 @@ namespace IO.Swagger.Controllers
/// <response code="400">Invalid pet value</response> /// <response code="400">Invalid pet value</response>
[HttpDelete] [HttpDelete]
[Route("/v2/pet/{petId}")] [Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("DeletePet")] [SwaggerOperation("DeletePet")]
public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey) public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Finds Pets by status /// Finds Pets by status
/// </summary> /// </summary>
@ -69,8 +70,10 @@ namespace IO.Swagger.Controllers
/// <response code="400">Invalid status value</response> /// <response code="400">Invalid status value</response>
[HttpGet] [HttpGet]
[Route("/v2/pet/findByStatus")] [Route("/v2/pet/findByStatus")]
[ValidateModelState]
[SwaggerOperation("FindPetsByStatus")] [SwaggerOperation("FindPetsByStatus")]
[SwaggerResponse(200, type: typeof(List<Pet>))] [SwaggerResponse(200, typeof(List<Pet>), "successful operation")]
[SwaggerResponse(400, typeof(List<Pet>), "Invalid status value")]
public virtual IActionResult FindPetsByStatus([FromQuery]List<string> status) public virtual IActionResult FindPetsByStatus([FromQuery]List<string> status)
{ {
string exampleJson = null; string exampleJson = null;
@ -81,7 +84,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Finds Pets by tags /// Finds Pets by tags
/// </summary> /// </summary>
@ -91,8 +93,10 @@ namespace IO.Swagger.Controllers
/// <response code="400">Invalid tag value</response> /// <response code="400">Invalid tag value</response>
[HttpGet] [HttpGet]
[Route("/v2/pet/findByTags")] [Route("/v2/pet/findByTags")]
[ValidateModelState]
[SwaggerOperation("FindPetsByTags")] [SwaggerOperation("FindPetsByTags")]
[SwaggerResponse(200, type: typeof(List<Pet>))] [SwaggerResponse(200, typeof(List<Pet>), "successful operation")]
[SwaggerResponse(400, typeof(List<Pet>), "Invalid tag value")]
public virtual IActionResult FindPetsByTags([FromQuery]List<string> tags) public virtual IActionResult FindPetsByTags([FromQuery]List<string> tags)
{ {
string exampleJson = null; string exampleJson = null;
@ -103,7 +107,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Find pet by ID /// Find pet by ID
/// </summary> /// </summary>
@ -114,8 +117,11 @@ namespace IO.Swagger.Controllers
/// <response code="404">Pet not found</response> /// <response code="404">Pet not found</response>
[HttpGet] [HttpGet]
[Route("/v2/pet/{petId}")] [Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("GetPetById")] [SwaggerOperation("GetPetById")]
[SwaggerResponse(200, type: typeof(Pet))] [SwaggerResponse(200, typeof(Pet), "successful operation")]
[SwaggerResponse(400, typeof(Pet), "Invalid ID supplied")]
[SwaggerResponse(404, typeof(Pet), "Pet not found")]
public virtual IActionResult GetPetById([FromRoute]long? petId) public virtual IActionResult GetPetById([FromRoute]long? petId)
{ {
string exampleJson = null; string exampleJson = null;
@ -126,7 +132,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Update an existing pet /// Update an existing pet
/// </summary> /// </summary>
@ -137,13 +142,13 @@ namespace IO.Swagger.Controllers
/// <response code="405">Validation exception</response> /// <response code="405">Validation exception</response>
[HttpPut] [HttpPut]
[Route("/v2/pet")] [Route("/v2/pet")]
[ValidateModelState]
[SwaggerOperation("UpdatePet")] [SwaggerOperation("UpdatePet")]
public virtual void UpdatePet([FromBody]Pet body) public virtual void UpdatePet([FromBody]Pet body)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Updates a pet in the store with form data /// Updates a pet in the store with form data
/// </summary> /// </summary>
@ -154,13 +159,13 @@ namespace IO.Swagger.Controllers
/// <response code="405">Invalid input</response> /// <response code="405">Invalid input</response>
[HttpPost] [HttpPost]
[Route("/v2/pet/{petId}")] [Route("/v2/pet/{petId}")]
[ValidateModelState]
[SwaggerOperation("UpdatePetWithForm")] [SwaggerOperation("UpdatePetWithForm")]
public virtual void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status) public virtual void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// uploads an image /// uploads an image
/// </summary> /// </summary>
@ -171,8 +176,9 @@ namespace IO.Swagger.Controllers
/// <response code="200">successful operation</response> /// <response code="200">successful operation</response>
[HttpPost] [HttpPost]
[Route("/v2/pet/{petId}/uploadImage")] [Route("/v2/pet/{petId}/uploadImage")]
[ValidateModelState]
[SwaggerOperation("UploadFile")] [SwaggerOperation("UploadFile")]
[SwaggerResponse(200, type: typeof(ApiResponse))] [SwaggerResponse(200, typeof(ApiResponse), "successful operation")]
public virtual IActionResult UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file) public virtual IActionResult UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]System.IO.Stream file)
{ {
string exampleJson = null; string exampleJson = null;

View File

@ -10,15 +10,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json; using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations; using IO.Swagger.Attributes;
using IO.Swagger.Models; using IO.Swagger.Models;
namespace IO.Swagger.Controllers namespace IO.Swagger.Controllers
@ -28,7 +30,6 @@ namespace IO.Swagger.Controllers
/// </summary> /// </summary>
public class StoreApiController : Controller public class StoreApiController : Controller
{ {
/// <summary> /// <summary>
/// Delete purchase order by ID /// Delete purchase order by ID
/// </summary> /// </summary>
@ -38,13 +39,13 @@ namespace IO.Swagger.Controllers
/// <response code="404">Order not found</response> /// <response code="404">Order not found</response>
[HttpDelete] [HttpDelete]
[Route("/v2/store/order/{orderId}")] [Route("/v2/store/order/{orderId}")]
[ValidateModelState]
[SwaggerOperation("DeleteOrder")] [SwaggerOperation("DeleteOrder")]
public virtual void DeleteOrder([FromRoute]string orderId) public virtual void DeleteOrder([FromRoute]string orderId)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Returns pet inventories by status /// Returns pet inventories by status
/// </summary> /// </summary>
@ -52,8 +53,9 @@ namespace IO.Swagger.Controllers
/// <response code="200">successful operation</response> /// <response code="200">successful operation</response>
[HttpGet] [HttpGet]
[Route("/v2/store/inventory")] [Route("/v2/store/inventory")]
[ValidateModelState]
[SwaggerOperation("GetInventory")] [SwaggerOperation("GetInventory")]
[SwaggerResponse(200, type: typeof(Dictionary<string, int?>))] [SwaggerResponse(200, typeof(Dictionary<string, int?>), "successful operation")]
public virtual IActionResult GetInventory() public virtual IActionResult GetInventory()
{ {
string exampleJson = null; string exampleJson = null;
@ -64,7 +66,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Find purchase order by ID /// Find purchase order by ID
/// </summary> /// </summary>
@ -75,8 +76,11 @@ namespace IO.Swagger.Controllers
/// <response code="404">Order not found</response> /// <response code="404">Order not found</response>
[HttpGet] [HttpGet]
[Route("/v2/store/order/{orderId}")] [Route("/v2/store/order/{orderId}")]
[ValidateModelState]
[SwaggerOperation("GetOrderById")] [SwaggerOperation("GetOrderById")]
[SwaggerResponse(200, type: typeof(Order))] [SwaggerResponse(200, typeof(Order), "successful operation")]
[SwaggerResponse(400, typeof(Order), "Invalid ID supplied")]
[SwaggerResponse(404, typeof(Order), "Order not found")]
public virtual IActionResult GetOrderById([FromRoute]long? orderId) public virtual IActionResult GetOrderById([FromRoute]long? orderId)
{ {
string exampleJson = null; string exampleJson = null;
@ -87,7 +91,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Place an order for a pet /// Place an order for a pet
/// </summary> /// </summary>
@ -97,8 +100,10 @@ namespace IO.Swagger.Controllers
/// <response code="400">Invalid Order</response> /// <response code="400">Invalid Order</response>
[HttpPost] [HttpPost]
[Route("/v2/store/order")] [Route("/v2/store/order")]
[ValidateModelState]
[SwaggerOperation("PlaceOrder")] [SwaggerOperation("PlaceOrder")]
[SwaggerResponse(200, type: typeof(Order))] [SwaggerResponse(200, typeof(Order), "successful operation")]
[SwaggerResponse(400, typeof(Order), "Invalid Order")]
public virtual IActionResult PlaceOrder([FromBody]Order body) public virtual IActionResult PlaceOrder([FromBody]Order body)
{ {
string exampleJson = null; string exampleJson = null;

View File

@ -10,15 +10,17 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Swashbuckle.AspNetCore.SwaggerGen;
using Newtonsoft.Json; using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations; using IO.Swagger.Attributes;
using IO.Swagger.Models; using IO.Swagger.Models;
namespace IO.Swagger.Controllers namespace IO.Swagger.Controllers
@ -28,7 +30,6 @@ namespace IO.Swagger.Controllers
/// </summary> /// </summary>
public class UserApiController : Controller public class UserApiController : Controller
{ {
/// <summary> /// <summary>
/// Create user /// Create user
/// </summary> /// </summary>
@ -37,13 +38,13 @@ namespace IO.Swagger.Controllers
/// <response code="0">successful operation</response> /// <response code="0">successful operation</response>
[HttpPost] [HttpPost]
[Route("/v2/user")] [Route("/v2/user")]
[ValidateModelState]
[SwaggerOperation("CreateUser")] [SwaggerOperation("CreateUser")]
public virtual void CreateUser([FromBody]User body) public virtual void CreateUser([FromBody]User body)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Creates list of users with given input array /// Creates list of users with given input array
/// </summary> /// </summary>
@ -52,13 +53,13 @@ namespace IO.Swagger.Controllers
/// <response code="0">successful operation</response> /// <response code="0">successful operation</response>
[HttpPost] [HttpPost]
[Route("/v2/user/createWithArray")] [Route("/v2/user/createWithArray")]
[ValidateModelState]
[SwaggerOperation("CreateUsersWithArrayInput")] [SwaggerOperation("CreateUsersWithArrayInput")]
public virtual void CreateUsersWithArrayInput([FromBody]List<User> body) public virtual void CreateUsersWithArrayInput([FromBody]List<User> body)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Creates list of users with given input array /// Creates list of users with given input array
/// </summary> /// </summary>
@ -67,13 +68,13 @@ namespace IO.Swagger.Controllers
/// <response code="0">successful operation</response> /// <response code="0">successful operation</response>
[HttpPost] [HttpPost]
[Route("/v2/user/createWithList")] [Route("/v2/user/createWithList")]
[ValidateModelState]
[SwaggerOperation("CreateUsersWithListInput")] [SwaggerOperation("CreateUsersWithListInput")]
public virtual void CreateUsersWithListInput([FromBody]List<User> body) public virtual void CreateUsersWithListInput([FromBody]List<User> body)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Delete user /// Delete user
/// </summary> /// </summary>
@ -83,13 +84,13 @@ namespace IO.Swagger.Controllers
/// <response code="404">User not found</response> /// <response code="404">User not found</response>
[HttpDelete] [HttpDelete]
[Route("/v2/user/{username}")] [Route("/v2/user/{username}")]
[ValidateModelState]
[SwaggerOperation("DeleteUser")] [SwaggerOperation("DeleteUser")]
public virtual void DeleteUser([FromRoute]string username) public virtual void DeleteUser([FromRoute]string username)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Get user by user name /// Get user by user name
/// </summary> /// </summary>
@ -100,8 +101,11 @@ namespace IO.Swagger.Controllers
/// <response code="404">User not found</response> /// <response code="404">User not found</response>
[HttpGet] [HttpGet]
[Route("/v2/user/{username}")] [Route("/v2/user/{username}")]
[ValidateModelState]
[SwaggerOperation("GetUserByName")] [SwaggerOperation("GetUserByName")]
[SwaggerResponse(200, type: typeof(User))] [SwaggerResponse(200, typeof(User), "successful operation")]
[SwaggerResponse(400, typeof(User), "Invalid username supplied")]
[SwaggerResponse(404, typeof(User), "User not found")]
public virtual IActionResult GetUserByName([FromRoute]string username) public virtual IActionResult GetUserByName([FromRoute]string username)
{ {
string exampleJson = null; string exampleJson = null;
@ -112,7 +116,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Logs user into the system /// Logs user into the system
/// </summary> /// </summary>
@ -123,8 +126,10 @@ namespace IO.Swagger.Controllers
/// <response code="400">Invalid username/password supplied</response> /// <response code="400">Invalid username/password supplied</response>
[HttpGet] [HttpGet]
[Route("/v2/user/login")] [Route("/v2/user/login")]
[ValidateModelState]
[SwaggerOperation("LoginUser")] [SwaggerOperation("LoginUser")]
[SwaggerResponse(200, type: typeof(string))] [SwaggerResponse(200, typeof(string), "successful operation")]
[SwaggerResponse(400, typeof(string), "Invalid username/password supplied")]
public virtual IActionResult LoginUser([FromQuery]string username, [FromQuery]string password) public virtual IActionResult LoginUser([FromQuery]string username, [FromQuery]string password)
{ {
string exampleJson = null; string exampleJson = null;
@ -135,7 +140,6 @@ namespace IO.Swagger.Controllers
return new ObjectResult(example); return new ObjectResult(example);
} }
/// <summary> /// <summary>
/// Logs out current logged in user session /// Logs out current logged in user session
/// </summary> /// </summary>
@ -143,13 +147,13 @@ namespace IO.Swagger.Controllers
/// <response code="0">successful operation</response> /// <response code="0">successful operation</response>
[HttpGet] [HttpGet]
[Route("/v2/user/logout")] [Route("/v2/user/logout")]
[ValidateModelState]
[SwaggerOperation("LogoutUser")] [SwaggerOperation("LogoutUser")]
public virtual void LogoutUser() public virtual void LogoutUser()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
/// <summary> /// <summary>
/// Updated user /// Updated user
/// </summary> /// </summary>
@ -160,6 +164,7 @@ namespace IO.Swagger.Controllers
/// <response code="404">User not found</response> /// <response code="404">User not found</response>
[HttpPut] [HttpPut]
[Route("/v2/user/{username}")] [Route("/v2/user/{username}")]
[ValidateModelState]
[SwaggerOperation("UpdateUser")] [SwaggerOperation("UpdateUser")]
public virtual void UpdateUser([FromRoute]string username, [FromBody]User body) public virtual void UpdateUser([FromRoute]string username, [FromBody]User body)
{ {

View File

@ -2,9 +2,8 @@ FROM microsoft/dotnet:1.0.3-sdk-projectjson
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1 ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
RUN mkdir -p /app/IO.Swagger
COPY . /app/IO.Swagger
WORKDIR /app/IO.Swagger WORKDIR /app/IO.Swagger
COPY . /app/IO.Swagger
EXPOSE 5000/tcp EXPOSE 5000/tcp

View File

@ -15,43 +15,30 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace IO.Swagger.Models namespace IO.Swagger.Models
{ {
/// <summary> /// <summary>
/// Describes the result of uploading an image resource /// Describes the result of uploading an image resource
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class ApiResponse : IEquatable<ApiResponse> public partial class ApiResponse : IEquatable<ApiResponse>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="ApiResponse" /> class.
/// </summary>
/// <param name="Code">Code.</param>
/// <param name="Type">Type.</param>
/// <param name="Message">Message.</param>
public ApiResponse(int? Code = default(int?), string Type = default(string), string Message = default(string))
{
this.Code = Code;
this.Type = Type;
this.Message = Message;
}
/// <summary> /// <summary>
/// Gets or Sets Code /// Gets or Sets Code
/// </summary> /// </summary>
[DataMember(Name="code")] [DataMember(Name="code")]
public int? Code { get; set; } public int? Code { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Type /// Gets or Sets Type
/// </summary> /// </summary>
[DataMember(Name="type")] [DataMember(Name="type")]
public string Type { get; set; } public string Type { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Message /// Gets or Sets Message
/// </summary> /// </summary>
@ -91,8 +78,7 @@ namespace IO.Swagger.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals((ApiResponse)obj);
return Equals((ApiResponse)obj);
} }
/// <summary> /// <summary>
@ -102,25 +88,24 @@ namespace IO.Swagger.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals(ApiResponse other) public bool Equals(ApiResponse other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return return
( (
this.Code == other.Code || Code == other.Code ||
this.Code != null && Code != null &&
this.Code.Equals(other.Code) Code.Equals(other.Code)
) && ) &&
( (
this.Type == other.Type || Type == other.Type ||
this.Type != null && Type != null &&
this.Type.Equals(other.Type) Type.Equals(other.Type)
) && ) &&
( (
this.Message == other.Message || Message == other.Message ||
this.Message != null && Message != null &&
this.Message.Equals(other.Message) Message.Equals(other.Message)
); );
} }
@ -133,19 +118,20 @@ namespace IO.Swagger.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
if (this.Code != null) if (Code != null)
hash = hash * 59 + this.Code.GetHashCode(); hash = hash * 59 + Code.GetHashCode();
if (this.Type != null) if (Type != null)
hash = hash * 59 + this.Type.GetHashCode(); hash = hash * 59 + Type.GetHashCode();
if (this.Message != null) if (Message != null)
hash = hash * 59 + this.Message.GetHashCode(); hash = hash * 59 + Message.GetHashCode();
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==(ApiResponse left, ApiResponse right) public static bool operator ==(ApiResponse left, ApiResponse right)
{ {
@ -157,7 +143,7 @@ namespace IO.Swagger.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
} }

View File

@ -15,36 +15,24 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace IO.Swagger.Models namespace IO.Swagger.Models
{ {
/// <summary> /// <summary>
/// A category for a pet /// A category for a pet
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class Category : IEquatable<Category> public partial class Category : IEquatable<Category>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="Category" /> class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Name">Name.</param>
public Category(long? Id = default(long?), string Name = default(string))
{
this.Id = Id;
this.Name = Name;
}
/// <summary> /// <summary>
/// Gets or Sets Id /// Gets or Sets Id
/// </summary> /// </summary>
[DataMember(Name="id")] [DataMember(Name="id")]
public long? Id { get; set; } public long? Id { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Name /// Gets or Sets Name
/// </summary> /// </summary>
@ -83,8 +71,7 @@ namespace IO.Swagger.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals((Category)obj);
return Equals((Category)obj);
} }
/// <summary> /// <summary>
@ -94,20 +81,19 @@ namespace IO.Swagger.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals(Category other) public bool Equals(Category other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return return
( (
this.Id == other.Id || Id == other.Id ||
this.Id != null && Id != null &&
this.Id.Equals(other.Id) Id.Equals(other.Id)
) && ) &&
( (
this.Name == other.Name || Name == other.Name ||
this.Name != null && Name != null &&
this.Name.Equals(other.Name) Name.Equals(other.Name)
); );
} }
@ -120,17 +106,18 @@ namespace IO.Swagger.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
if (this.Id != null) if (Id != null)
hash = hash * 59 + this.Id.GetHashCode(); hash = hash * 59 + Id.GetHashCode();
if (this.Name != null) if (Name != null)
hash = hash * 59 + this.Name.GetHashCode(); hash = hash * 59 + Name.GetHashCode();
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==(Category left, Category right) public static bool operator ==(Category left, Category right)
{ {
@ -142,7 +129,7 @@ namespace IO.Swagger.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
} }

View File

@ -15,25 +15,47 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace IO.Swagger.Models namespace IO.Swagger.Models
{ {
/// <summary> /// <summary>
/// An order for a pets from the pet store /// An order for a pets from the pet store
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class Order : IEquatable<Order> public partial class Order : IEquatable<Order>
{ {
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id")]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
[DataMember(Name="petId")]
public long? PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
[DataMember(Name="quantity")]
public int? Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
[DataMember(Name="shipDate")]
public DateTime? ShipDate { get; set; }
/// <summary> /// <summary>
/// Order Status /// Order Status
/// </summary> /// </summary>
/// <value>Order Status</value> /// <value>Order Status</value>
public enum StatusEnum public enum StatusEnum
{ {
/// <summary> /// <summary>
/// Enum PlacedEnum for "placed" /// Enum PlacedEnum for "placed"
/// </summary> /// </summary>
@ -52,6 +74,7 @@ namespace IO.Swagger.Models
[EnumMember(Value = "delivered")] [EnumMember(Value = "delivered")]
DeliveredEnum DeliveredEnum
} }
/// <summary> /// <summary>
/// Order Status /// Order Status
/// </summary> /// </summary>
@ -59,54 +82,6 @@ namespace IO.Swagger.Models
[DataMember(Name="status")] [DataMember(Name="status")]
public StatusEnum? Status { get; set; } public StatusEnum? Status { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Order" /> class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="PetId">PetId.</param>
/// <param name="Quantity">Quantity.</param>
/// <param name="ShipDate">ShipDate.</param>
/// <param name="Status">Order Status.</param>
/// <param name="Complete">Complete (default to false).</param>
public Order(long? Id = default(long?), long? PetId = default(long?), int? Quantity = default(int?), DateTime? ShipDate = default(DateTime?), StatusEnum? Status = default(StatusEnum?), bool? Complete = false)
{
this.Id = Id;
this.PetId = PetId;
this.Quantity = Quantity;
this.ShipDate = ShipDate;
this.Status = Status;
// use default value if no "Complete" provided
if (Complete == null)
{
this.Complete = false;
}
else
{
this.Complete = Complete;
}
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id")]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
[DataMember(Name="petId")]
public long? PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
[DataMember(Name="quantity")]
public int? Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
[DataMember(Name="shipDate")]
public DateTime? ShipDate { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Complete /// Gets or Sets Complete
/// </summary> /// </summary>
@ -149,8 +124,7 @@ namespace IO.Swagger.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals((Order)obj);
return Equals((Order)obj);
} }
/// <summary> /// <summary>
@ -160,40 +134,39 @@ namespace IO.Swagger.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals(Order other) public bool Equals(Order other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return return
( (
this.Id == other.Id || Id == other.Id ||
this.Id != null && Id != null &&
this.Id.Equals(other.Id) Id.Equals(other.Id)
) && ) &&
( (
this.PetId == other.PetId || PetId == other.PetId ||
this.PetId != null && PetId != null &&
this.PetId.Equals(other.PetId) PetId.Equals(other.PetId)
) && ) &&
( (
this.Quantity == other.Quantity || Quantity == other.Quantity ||
this.Quantity != null && Quantity != null &&
this.Quantity.Equals(other.Quantity) Quantity.Equals(other.Quantity)
) && ) &&
( (
this.ShipDate == other.ShipDate || ShipDate == other.ShipDate ||
this.ShipDate != null && ShipDate != null &&
this.ShipDate.Equals(other.ShipDate) ShipDate.Equals(other.ShipDate)
) && ) &&
( (
this.Status == other.Status || Status == other.Status ||
this.Status != null && Status != null &&
this.Status.Equals(other.Status) Status.Equals(other.Status)
) && ) &&
( (
this.Complete == other.Complete || Complete == other.Complete ||
this.Complete != null && Complete != null &&
this.Complete.Equals(other.Complete) Complete.Equals(other.Complete)
); );
} }
@ -206,25 +179,26 @@ namespace IO.Swagger.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
if (this.Id != null) if (Id != null)
hash = hash * 59 + this.Id.GetHashCode(); hash = hash * 59 + Id.GetHashCode();
if (this.PetId != null) if (PetId != null)
hash = hash * 59 + this.PetId.GetHashCode(); hash = hash * 59 + PetId.GetHashCode();
if (this.Quantity != null) if (Quantity != null)
hash = hash * 59 + this.Quantity.GetHashCode(); hash = hash * 59 + Quantity.GetHashCode();
if (this.ShipDate != null) if (ShipDate != null)
hash = hash * 59 + this.ShipDate.GetHashCode(); hash = hash * 59 + ShipDate.GetHashCode();
if (this.Status != null) if (Status != null)
hash = hash * 59 + this.Status.GetHashCode(); hash = hash * 59 + Status.GetHashCode();
if (this.Complete != null) if (Complete != null)
hash = hash * 59 + this.Complete.GetHashCode(); hash = hash * 59 + Complete.GetHashCode();
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==(Order left, Order right) public static bool operator ==(Order left, Order right)
{ {
@ -236,7 +210,7 @@ namespace IO.Swagger.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
} }

View File

@ -15,25 +15,55 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace IO.Swagger.Models namespace IO.Swagger.Models
{ {
/// <summary> /// <summary>
/// A pet for sale in the pet store /// A pet for sale in the pet store
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class Pet : IEquatable<Pet> public partial class Pet : IEquatable<Pet>
{ {
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id")]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
[DataMember(Name="category")]
public Category Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[Required]
[DataMember(Name="name")]
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
[Required]
[DataMember(Name="photoUrls")]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Tags
/// </summary>
[DataMember(Name="tags")]
public List<Tag> Tags { get; set; }
/// <summary> /// <summary>
/// pet status in the store /// pet status in the store
/// </summary> /// </summary>
/// <value>pet status in the store</value> /// <value>pet status in the store</value>
public enum StatusEnum public enum StatusEnum
{ {
/// <summary> /// <summary>
/// Enum AvailableEnum for "available" /// Enum AvailableEnum for "available"
/// </summary> /// </summary>
@ -52,6 +82,7 @@ namespace IO.Swagger.Models
[EnumMember(Value = "sold")] [EnumMember(Value = "sold")]
SoldEnum SoldEnum
} }
/// <summary> /// <summary>
/// pet status in the store /// pet status in the store
/// </summary> /// </summary>
@ -59,68 +90,6 @@ namespace IO.Swagger.Models
[DataMember(Name="status")] [DataMember(Name="status")]
public StatusEnum? Status { get; set; } public StatusEnum? Status { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Pet" /> class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Category">Category.</param>
/// <param name="Name">Name (required).</param>
/// <param name="PhotoUrls">PhotoUrls (required).</param>
/// <param name="Tags">Tags.</param>
/// <param name="Status">pet status in the store.</param>
public Pet(long? Id = default(long?), Category Category = default(Category), string Name = default(string), List<string> PhotoUrls = default(List<string>), List<Tag> Tags = default(List<Tag>), StatusEnum? Status = default(StatusEnum?))
{
// to ensure "Name" is required (not null)
if (Name == null)
{
throw new InvalidDataException("Name is a required property for Pet and cannot be null");
}
else
{
this.Name = Name;
}
// to ensure "PhotoUrls" is required (not null)
if (PhotoUrls == null)
{
throw new InvalidDataException("PhotoUrls is a required property for Pet and cannot be null");
}
else
{
this.PhotoUrls = PhotoUrls;
}
this.Id = Id;
this.Category = Category;
this.Tags = Tags;
this.Status = Status;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id")]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
[DataMember(Name="category")]
public Category Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name")]
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
[DataMember(Name="photoUrls")]
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Tags
/// </summary>
[DataMember(Name="tags")]
public List<Tag> Tags { get; set; }
/// <summary> /// <summary>
/// Returns the string presentation of the object /// Returns the string presentation of the object
/// </summary> /// </summary>
@ -157,8 +126,7 @@ namespace IO.Swagger.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals((Pet)obj);
return Equals((Pet)obj);
} }
/// <summary> /// <summary>
@ -168,40 +136,39 @@ namespace IO.Swagger.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals(Pet other) public bool Equals(Pet other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return return
( (
this.Id == other.Id || Id == other.Id ||
this.Id != null && Id != null &&
this.Id.Equals(other.Id) Id.Equals(other.Id)
) && ) &&
( (
this.Category == other.Category || Category == other.Category ||
this.Category != null && Category != null &&
this.Category.Equals(other.Category) Category.Equals(other.Category)
) && ) &&
( (
this.Name == other.Name || Name == other.Name ||
this.Name != null && Name != null &&
this.Name.Equals(other.Name) Name.Equals(other.Name)
) && ) &&
( (
this.PhotoUrls == other.PhotoUrls || PhotoUrls == other.PhotoUrls ||
this.PhotoUrls != null && PhotoUrls != null &&
this.PhotoUrls.SequenceEqual(other.PhotoUrls) PhotoUrls.SequenceEqual(other.PhotoUrls)
) && ) &&
( (
this.Tags == other.Tags || Tags == other.Tags ||
this.Tags != null && Tags != null &&
this.Tags.SequenceEqual(other.Tags) Tags.SequenceEqual(other.Tags)
) && ) &&
( (
this.Status == other.Status || Status == other.Status ||
this.Status != null && Status != null &&
this.Status.Equals(other.Status) Status.Equals(other.Status)
); );
} }
@ -214,25 +181,26 @@ namespace IO.Swagger.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
if (this.Id != null) if (Id != null)
hash = hash * 59 + this.Id.GetHashCode(); hash = hash * 59 + Id.GetHashCode();
if (this.Category != null) if (Category != null)
hash = hash * 59 + this.Category.GetHashCode(); hash = hash * 59 + Category.GetHashCode();
if (this.Name != null) if (Name != null)
hash = hash * 59 + this.Name.GetHashCode(); hash = hash * 59 + Name.GetHashCode();
if (this.PhotoUrls != null) if (PhotoUrls != null)
hash = hash * 59 + this.PhotoUrls.GetHashCode(); hash = hash * 59 + PhotoUrls.GetHashCode();
if (this.Tags != null) if (Tags != null)
hash = hash * 59 + this.Tags.GetHashCode(); hash = hash * 59 + Tags.GetHashCode();
if (this.Status != null) if (Status != null)
hash = hash * 59 + this.Status.GetHashCode(); hash = hash * 59 + Status.GetHashCode();
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==(Pet left, Pet right) public static bool operator ==(Pet left, Pet right)
{ {
@ -244,7 +212,7 @@ namespace IO.Swagger.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
} }

View File

@ -15,36 +15,24 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace IO.Swagger.Models namespace IO.Swagger.Models
{ {
/// <summary> /// <summary>
/// A tag for a pet /// A tag for a pet
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class Tag : IEquatable<Tag> public partial class Tag : IEquatable<Tag>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="Tag" /> class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Name">Name.</param>
public Tag(long? Id = default(long?), string Name = default(string))
{
this.Id = Id;
this.Name = Name;
}
/// <summary> /// <summary>
/// Gets or Sets Id /// Gets or Sets Id
/// </summary> /// </summary>
[DataMember(Name="id")] [DataMember(Name="id")]
public long? Id { get; set; } public long? Id { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Name /// Gets or Sets Name
/// </summary> /// </summary>
@ -83,8 +71,7 @@ namespace IO.Swagger.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals((Tag)obj);
return Equals((Tag)obj);
} }
/// <summary> /// <summary>
@ -94,20 +81,19 @@ namespace IO.Swagger.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals(Tag other) public bool Equals(Tag other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return return
( (
this.Id == other.Id || Id == other.Id ||
this.Id != null && Id != null &&
this.Id.Equals(other.Id) Id.Equals(other.Id)
) && ) &&
( (
this.Name == other.Name || Name == other.Name ||
this.Name != null && Name != null &&
this.Name.Equals(other.Name) Name.Equals(other.Name)
); );
} }
@ -120,17 +106,18 @@ namespace IO.Swagger.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
if (this.Id != null) if (Id != null)
hash = hash * 59 + this.Id.GetHashCode(); hash = hash * 59 + Id.GetHashCode();
if (this.Name != null) if (Name != null)
hash = hash * 59 + this.Name.GetHashCode(); hash = hash * 59 + Name.GetHashCode();
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==(Tag left, Tag right) public static bool operator ==(Tag left, Tag right)
{ {
@ -142,7 +129,7 @@ namespace IO.Swagger.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
} }

View File

@ -15,78 +15,60 @@ using System.Text;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace IO.Swagger.Models namespace IO.Swagger.Models
{ {
/// <summary> /// <summary>
/// A User who is purchasing from the pet store /// A User who is purchasing from the pet store
/// </summary> /// </summary>
[DataContract] [DataContract]
public partial class User : IEquatable<User> public partial class User : IEquatable<User>
{ {
/// <summary>
/// Initializes a new instance of the <see cref="User" /> class.
/// </summary>
/// <param name="Id">Id.</param>
/// <param name="Username">Username.</param>
/// <param name="FirstName">FirstName.</param>
/// <param name="LastName">LastName.</param>
/// <param name="Email">Email.</param>
/// <param name="Password">Password.</param>
/// <param name="Phone">Phone.</param>
/// <param name="UserStatus">User Status.</param>
public User(long? Id = default(long?), string Username = default(string), string FirstName = default(string), string LastName = default(string), string Email = default(string), string Password = default(string), string Phone = default(string), int? UserStatus = default(int?))
{
this.Id = Id;
this.Username = Username;
this.FirstName = FirstName;
this.LastName = LastName;
this.Email = Email;
this.Password = Password;
this.Phone = Phone;
this.UserStatus = UserStatus;
}
/// <summary> /// <summary>
/// Gets or Sets Id /// Gets or Sets Id
/// </summary> /// </summary>
[DataMember(Name="id")] [DataMember(Name="id")]
public long? Id { get; set; } public long? Id { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Username /// Gets or Sets Username
/// </summary> /// </summary>
[DataMember(Name="username")] [DataMember(Name="username")]
public string Username { get; set; } public string Username { get; set; }
/// <summary> /// <summary>
/// Gets or Sets FirstName /// Gets or Sets FirstName
/// </summary> /// </summary>
[DataMember(Name="firstName")] [DataMember(Name="firstName")]
public string FirstName { get; set; } public string FirstName { get; set; }
/// <summary> /// <summary>
/// Gets or Sets LastName /// Gets or Sets LastName
/// </summary> /// </summary>
[DataMember(Name="lastName")] [DataMember(Name="lastName")]
public string LastName { get; set; } public string LastName { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Email /// Gets or Sets Email
/// </summary> /// </summary>
[DataMember(Name="email")] [DataMember(Name="email")]
public string Email { get; set; } public string Email { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Password /// Gets or Sets Password
/// </summary> /// </summary>
[DataMember(Name="password")] [DataMember(Name="password")]
public string Password { get; set; } public string Password { get; set; }
/// <summary> /// <summary>
/// Gets or Sets Phone /// Gets or Sets Phone
/// </summary> /// </summary>
[DataMember(Name="phone")] [DataMember(Name="phone")]
public string Phone { get; set; } public string Phone { get; set; }
/// <summary> /// <summary>
/// User Status /// User Status
/// </summary> /// </summary>
@ -132,8 +114,7 @@ namespace IO.Swagger.Models
{ {
if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true; if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false; return obj.GetType() == GetType() && Equals((User)obj);
return Equals((User)obj);
} }
/// <summary> /// <summary>
@ -143,50 +124,49 @@ namespace IO.Swagger.Models
/// <returns>Boolean</returns> /// <returns>Boolean</returns>
public bool Equals(User other) public bool Equals(User other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;
return return
( (
this.Id == other.Id || Id == other.Id ||
this.Id != null && Id != null &&
this.Id.Equals(other.Id) Id.Equals(other.Id)
) && ) &&
( (
this.Username == other.Username || Username == other.Username ||
this.Username != null && Username != null &&
this.Username.Equals(other.Username) Username.Equals(other.Username)
) && ) &&
( (
this.FirstName == other.FirstName || FirstName == other.FirstName ||
this.FirstName != null && FirstName != null &&
this.FirstName.Equals(other.FirstName) FirstName.Equals(other.FirstName)
) && ) &&
( (
this.LastName == other.LastName || LastName == other.LastName ||
this.LastName != null && LastName != null &&
this.LastName.Equals(other.LastName) LastName.Equals(other.LastName)
) && ) &&
( (
this.Email == other.Email || Email == other.Email ||
this.Email != null && Email != null &&
this.Email.Equals(other.Email) Email.Equals(other.Email)
) && ) &&
( (
this.Password == other.Password || Password == other.Password ||
this.Password != null && Password != null &&
this.Password.Equals(other.Password) Password.Equals(other.Password)
) && ) &&
( (
this.Phone == other.Phone || Phone == other.Phone ||
this.Phone != null && Phone != null &&
this.Phone.Equals(other.Phone) Phone.Equals(other.Phone)
) && ) &&
( (
this.UserStatus == other.UserStatus || UserStatus == other.UserStatus ||
this.UserStatus != null && UserStatus != null &&
this.UserStatus.Equals(other.UserStatus) UserStatus.Equals(other.UserStatus)
); );
} }
@ -199,29 +179,30 @@ namespace IO.Swagger.Models
// credit: http://stackoverflow.com/a/263416/677735 // credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap unchecked // Overflow is fine, just wrap
{ {
int hash = 41; var hash = 41;
// Suitable nullity checks etc, of course :) // Suitable nullity checks etc, of course :)
if (this.Id != null) if (Id != null)
hash = hash * 59 + this.Id.GetHashCode(); hash = hash * 59 + Id.GetHashCode();
if (this.Username != null) if (Username != null)
hash = hash * 59 + this.Username.GetHashCode(); hash = hash * 59 + Username.GetHashCode();
if (this.FirstName != null) if (FirstName != null)
hash = hash * 59 + this.FirstName.GetHashCode(); hash = hash * 59 + FirstName.GetHashCode();
if (this.LastName != null) if (LastName != null)
hash = hash * 59 + this.LastName.GetHashCode(); hash = hash * 59 + LastName.GetHashCode();
if (this.Email != null) if (Email != null)
hash = hash * 59 + this.Email.GetHashCode(); hash = hash * 59 + Email.GetHashCode();
if (this.Password != null) if (Password != null)
hash = hash * 59 + this.Password.GetHashCode(); hash = hash * 59 + Password.GetHashCode();
if (this.Phone != null) if (Phone != null)
hash = hash * 59 + this.Phone.GetHashCode(); hash = hash * 59 + Phone.GetHashCode();
if (this.UserStatus != null) if (UserStatus != null)
hash = hash * 59 + this.UserStatus.GetHashCode(); hash = hash * 59 + UserStatus.GetHashCode();
return hash; return hash;
} }
} }
#region Operators #region Operators
#pragma warning disable 1591
public static bool operator ==(User left, User right) public static bool operator ==(User left, User right)
{ {
@ -233,7 +214,7 @@ namespace IO.Swagger.Models
return !Equals(left, right); return !Equals(left, right);
} }
#pragma warning restore 1591
#endregion Operators #endregion Operators
} }
} }

View File

@ -1,15 +1,17 @@
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
namespace IO.Swagger namespace IO.Swagger
{ {
/// <summary>
/// Program
/// </summary>
public class Program public class Program
{ {
/// <summary>
/// Main
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args) public static void Main(string[] args)
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()

View File

@ -11,7 +11,7 @@
"IIS Express": { "IIS Express": {
"commandName": "IISExpress", "commandName": "IISExpress",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "swagger/ui/index.html", "launchUrl": "swagger/",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
@ -19,7 +19,7 @@
"web": { "web": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"launchUrl": "http://localhost:5000/swagger/ui/index.html", "launchUrl": "http://localhost:5000/swagger/",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }

View File

@ -9,28 +9,32 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.XPath;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using Swashbuckle.Swagger.Model; using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.SwaggerGen.Annotations; using Swashbuckle.AspNetCore.SwaggerGen;
namespace IO.Swagger namespace IO.Swagger
{ {
/// <summary>
/// Startup
/// </summary>
public class Startup public class Startup
{ {
private readonly IHostingEnvironment _hostingEnv; private readonly IHostingEnvironment _hostingEnv;
public IConfigurationRoot Configuration { get; } private IConfigurationRoot Configuration { get; }
/// <summary>
/// Constructor
/// </summary>
/// <param name="env"></param>
public Startup(IHostingEnvironment env) public Startup(IHostingEnvironment env)
{ {
_hostingEnv = env; _hostingEnv = env;
@ -43,48 +47,59 @@ namespace IO.Swagger
Configuration = builder.Build(); Configuration = builder.Build();
} }
/// <summary>
// This method gets called by the runtime. Use this method to add services to the container. /// This method gets called by the runtime. Use this method to add services to the container.
/// </summary>
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// Add framework services. // Add framework services.
services.AddMvc() services
.AddJsonOptions( .AddMvc()
opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); .AddJsonOptions(opts =>
services.AddSwaggerGen();
services.ConfigureSwaggerGen(options =>
{ {
options.SingleApiVersion(new Info opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
opts.SerializerSettings.Converters.Add(new StringEnumConverter {
CamelCaseText = true
});
});
services
.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
{ {
Version = "v1", Version = "v1",
Title = "IO.Swagger", Title = "IO.Swagger",
Description = "IO.Swagger (ASP.NET Core 1.0)" Description = "IO.Swagger (ASP.NET Core 1.0)"
}); });
c.CustomSchemaIds(type => type.FriendlyId(true));
options.DescribeAllEnumsAsStrings(); c.DescribeAllEnumsAsStrings();
c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
var comments = new XPathDocument($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
options.OperationFilter<XmlCommentsOperationFilter>(comments);
options.ModelFilter<XmlCommentsModelFilter>(comments);
}); });
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
/// <param name="loggerFactory"></param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory
loggerFactory.AddDebug(); .AddConsole(Configuration.GetSection("Logging"))
.AddDebug();
app.UseMvc(); app
.UseMvc()
app.UseDefaultFiles(); .UseDefaultFiles()
app.UseStaticFiles(); .UseStaticFiles()
.UseSwagger()
app.UseSwagger(); .UseSwaggerUI(c =>
app.UseSwaggerUi(); {
c.SwaggerEndpoint("/swagger/v1/swagger.json", "IO.Swagger");
});
} }
} }
} }

View File

@ -21,8 +21,7 @@
"Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.0.0", "Microsoft.EntityFrameworkCore": "1.0.0",
"Swashbuckle.SwaggerGen": "6.0.0-beta901", "Swashbuckle.AspNetCore": "1.0.0-rc3",
"Swashbuckle.SwaggerUi": "6.0.0-beta901",
"Newtonsoft.Json": "9.0.1" "Newtonsoft.Json": "9.0.1"
}, },

View File

@ -1 +1 @@
<meta http-equiv="refresh" content="0;URL='./swagger/ui/index.html'" /> <meta http-equiv="refresh" content="0;URL='./swagger/'" />