forked from loafle/openapi-generator-original
[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:
parent
c9182ba00f
commit
7cc20cbeba
@ -35,7 +35,7 @@ public class CodegenOperation {
|
||||
public ExternalDocs externalDocs;
|
||||
public Map<String, Object> vendorExtensions;
|
||||
public String nickname; // legacy support
|
||||
public String operationIdLowerCase; // for mardown documentation
|
||||
public String operationIdLowerCase; // for markdown documentation
|
||||
public String operationIdCamelCase; // for class names
|
||||
|
||||
/**
|
||||
|
@ -114,6 +114,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
supportingFiles.add(new SupportingFile("project.json.mustache", packageFolder, "project.json"));
|
||||
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.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("Project.xproj.mustache", packageFolder, this.packageName + ".xproj"));
|
||||
|
@ -2,9 +2,8 @@ FROM microsoft/dotnet:1.0.3-sdk-projectjson
|
||||
|
||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
|
||||
|
||||
RUN mkdir -p /app/{{packageName}}
|
||||
COPY . /app/{{packageName}}
|
||||
WORKDIR /app/{{packageName}}
|
||||
COPY . /app/{{packageName}}
|
||||
|
||||
EXPOSE 5000/tcp
|
||||
|
||||
|
@ -1,15 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
namespace {{packageName}}
|
||||
{
|
||||
/// <summary>
|
||||
/// Program
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Main
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
|
@ -11,7 +11,7 @@
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger/ui/index.html",
|
||||
"launchUrl": "swagger/",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
@ -19,7 +19,7 @@
|
||||
"web": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "http://localhost:5000/swagger/ui/index.html",
|
||||
"launchUrl": "http://localhost:5000/swagger/",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
@ -1,27 +1,31 @@
|
||||
{{>partial_header}}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.XPath;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Swashbuckle.Swagger.Model;
|
||||
using Swashbuckle.SwaggerGen.Annotations;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace {{packageName}}
|
||||
{
|
||||
/// <summary>
|
||||
/// Startup
|
||||
/// </summary>
|
||||
public class Startup
|
||||
{
|
||||
private readonly IHostingEnvironment _hostingEnv;
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
private IConfigurationRoot Configuration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="env"></param>
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
_hostingEnv = env;
|
||||
@ -33,49 +37,60 @@ namespace {{packageName}}
|
||||
.AddEnvironmentVariables();
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
// Add framework services.
|
||||
services.AddMvc()
|
||||
.AddJsonOptions(
|
||||
opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });
|
||||
|
||||
services.AddSwaggerGen();
|
||||
|
||||
services.ConfigureSwaggerGen(options =>
|
||||
{
|
||||
options.SingleApiVersion(new Info
|
||||
services
|
||||
.AddMvc()
|
||||
.AddJsonOptions(opts =>
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "{{packageName}}",
|
||||
Description = "{{packageName}} (ASP.NET Core 1.0)"
|
||||
opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
opts.SerializerSettings.Converters.Add(new StringEnumConverter {
|
||||
CamelCaseText = true
|
||||
});
|
||||
});
|
||||
|
||||
options.DescribeAllEnumsAsStrings();
|
||||
|
||||
var comments = new XPathDocument($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
|
||||
options.OperationFilter<XmlCommentsOperationFilter>(comments);
|
||||
options.ModelFilter<XmlCommentsModelFilter>(comments);
|
||||
});
|
||||
|
||||
services
|
||||
.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new Info
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "{{packageName}}",
|
||||
Description = "{{packageName}} (ASP.NET Core 1.0)"
|
||||
});
|
||||
c.CustomSchemaIds(type => type.FriendlyId(true));
|
||||
c.DescribeAllEnumsAsStrings();
|
||||
c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
|
||||
});
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
loggerFactory.AddDebug();
|
||||
loggerFactory
|
||||
.AddConsole(Configuration.GetSection("Logging"))
|
||||
.AddDebug();
|
||||
|
||||
app.UseMvc();
|
||||
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUi();
|
||||
app
|
||||
.UseMvc()
|
||||
.UseDefaultFiles()
|
||||
.UseStaticFiles()
|
||||
.UseSwagger()
|
||||
.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "{{packageName}}");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
{{>partial_header}}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.SwaggerGen.Annotations;
|
||||
using {{packageName}}.Attributes;
|
||||
using {{packageName}}.Models;
|
||||
|
||||
namespace {{packageName}}.Controllers
|
||||
@ -20,7 +22,6 @@ namespace {{packageName}}.Controllers
|
||||
[Description("{{description}}")]{{/description}}
|
||||
public class {{classname}}Controller : Controller
|
||||
{ {{#operation}}
|
||||
|
||||
/// <summary>
|
||||
/// {{#summary}}{{summary}}{{/summary}}
|
||||
/// </summary>
|
||||
@ -29,8 +30,9 @@ namespace {{packageName}}.Controllers
|
||||
/// <response code="{{code}}">{{message}}</response>{{/responses}}
|
||||
[{{httpMethod}}]
|
||||
[Route("{{{basePathWithoutHost}}}{{{path}}}")]
|
||||
[SwaggerOperation("{{operationId}}")]{{#returnType}}
|
||||
[SwaggerResponse(200, type: typeof({{&returnType}}))]{{/returnType}}
|
||||
[ValidateModelState]
|
||||
[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}})
|
||||
{ {{#returnType}}
|
||||
string exampleJson = null;
|
||||
@ -39,7 +41,7 @@ namespace {{packageName}}.Controllers
|
||||
return new ObjectResult(example);{{/returnType}}{{^returnType}}
|
||||
throw new NotImplementedException();{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
}
|
||||
|
@ -3,12 +3,11 @@
|
||||
/// </summary>{{#description}}
|
||||
/// <value>{{{description}}}</value>{{/description}}
|
||||
public enum {{#datatypeWithEnum}}{{.}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}
|
||||
{
|
||||
{{#allowableValues}}{{#enumVars}}
|
||||
{ {{#allowableValues}}{{#enumVars}}
|
||||
/// <summary>
|
||||
/// Enum {{name}} for {{{value}}}
|
||||
/// </summary>
|
||||
[EnumMember(Value = {{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isFloat}}"{{/isFloat}}{{#isDouble}}"{{/isDouble}}{{{value}}}{{#isLong}}"{{/isLong}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isFloat}}"{{/isFloat}})]
|
||||
{{name}}{{#isLong}} = {{{value}}}{{/isLong}}{{#isInteger}} = {{{value}}}{{/isInteger}}{{^-last}},
|
||||
{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
}
|
||||
}
|
||||
|
@ -6,79 +6,36 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
namespace {{packageName}}.Models
|
||||
{
|
||||
{{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
|
||||
{ {{#isEnum}}{{>enumClass}}{{/isEnum}}{{^isEnum}}
|
||||
/// <summary>
|
||||
/// {{description}}
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
|
||||
{
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
{{>enumClass}}
|
||||
{{/isEnum}}
|
||||
{{#items.isEnum}}
|
||||
{{#items}}
|
||||
{{>enumClass}}
|
||||
{{/items}}
|
||||
{{/items.isEnum}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}}IEquatable<{{classname}}>
|
||||
{ {{#vars}}{{#isEnum}}{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||
/// <summary>
|
||||
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
|
||||
/// </summary>{{#description}}
|
||||
/// <value>{{{description}}}</value>{{/description}}
|
||||
{{#required}}
|
||||
[Required]
|
||||
{{/required}}
|
||||
[DataMember(Name="{{baseName}}")]
|
||||
{{#isEnum}}
|
||||
public {{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}} {{name}} { get; set; }
|
||||
{{/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}}
|
||||
/// <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; }
|
||||
{{/isEnum}}
|
||||
{{#hasMore}}
|
||||
{{/hasMore}}
|
||||
{{/vars}}
|
||||
|
||||
/// <summary>
|
||||
@ -114,8 +71,7 @@ namespace {{packageName}}.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals(({{classname}})obj);
|
||||
return obj.GetType() == GetType() && Equals(({{classname}})obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -125,20 +81,19 @@ namespace {{packageName}}.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals({{classname}} other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return {{#vars}}{{#isNotContainer}}
|
||||
(
|
||||
this.{{name}} == other.{{name}} ||
|
||||
this.{{name}} != null &&
|
||||
this.{{name}}.Equals(other.{{name}})
|
||||
{{name}} == other.{{name}} ||
|
||||
{{name}} != null &&
|
||||
{{name}}.Equals(other.{{name}})
|
||||
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
|
||||
(
|
||||
this.{{name}} == other.{{name}} ||
|
||||
this.{{name}} != null &&
|
||||
this.{{name}}.SequenceEqual(other.{{name}})
|
||||
{{name}} == other.{{name}} ||
|
||||
{{name}} != null &&
|
||||
{{name}}.SequenceEqual(other.{{name}})
|
||||
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
|
||||
}
|
||||
|
||||
@ -151,17 +106,18 @@ namespace {{packageName}}.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
{{#vars}}
|
||||
if (this.{{name}} != null)
|
||||
hash = hash * 59 + this.{{name}}.GetHashCode();
|
||||
if ({{name}} != null)
|
||||
hash = hash * 59 + {{name}}.GetHashCode();
|
||||
{{/vars}}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==({{classname}} left, {{classname}} right)
|
||||
{
|
||||
@ -173,8 +129,8 @@ namespace {{packageName}}.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
|
@ -21,8 +21,7 @@
|
||||
"Microsoft.Extensions.Logging.Debug": "1.0.0",
|
||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
|
||||
"Microsoft.EntityFrameworkCore": "1.0.0",
|
||||
"Swashbuckle.SwaggerGen": "6.0.0-beta901",
|
||||
"Swashbuckle.SwaggerUi": "6.0.0-beta901",
|
||||
"Swashbuckle.AspNetCore": "1.0.0-rc3",
|
||||
"Newtonsoft.Json": "9.0.1"
|
||||
},
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1 +1 @@
|
||||
<meta http-equiv="refresh" content="0;URL='./swagger/ui/index.html'" />
|
||||
<meta http-equiv="refresh" content="0;URL='./swagger/'" />
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,15 +10,17 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.SwaggerGen.Annotations;
|
||||
using IO.Swagger.Attributes;
|
||||
using IO.Swagger.Models;
|
||||
|
||||
namespace IO.Swagger.Controllers
|
||||
@ -28,7 +30,6 @@ namespace IO.Swagger.Controllers
|
||||
/// </summary>
|
||||
public class PetApiController : Controller
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
@ -37,13 +38,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="405">Invalid input</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/pet")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("AddPet")]
|
||||
public virtual void AddPet([FromBody]Pet body)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
/// </summary>
|
||||
@ -53,13 +54,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="400">Invalid pet value</response>
|
||||
[HttpDelete]
|
||||
[Route("/v2/pet/{petId}")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("DeletePet")]
|
||||
public virtual void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by status
|
||||
/// </summary>
|
||||
@ -69,8 +70,10 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="400">Invalid status value</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/pet/findByStatus")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -81,7 +84,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Finds Pets by tags
|
||||
/// </summary>
|
||||
@ -91,8 +93,10 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="400">Invalid tag value</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/pet/findByTags")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -103,7 +107,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find pet by ID
|
||||
/// </summary>
|
||||
@ -114,8 +117,11 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="404">Pet not found</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/pet/{petId}")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -126,7 +132,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
@ -137,13 +142,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="405">Validation exception</response>
|
||||
[HttpPut]
|
||||
[Route("/v2/pet")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("UpdatePet")]
|
||||
public virtual void UpdatePet([FromBody]Pet body)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updates a pet in the store with form data
|
||||
/// </summary>
|
||||
@ -154,13 +159,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="405">Invalid input</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/pet/{petId}")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("UpdatePetWithForm")]
|
||||
public virtual void UpdatePetWithForm([FromRoute]long? petId, [FromForm]string name, [FromForm]string status)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
/// </summary>
|
||||
@ -171,8 +176,9 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="200">successful operation</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/pet/{petId}/uploadImage")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
|
@ -10,15 +10,17 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.SwaggerGen.Annotations;
|
||||
using IO.Swagger.Attributes;
|
||||
using IO.Swagger.Models;
|
||||
|
||||
namespace IO.Swagger.Controllers
|
||||
@ -28,7 +30,6 @@ namespace IO.Swagger.Controllers
|
||||
/// </summary>
|
||||
public class StoreApiController : Controller
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
/// </summary>
|
||||
@ -38,13 +39,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="404">Order not found</response>
|
||||
[HttpDelete]
|
||||
[Route("/v2/store/order/{orderId}")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("DeleteOrder")]
|
||||
public virtual void DeleteOrder([FromRoute]string orderId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
/// </summary>
|
||||
@ -52,8 +53,9 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="200">successful operation</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/store/inventory")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("GetInventory")]
|
||||
[SwaggerResponse(200, type: typeof(Dictionary<string, int?>))]
|
||||
[SwaggerResponse(200, typeof(Dictionary<string, int?>), "successful operation")]
|
||||
public virtual IActionResult GetInventory()
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -64,7 +66,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
/// </summary>
|
||||
@ -75,8 +76,11 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="404">Order not found</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/store/order/{orderId}")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -87,7 +91,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
@ -97,8 +100,10 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="400">Invalid Order</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/store/order")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
|
@ -10,15 +10,17 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.SwaggerGen.Annotations;
|
||||
using IO.Swagger.Attributes;
|
||||
using IO.Swagger.Models;
|
||||
|
||||
namespace IO.Swagger.Controllers
|
||||
@ -28,7 +30,6 @@ namespace IO.Swagger.Controllers
|
||||
/// </summary>
|
||||
public class UserApiController : Controller
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Create user
|
||||
/// </summary>
|
||||
@ -37,13 +38,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="0">successful operation</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/user")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("CreateUser")]
|
||||
public virtual void CreateUser([FromBody]User body)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
@ -52,13 +53,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="0">successful operation</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/user/createWithArray")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("CreateUsersWithArrayInput")]
|
||||
public virtual void CreateUsersWithArrayInput([FromBody]List<User> body)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
@ -67,13 +68,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="0">successful operation</response>
|
||||
[HttpPost]
|
||||
[Route("/v2/user/createWithList")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("CreateUsersWithListInput")]
|
||||
public virtual void CreateUsersWithListInput([FromBody]List<User> body)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Delete user
|
||||
/// </summary>
|
||||
@ -83,13 +84,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="404">User not found</response>
|
||||
[HttpDelete]
|
||||
[Route("/v2/user/{username}")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("DeleteUser")]
|
||||
public virtual void DeleteUser([FromRoute]string username)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get user by user name
|
||||
/// </summary>
|
||||
@ -100,8 +101,11 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="404">User not found</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/user/{username}")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -112,7 +116,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
/// </summary>
|
||||
@ -123,8 +126,10 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="400">Invalid username/password supplied</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/user/login")]
|
||||
[ValidateModelState]
|
||||
[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)
|
||||
{
|
||||
string exampleJson = null;
|
||||
@ -135,7 +140,6 @@ namespace IO.Swagger.Controllers
|
||||
return new ObjectResult(example);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
@ -143,13 +147,13 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="0">successful operation</response>
|
||||
[HttpGet]
|
||||
[Route("/v2/user/logout")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("LogoutUser")]
|
||||
public virtual void LogoutUser()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Updated user
|
||||
/// </summary>
|
||||
@ -160,6 +164,7 @@ namespace IO.Swagger.Controllers
|
||||
/// <response code="404">User not found</response>
|
||||
[HttpPut]
|
||||
[Route("/v2/user/{username}")]
|
||||
[ValidateModelState]
|
||||
[SwaggerOperation("UpdateUser")]
|
||||
public virtual void UpdateUser([FromRoute]string username, [FromBody]User body)
|
||||
{
|
||||
|
@ -2,9 +2,8 @@ FROM microsoft/dotnet:1.0.3-sdk-projectjson
|
||||
|
||||
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
|
||||
|
||||
RUN mkdir -p /app/IO.Swagger
|
||||
COPY . /app/IO.Swagger
|
||||
WORKDIR /app/IO.Swagger
|
||||
COPY . /app/IO.Swagger
|
||||
|
||||
EXPOSE 5000/tcp
|
||||
|
||||
|
@ -15,43 +15,30 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Models
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the result of uploading an image resource
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
public partial class ApiResponse : IEquatable<ApiResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets Code
|
||||
/// </summary>
|
||||
[DataMember(Name="code")]
|
||||
public int? Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Type
|
||||
/// </summary>
|
||||
[DataMember(Name="type")]
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Message
|
||||
/// </summary>
|
||||
@ -91,8 +78,7 @@ namespace IO.Swagger.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((ApiResponse)obj);
|
||||
return obj.GetType() == GetType() && Equals((ApiResponse)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -102,25 +88,24 @@ namespace IO.Swagger.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(ApiResponse other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return
|
||||
(
|
||||
this.Code == other.Code ||
|
||||
this.Code != null &&
|
||||
this.Code.Equals(other.Code)
|
||||
Code == other.Code ||
|
||||
Code != null &&
|
||||
Code.Equals(other.Code)
|
||||
) &&
|
||||
(
|
||||
this.Type == other.Type ||
|
||||
this.Type != null &&
|
||||
this.Type.Equals(other.Type)
|
||||
Type == other.Type ||
|
||||
Type != null &&
|
||||
Type.Equals(other.Type)
|
||||
) &&
|
||||
(
|
||||
this.Message == other.Message ||
|
||||
this.Message != null &&
|
||||
this.Message.Equals(other.Message)
|
||||
Message == other.Message ||
|
||||
Message != null &&
|
||||
Message.Equals(other.Message)
|
||||
);
|
||||
}
|
||||
|
||||
@ -133,19 +118,20 @@ namespace IO.Swagger.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.Code != null)
|
||||
hash = hash * 59 + this.Code.GetHashCode();
|
||||
if (this.Type != null)
|
||||
hash = hash * 59 + this.Type.GetHashCode();
|
||||
if (this.Message != null)
|
||||
hash = hash * 59 + this.Message.GetHashCode();
|
||||
if (Code != null)
|
||||
hash = hash * 59 + Code.GetHashCode();
|
||||
if (Type != null)
|
||||
hash = hash * 59 + Type.GetHashCode();
|
||||
if (Message != null)
|
||||
hash = hash * 59 + Message.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==(ApiResponse left, ApiResponse right)
|
||||
{
|
||||
@ -157,7 +143,7 @@ namespace IO.Swagger.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,36 +15,24 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Models
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// A category for a pet
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
public partial class Category : IEquatable<Category>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id")]
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
@ -83,8 +71,7 @@ namespace IO.Swagger.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((Category)obj);
|
||||
return obj.GetType() == GetType() && Equals((Category)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -94,20 +81,19 @@ namespace IO.Swagger.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(Category other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return
|
||||
(
|
||||
this.Id == other.Id ||
|
||||
this.Id != null &&
|
||||
this.Id.Equals(other.Id)
|
||||
Id == other.Id ||
|
||||
Id != null &&
|
||||
Id.Equals(other.Id)
|
||||
) &&
|
||||
(
|
||||
this.Name == other.Name ||
|
||||
this.Name != null &&
|
||||
this.Name.Equals(other.Name)
|
||||
Name == other.Name ||
|
||||
Name != null &&
|
||||
Name.Equals(other.Name)
|
||||
);
|
||||
}
|
||||
|
||||
@ -120,17 +106,18 @@ namespace IO.Swagger.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.Id != null)
|
||||
hash = hash * 59 + this.Id.GetHashCode();
|
||||
if (this.Name != null)
|
||||
hash = hash * 59 + this.Name.GetHashCode();
|
||||
if (Id != null)
|
||||
hash = hash * 59 + Id.GetHashCode();
|
||||
if (Name != null)
|
||||
hash = hash * 59 + Name.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==(Category left, Category right)
|
||||
{
|
||||
@ -142,7 +129,7 @@ namespace IO.Swagger.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,25 +15,47 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Models
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// An order for a pets from the pet store
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class Order : IEquatable<Order>
|
||||
{
|
||||
/// <summary>
|
||||
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>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
/// <value>Order Status</value>
|
||||
public enum StatusEnum
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum PlacedEnum for "placed"
|
||||
/// </summary>
|
||||
@ -52,6 +74,7 @@ namespace IO.Swagger.Models
|
||||
[EnumMember(Value = "delivered")]
|
||||
DeliveredEnum
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Order Status
|
||||
/// </summary>
|
||||
@ -59,54 +82,6 @@ namespace IO.Swagger.Models
|
||||
[DataMember(Name="status")]
|
||||
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>
|
||||
/// Gets or Sets Complete
|
||||
/// </summary>
|
||||
@ -149,8 +124,7 @@ namespace IO.Swagger.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((Order)obj);
|
||||
return obj.GetType() == GetType() && Equals((Order)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,40 +134,39 @@ namespace IO.Swagger.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(Order other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return
|
||||
(
|
||||
this.Id == other.Id ||
|
||||
this.Id != null &&
|
||||
this.Id.Equals(other.Id)
|
||||
Id == other.Id ||
|
||||
Id != null &&
|
||||
Id.Equals(other.Id)
|
||||
) &&
|
||||
(
|
||||
this.PetId == other.PetId ||
|
||||
this.PetId != null &&
|
||||
this.PetId.Equals(other.PetId)
|
||||
PetId == other.PetId ||
|
||||
PetId != null &&
|
||||
PetId.Equals(other.PetId)
|
||||
) &&
|
||||
(
|
||||
this.Quantity == other.Quantity ||
|
||||
this.Quantity != null &&
|
||||
this.Quantity.Equals(other.Quantity)
|
||||
Quantity == other.Quantity ||
|
||||
Quantity != null &&
|
||||
Quantity.Equals(other.Quantity)
|
||||
) &&
|
||||
(
|
||||
this.ShipDate == other.ShipDate ||
|
||||
this.ShipDate != null &&
|
||||
this.ShipDate.Equals(other.ShipDate)
|
||||
ShipDate == other.ShipDate ||
|
||||
ShipDate != null &&
|
||||
ShipDate.Equals(other.ShipDate)
|
||||
) &&
|
||||
(
|
||||
this.Status == other.Status ||
|
||||
this.Status != null &&
|
||||
this.Status.Equals(other.Status)
|
||||
Status == other.Status ||
|
||||
Status != null &&
|
||||
Status.Equals(other.Status)
|
||||
) &&
|
||||
(
|
||||
this.Complete == other.Complete ||
|
||||
this.Complete != null &&
|
||||
this.Complete.Equals(other.Complete)
|
||||
Complete == other.Complete ||
|
||||
Complete != null &&
|
||||
Complete.Equals(other.Complete)
|
||||
);
|
||||
}
|
||||
|
||||
@ -206,25 +179,26 @@ namespace IO.Swagger.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.Id != null)
|
||||
hash = hash * 59 + this.Id.GetHashCode();
|
||||
if (this.PetId != null)
|
||||
hash = hash * 59 + this.PetId.GetHashCode();
|
||||
if (this.Quantity != null)
|
||||
hash = hash * 59 + this.Quantity.GetHashCode();
|
||||
if (this.ShipDate != null)
|
||||
hash = hash * 59 + this.ShipDate.GetHashCode();
|
||||
if (this.Status != null)
|
||||
hash = hash * 59 + this.Status.GetHashCode();
|
||||
if (this.Complete != null)
|
||||
hash = hash * 59 + this.Complete.GetHashCode();
|
||||
if (Id != null)
|
||||
hash = hash * 59 + Id.GetHashCode();
|
||||
if (PetId != null)
|
||||
hash = hash * 59 + PetId.GetHashCode();
|
||||
if (Quantity != null)
|
||||
hash = hash * 59 + Quantity.GetHashCode();
|
||||
if (ShipDate != null)
|
||||
hash = hash * 59 + ShipDate.GetHashCode();
|
||||
if (Status != null)
|
||||
hash = hash * 59 + Status.GetHashCode();
|
||||
if (Complete != null)
|
||||
hash = hash * 59 + Complete.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==(Order left, Order right)
|
||||
{
|
||||
@ -236,7 +210,7 @@ namespace IO.Swagger.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,25 +15,55 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Models
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// A pet for sale in the pet store
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class Pet : IEquatable<Pet>
|
||||
{
|
||||
/// <summary>
|
||||
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>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
/// <value>pet status in the store</value>
|
||||
public enum StatusEnum
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum AvailableEnum for "available"
|
||||
/// </summary>
|
||||
@ -52,6 +82,7 @@ namespace IO.Swagger.Models
|
||||
[EnumMember(Value = "sold")]
|
||||
SoldEnum
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// pet status in the store
|
||||
/// </summary>
|
||||
@ -59,68 +90,6 @@ namespace IO.Swagger.Models
|
||||
[DataMember(Name="status")]
|
||||
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>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
@ -157,8 +126,7 @@ namespace IO.Swagger.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((Pet)obj);
|
||||
return obj.GetType() == GetType() && Equals((Pet)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -168,40 +136,39 @@ namespace IO.Swagger.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(Pet other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return
|
||||
(
|
||||
this.Id == other.Id ||
|
||||
this.Id != null &&
|
||||
this.Id.Equals(other.Id)
|
||||
Id == other.Id ||
|
||||
Id != null &&
|
||||
Id.Equals(other.Id)
|
||||
) &&
|
||||
(
|
||||
this.Category == other.Category ||
|
||||
this.Category != null &&
|
||||
this.Category.Equals(other.Category)
|
||||
Category == other.Category ||
|
||||
Category != null &&
|
||||
Category.Equals(other.Category)
|
||||
) &&
|
||||
(
|
||||
this.Name == other.Name ||
|
||||
this.Name != null &&
|
||||
this.Name.Equals(other.Name)
|
||||
Name == other.Name ||
|
||||
Name != null &&
|
||||
Name.Equals(other.Name)
|
||||
) &&
|
||||
(
|
||||
this.PhotoUrls == other.PhotoUrls ||
|
||||
this.PhotoUrls != null &&
|
||||
this.PhotoUrls.SequenceEqual(other.PhotoUrls)
|
||||
PhotoUrls == other.PhotoUrls ||
|
||||
PhotoUrls != null &&
|
||||
PhotoUrls.SequenceEqual(other.PhotoUrls)
|
||||
) &&
|
||||
(
|
||||
this.Tags == other.Tags ||
|
||||
this.Tags != null &&
|
||||
this.Tags.SequenceEqual(other.Tags)
|
||||
Tags == other.Tags ||
|
||||
Tags != null &&
|
||||
Tags.SequenceEqual(other.Tags)
|
||||
) &&
|
||||
(
|
||||
this.Status == other.Status ||
|
||||
this.Status != null &&
|
||||
this.Status.Equals(other.Status)
|
||||
Status == other.Status ||
|
||||
Status != null &&
|
||||
Status.Equals(other.Status)
|
||||
);
|
||||
}
|
||||
|
||||
@ -214,25 +181,26 @@ namespace IO.Swagger.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.Id != null)
|
||||
hash = hash * 59 + this.Id.GetHashCode();
|
||||
if (this.Category != null)
|
||||
hash = hash * 59 + this.Category.GetHashCode();
|
||||
if (this.Name != null)
|
||||
hash = hash * 59 + this.Name.GetHashCode();
|
||||
if (this.PhotoUrls != null)
|
||||
hash = hash * 59 + this.PhotoUrls.GetHashCode();
|
||||
if (this.Tags != null)
|
||||
hash = hash * 59 + this.Tags.GetHashCode();
|
||||
if (this.Status != null)
|
||||
hash = hash * 59 + this.Status.GetHashCode();
|
||||
if (Id != null)
|
||||
hash = hash * 59 + Id.GetHashCode();
|
||||
if (Category != null)
|
||||
hash = hash * 59 + Category.GetHashCode();
|
||||
if (Name != null)
|
||||
hash = hash * 59 + Name.GetHashCode();
|
||||
if (PhotoUrls != null)
|
||||
hash = hash * 59 + PhotoUrls.GetHashCode();
|
||||
if (Tags != null)
|
||||
hash = hash * 59 + Tags.GetHashCode();
|
||||
if (Status != null)
|
||||
hash = hash * 59 + Status.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==(Pet left, Pet right)
|
||||
{
|
||||
@ -244,7 +212,7 @@ namespace IO.Swagger.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,36 +15,24 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Models
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// A tag for a pet
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
public partial class Tag : IEquatable<Tag>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id")]
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
@ -83,8 +71,7 @@ namespace IO.Swagger.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((Tag)obj);
|
||||
return obj.GetType() == GetType() && Equals((Tag)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -94,20 +81,19 @@ namespace IO.Swagger.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(Tag other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return
|
||||
(
|
||||
this.Id == other.Id ||
|
||||
this.Id != null &&
|
||||
this.Id.Equals(other.Id)
|
||||
Id == other.Id ||
|
||||
Id != null &&
|
||||
Id.Equals(other.Id)
|
||||
) &&
|
||||
(
|
||||
this.Name == other.Name ||
|
||||
this.Name != null &&
|
||||
this.Name.Equals(other.Name)
|
||||
Name == other.Name ||
|
||||
Name != null &&
|
||||
Name.Equals(other.Name)
|
||||
);
|
||||
}
|
||||
|
||||
@ -120,17 +106,18 @@ namespace IO.Swagger.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.Id != null)
|
||||
hash = hash * 59 + this.Id.GetHashCode();
|
||||
if (this.Name != null)
|
||||
hash = hash * 59 + this.Name.GetHashCode();
|
||||
if (Id != null)
|
||||
hash = hash * 59 + Id.GetHashCode();
|
||||
if (Name != null)
|
||||
hash = hash * 59 + Name.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==(Tag left, Tag right)
|
||||
{
|
||||
@ -142,7 +129,7 @@ namespace IO.Swagger.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,78 +15,60 @@ using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Models
|
||||
{
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
/// A User who is purchasing from the pet store
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
public partial class User : IEquatable<User>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id")]
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Username
|
||||
/// </summary>
|
||||
[DataMember(Name="username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets FirstName
|
||||
/// </summary>
|
||||
[DataMember(Name="firstName")]
|
||||
public string FirstName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets LastName
|
||||
/// </summary>
|
||||
[DataMember(Name="lastName")]
|
||||
public string LastName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Email
|
||||
/// </summary>
|
||||
[DataMember(Name="email")]
|
||||
public string Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Password
|
||||
/// </summary>
|
||||
[DataMember(Name="password")]
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Phone
|
||||
/// </summary>
|
||||
[DataMember(Name="phone")]
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// User Status
|
||||
/// </summary>
|
||||
@ -132,8 +114,7 @@ namespace IO.Swagger.Models
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != GetType()) return false;
|
||||
return Equals((User)obj);
|
||||
return obj.GetType() == GetType() && Equals((User)obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,50 +124,49 @@ namespace IO.Swagger.Models
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(User other)
|
||||
{
|
||||
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return
|
||||
(
|
||||
this.Id == other.Id ||
|
||||
this.Id != null &&
|
||||
this.Id.Equals(other.Id)
|
||||
Id == other.Id ||
|
||||
Id != null &&
|
||||
Id.Equals(other.Id)
|
||||
) &&
|
||||
(
|
||||
this.Username == other.Username ||
|
||||
this.Username != null &&
|
||||
this.Username.Equals(other.Username)
|
||||
Username == other.Username ||
|
||||
Username != null &&
|
||||
Username.Equals(other.Username)
|
||||
) &&
|
||||
(
|
||||
this.FirstName == other.FirstName ||
|
||||
this.FirstName != null &&
|
||||
this.FirstName.Equals(other.FirstName)
|
||||
FirstName == other.FirstName ||
|
||||
FirstName != null &&
|
||||
FirstName.Equals(other.FirstName)
|
||||
) &&
|
||||
(
|
||||
this.LastName == other.LastName ||
|
||||
this.LastName != null &&
|
||||
this.LastName.Equals(other.LastName)
|
||||
LastName == other.LastName ||
|
||||
LastName != null &&
|
||||
LastName.Equals(other.LastName)
|
||||
) &&
|
||||
(
|
||||
this.Email == other.Email ||
|
||||
this.Email != null &&
|
||||
this.Email.Equals(other.Email)
|
||||
Email == other.Email ||
|
||||
Email != null &&
|
||||
Email.Equals(other.Email)
|
||||
) &&
|
||||
(
|
||||
this.Password == other.Password ||
|
||||
this.Password != null &&
|
||||
this.Password.Equals(other.Password)
|
||||
Password == other.Password ||
|
||||
Password != null &&
|
||||
Password.Equals(other.Password)
|
||||
) &&
|
||||
(
|
||||
this.Phone == other.Phone ||
|
||||
this.Phone != null &&
|
||||
this.Phone.Equals(other.Phone)
|
||||
Phone == other.Phone ||
|
||||
Phone != null &&
|
||||
Phone.Equals(other.Phone)
|
||||
) &&
|
||||
(
|
||||
this.UserStatus == other.UserStatus ||
|
||||
this.UserStatus != null &&
|
||||
this.UserStatus.Equals(other.UserStatus)
|
||||
UserStatus == other.UserStatus ||
|
||||
UserStatus != null &&
|
||||
UserStatus.Equals(other.UserStatus)
|
||||
);
|
||||
}
|
||||
|
||||
@ -199,29 +179,30 @@ namespace IO.Swagger.Models
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
var hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.Id != null)
|
||||
hash = hash * 59 + this.Id.GetHashCode();
|
||||
if (this.Username != null)
|
||||
hash = hash * 59 + this.Username.GetHashCode();
|
||||
if (this.FirstName != null)
|
||||
hash = hash * 59 + this.FirstName.GetHashCode();
|
||||
if (this.LastName != null)
|
||||
hash = hash * 59 + this.LastName.GetHashCode();
|
||||
if (this.Email != null)
|
||||
hash = hash * 59 + this.Email.GetHashCode();
|
||||
if (this.Password != null)
|
||||
hash = hash * 59 + this.Password.GetHashCode();
|
||||
if (this.Phone != null)
|
||||
hash = hash * 59 + this.Phone.GetHashCode();
|
||||
if (this.UserStatus != null)
|
||||
hash = hash * 59 + this.UserStatus.GetHashCode();
|
||||
if (Id != null)
|
||||
hash = hash * 59 + Id.GetHashCode();
|
||||
if (Username != null)
|
||||
hash = hash * 59 + Username.GetHashCode();
|
||||
if (FirstName != null)
|
||||
hash = hash * 59 + FirstName.GetHashCode();
|
||||
if (LastName != null)
|
||||
hash = hash * 59 + LastName.GetHashCode();
|
||||
if (Email != null)
|
||||
hash = hash * 59 + Email.GetHashCode();
|
||||
if (Password != null)
|
||||
hash = hash * 59 + Password.GetHashCode();
|
||||
if (Phone != null)
|
||||
hash = hash * 59 + Phone.GetHashCode();
|
||||
if (UserStatus != null)
|
||||
hash = hash * 59 + UserStatus.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
#region Operators
|
||||
#pragma warning disable 1591
|
||||
|
||||
public static bool operator ==(User left, User right)
|
||||
{
|
||||
@ -233,7 +214,7 @@ namespace IO.Swagger.Models
|
||||
return !Equals(left, right);
|
||||
}
|
||||
|
||||
#pragma warning restore 1591
|
||||
#endregion Operators
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
namespace IO.Swagger
|
||||
{
|
||||
/// <summary>
|
||||
/// Program
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// Main
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
|
@ -11,7 +11,7 @@
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger/ui/index.html",
|
||||
"launchUrl": "swagger/",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
@ -19,7 +19,7 @@
|
||||
"web": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "http://localhost:5000/swagger/ui/index.html",
|
||||
"launchUrl": "http://localhost:5000/swagger/",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
|
@ -9,28 +9,32 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.XPath;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Swashbuckle.Swagger.Model;
|
||||
using Swashbuckle.SwaggerGen.Annotations;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
||||
namespace IO.Swagger
|
||||
{
|
||||
/// <summary>
|
||||
/// Startup
|
||||
/// </summary>
|
||||
public class Startup
|
||||
{
|
||||
private readonly IHostingEnvironment _hostingEnv;
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
private IConfigurationRoot Configuration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="env"></param>
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
_hostingEnv = env;
|
||||
@ -42,49 +46,60 @@ namespace IO.Swagger
|
||||
.AddEnvironmentVariables();
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
|
||||
/// <summary>
|
||||
/// 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)
|
||||
{
|
||||
// Add framework services.
|
||||
services.AddMvc()
|
||||
.AddJsonOptions(
|
||||
opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });
|
||||
|
||||
services.AddSwaggerGen();
|
||||
|
||||
services.ConfigureSwaggerGen(options =>
|
||||
{
|
||||
options.SingleApiVersion(new Info
|
||||
services
|
||||
.AddMvc()
|
||||
.AddJsonOptions(opts =>
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "IO.Swagger",
|
||||
Description = "IO.Swagger (ASP.NET Core 1.0)"
|
||||
opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
opts.SerializerSettings.Converters.Add(new StringEnumConverter {
|
||||
CamelCaseText = true
|
||||
});
|
||||
});
|
||||
|
||||
options.DescribeAllEnumsAsStrings();
|
||||
|
||||
var comments = new XPathDocument($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
|
||||
options.OperationFilter<XmlCommentsOperationFilter>(comments);
|
||||
options.ModelFilter<XmlCommentsModelFilter>(comments);
|
||||
});
|
||||
|
||||
services
|
||||
.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new Info
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "IO.Swagger",
|
||||
Description = "IO.Swagger (ASP.NET Core 1.0)"
|
||||
});
|
||||
c.CustomSchemaIds(type => type.FriendlyId(true));
|
||||
c.DescribeAllEnumsAsStrings();
|
||||
c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml");
|
||||
});
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
loggerFactory.AddDebug();
|
||||
loggerFactory
|
||||
.AddConsole(Configuration.GetSection("Logging"))
|
||||
.AddDebug();
|
||||
|
||||
app.UseMvc();
|
||||
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUi();
|
||||
app
|
||||
.UseMvc()
|
||||
.UseDefaultFiles()
|
||||
.UseStaticFiles()
|
||||
.UseSwagger()
|
||||
.UseSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "IO.Swagger");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,7 @@
|
||||
"Microsoft.Extensions.Logging.Debug": "1.0.0",
|
||||
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
|
||||
"Microsoft.EntityFrameworkCore": "1.0.0",
|
||||
"Swashbuckle.SwaggerGen": "6.0.0-beta901",
|
||||
"Swashbuckle.SwaggerUi": "6.0.0-beta901",
|
||||
"Swashbuckle.AspNetCore": "1.0.0-rc3",
|
||||
"Newtonsoft.Json": "9.0.1"
|
||||
},
|
||||
|
||||
|
@ -1 +1 @@
|
||||
<meta http-equiv="refresh" content="0;URL='./swagger/ui/index.html'" />
|
||||
<meta http-equiv="refresh" content="0;URL='./swagger/'" />
|
Loading…
x
Reference in New Issue
Block a user