[aspnet] Initial implementation of ASP.NET 5 server

Things to work on:

Gaps:

* Missing swagger definition functionality:
  - defaultResponse
  - examples
  - auth
  - consumes
  - produces
  - nickname
  - externalDocs
  - imports
  - security
  - schema
* Resolve allParams/hasMore issue with headerParams
* Create functional test project stub
* Resolve all issues with value type return values

In this commit:

* Initial cross-platform ASP.NET 5 API server
* Hook up swagger gen via Swashbuckle and xml comment
* Build script (*nix) in project root
* Dockerfile for container deployment
This commit is contained in:
Jim Schubert
2016-02-01 13:38:34 -05:00
parent cd1e9b0504
commit 455ba9d839
48 changed files with 3202 additions and 2 deletions

View File

@@ -313,6 +313,7 @@ AbstractJavaJAXRSServerCodegen.java
AbstractTypeScriptClientCodegen.java
AkkaScalaClientCodegen.java
AndroidClientCodegen.java
AspNet5WebApiServerCodegen.java
AsyncScalaClientCodegen.java
CSharpClientCodegen.java
ClojureClientCodegen.java
@@ -579,14 +580,22 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
```
### Haskell Servant
```
=======
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l haskell-servant \
-o samples/server/petstore/haskell-servant
```
### ASP.NET 5 Web API
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l aspnet5-webapi \
-o samples/server/petstore/aspnet5-webapi
```
### To build the codegen library
This will create the swagger-codegen library from source.

View File

@@ -0,0 +1,31 @@
#!/usr/bin/env bash
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -l aspnet5 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -o samples/server/petstore/aspnet5"
java $JAVA_OPTS -jar $executable $ags

View File

@@ -0,0 +1,513 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.*;
import io.swagger.models.properties.*;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
public class AspNet5ServerCodegen extends DefaultCodegen implements CodegenConfig {
protected boolean useDateTimeOffsetFlag = false;
protected String packageName = "IO.Swagger";
protected String packageVersion = "1.0.0";
protected boolean useCollection = false;
protected boolean returnICollection = false;
protected String sourceFolder = "src" + File.separator + packageName;
protected Set<String> collectionTypes;
protected Set<String> mapTypes;
@SuppressWarnings("hiding")
protected Logger LOGGER = LoggerFactory.getLogger(AspNet5ServerCodegen.class);
public AspNet5ServerCodegen() {
super();
outputFolder = "generated-code" + File.separator + "aspnet5";
embeddedTemplateDir = templateDir = "aspnet5";
modelTemplateFiles.put("model.mustache", ".cs");
apiTemplateFiles.put("controller.mustache", ".cs");
// TODO: Create a base C# abstract type to avoid duplication of language functionality
collectionTypes = new HashSet<String>(
Arrays.asList(
"IList", "List",
"ICollection", "Collection",
"IEnumerable")
);
mapTypes = new HashSet<String>(
Arrays.asList("IDictionary")
);
reservedWords = new HashSet<String>(
Arrays.asList(
// local variable names in API methods (endpoints)
"path_", "pathParams", "queryParams", "headerParams", "formParams", "fileParams",
"postBody", "http_header_accepts", "http_header_accept", "apiKeyValue", "response",
"statusCode",
// C# reserved words
"abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked",
"class", "const", "continue", "decimal", "default", "delegate", "do", "double", "else",
"enum", "event", "explicit", "extern", "false", "finally", "fixed", "float", "for",
"foreach", "goto", "if", "implicit", "in", "int", "interface", "internal", "is", "lock",
"long", "namespace", "new", "null", "object", "operator", "out", "override", "params",
"private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed",
"short", "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw",
"true", "try", "typeof", "uint", "ulong", "unchecked", "unsafe", "ushort", "using",
"virtual", "void", "volatile", "while")
);
languageSpecificPrimitives = new HashSet<String>(
Arrays.asList(
"String",
"string",
"bool?",
"double?",
"int?",
"long?",
"float?",
"byte[]",
"ICollection",
"Collection",
"List",
"Dictionary",
"DateTime?",
"DateTimeOffset?",
"String",
"Boolean",
"Double",
"Integer",
"Long",
"Float",
"Stream", // not really a primitive, we include it to avoid model import
"Object")
);
instantiationTypes.put("array", "List");
instantiationTypes.put("list", "List");
instantiationTypes.put("map", "Dictionary");
typeMapping = new HashMap<String, String>();
typeMapping.put("string", "string");
typeMapping.put("binary", "byte[]");
typeMapping.put("boolean", "bool?");
typeMapping.put("integer", "int?");
typeMapping.put("float", "float?");
typeMapping.put("long", "long?");
typeMapping.put("double", "double?");
typeMapping.put("number", "double?");
typeMapping.put("datetime", "DateTime?");
typeMapping.put("date", "DateTime?");
typeMapping.put("file", "Stream");
typeMapping.put("array", "List");
typeMapping.put("list", "List");
typeMapping.put("map", "Dictionary");
typeMapping.put("object", "Object");
cliOptions.clear();
addOption(CodegenConstants.PACKAGE_NAME,
"C# package name (convention: Title.Case).",
this.packageName);
addOption(CodegenConstants.PACKAGE_VERSION,
"C# package version.",
this.packageVersion);
addOption(CodegenConstants.SOURCE_FOLDER,
CodegenConstants.SOURCE_FOLDER_DESC,
sourceFolder);
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC,
Boolean.TRUE);
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC,
Boolean.TRUE);
addSwitch(CodegenConstants.USE_DATETIME_OFFSET,
CodegenConstants.USE_DATETIME_OFFSET_DESC,
Boolean.FALSE);
addSwitch(CodegenConstants.USE_COLLECTION,
CodegenConstants.USE_COLLECTION_DESC,
Boolean.FALSE);
addSwitch(CodegenConstants.RETURN_ICOLLECTION,
CodegenConstants.RETURN_ICOLLECTION_DESC,
Boolean.FALSE);
}
private void addOption(String key, String description, String defaultValue){
CliOption option = new CliOption(key, description);
if(defaultValue != null) option.defaultValue(defaultValue);
cliOptions.add(option);
}
private void addSwitch(String key, String description, Boolean defaultValue){
CliOption option = CliOption.newBoolean(key, description);
if(defaultValue != null) option.defaultValue(defaultValue.toString());
cliOptions.add(option);
}
@Override
public void processOpts() {
super.processOpts();
// {{packageVersion}}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} else {
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);
}
// {{sourceFolder}}
if (additionalProperties.containsKey(CodegenConstants.SOURCE_FOLDER)){
setSourceFolder((String) additionalProperties.get(CodegenConstants.SOURCE_FOLDER));
} else {
additionalProperties.put(CodegenConstants.SOURCE_FOLDER, this.sourceFolder);
}
// {{packageName}}
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} else {
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
}
apiPackage = packageName + ".Controllers";
modelPackage = packageName + ".Models";
// {{useDateTimeOffset}}
if (additionalProperties.containsKey(CodegenConstants.USE_DATETIME_OFFSET))
{
useDateTimeOffset(Boolean.valueOf(additionalProperties.get(CodegenConstants.USE_DATETIME_OFFSET).toString()));
}
additionalProperties.put(CodegenConstants.USE_DATETIME_OFFSET, useDateTimeOffsetFlag);
if (additionalProperties.containsKey(CodegenConstants.USE_COLLECTION)){
setUseCollection(Boolean.valueOf(additionalProperties.get(CodegenConstants.USE_COLLECTION).toString()));
}
if (additionalProperties.containsKey(CodegenConstants.RETURN_ICOLLECTION)){
setReturnICollection(Boolean.valueOf(additionalProperties.get(CodegenConstants.RETURN_ICOLLECTION).toString()));
}
supportingFiles.add(new SupportingFile("global.json", "", "global.json"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.sh"));
supportingFiles.add(new SupportingFile("Dockerfile.mustache", this.sourceFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("gitignore", this.sourceFolder, ".gitignore"));
supportingFiles.add(new SupportingFile("appsettings.json", this.sourceFolder, "appsettings.json"));
supportingFiles.add(new SupportingFile("project.mustache", this.sourceFolder, "project.json"));
supportingFiles.add(new SupportingFile("Startup.mustache", this.sourceFolder, "Startup.cs"));
supportingFiles.add(new SupportingFile("Properties"+File.separator +"launchSettings.json", this.sourceFolder + File.separator + "Properties", "launchSettings.json"));
supportingFiles.add(new SupportingFile("wwwroot" +File.separator + "README.md", this.sourceFolder + File.separator + "wwwroot", "README.md"));
supportingFiles.add(new SupportingFile("wwwroot" +File.separator + "index.html", this.sourceFolder + File.separator + "wwwroot", "index.html"));
supportingFiles.add(new SupportingFile("wwwroot" +File.separator + "web.config", this.sourceFolder + File.separator + "wwwroot", "web.config"));
}
public void useDateTimeOffset(boolean flag) {
this.useDateTimeOffsetFlag = flag;
if (flag) typeMapping.put("datetime", "DateTimeOffset?");
else typeMapping.put("datetime", "DateTime?");
}
public void setReturnICollection(boolean returnICollection) {
this.returnICollection = returnICollection;
}
public void setUseCollection(boolean useCollection) {
this.useCollection = useCollection;
if(useCollection){
typeMapping.put("array", "Collection");
typeMapping.put("list", "Collection");
instantiationTypes.put("array", "Collection");
instantiationTypes.put("list", "Collection");
}
}
@Override
public CodegenType getTag() { return CodegenType.SERVER; }
@Override
public String getName() { return "aspnet5"; }
@Override
public String getHelp() {
return "Generates an ASP.NET 5 Web API server.";
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "Controllers";
}
@Override
public String modelFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + "Models";
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String escapeReservedWord(String name) {
return "_" + name;
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String toVarName(String name) {
// sanitize name
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// if it's all uppper case, do nothing
if (name.matches("^[A-Z_]*$")) {
return name;
}
// camelize the variable name
// pet_id => PetId
name = camelize(name);
// for reserved word or word starting with number, append _
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
name = escapeReservedWord(name);
}
return name;
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String toParamName(String name) {
// replace - with _ e.g. created-at => created_at
name = name.replaceAll("-", "_");
// if it's all uppper case, do nothing
if (name.matches("^[A-Z_]*$")) {
return name;
}
// camelize(lower) the variable name
// pet_id => petId
name = camelize(name, true);
// for reserved word or word starting with number, append _
if (reservedWords.contains(name) || name.matches("^\\d.*")) {
name = escapeReservedWord(name);
}
return name;
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String toModelName(String name) {
// model name cannot use reserved keyword, e.g. return
if (reservedWords.contains(name)) {
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
}
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String toModelFilename(String name) {
// should be the same as the model name
return toModelName(name);
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
super.postProcessOperations(objs);
if(objs != null) {
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
if (operations != null) {
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
for (CodegenOperation operation : ops) {
// HACK: Unlikely in the wild, but we need to clean operation paths for MVC Routing
if(operation.path != null){
String original = operation.path;
operation.path = operation.path.replace("?", "/");
if(!original.equals(operation.path)){
LOGGER.warn("Normalized " + original + " to " + operation.path + ". Please verify generated source.");
}
}
// Check return types for collection
if (operation.returnType != null) {
String typeMapping;
int namespaceEnd = operation.returnType.lastIndexOf(".");
if(namespaceEnd > 0) {
typeMapping = operation.returnType.substring(namespaceEnd);
} else {
typeMapping = operation.returnType;
}
if(this.collectionTypes.contains(typeMapping)){
operation.isListContainer = true;
operation.returnContainer = operation.returnType;
if( this.returnICollection && (
typeMapping.startsWith("List")||
typeMapping.startsWith("Collection")) ) {
// NOTE: ICollection works for both List<T> and Collection<T>
int genericStart = typeMapping.indexOf("<");
if(genericStart > 0) {
operation.returnType = "ICollection" + typeMapping.substring(genericStart);
}
}
} else {
operation.returnContainer = operation.returnType;
operation.isMapContainer = this.mapTypes.contains(typeMapping);
}
}
// Converts, for example, PUT to HttpPut for controller attributes
operation.httpMethod = "Http" + operation.httpMethod.substring(0,1) + operation.httpMethod.substring(1).toLowerCase();
}
}
}
return objs;
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String getTypeDeclaration(Property p) {
if (p instanceof ArrayProperty) {
ArrayProperty ap = (ArrayProperty) p;
Property inner = ap.getItems();
return getSwaggerType(p) + "<" + getTypeDeclaration(inner) + ">";
} else if (p instanceof MapProperty) {
MapProperty mp = (MapProperty) p;
Property inner = mp.getAdditionalProperties();
return getSwaggerType(p) + "<string, " + getTypeDeclaration(inner) + ">";
}
return super.getTypeDeclaration(p);
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
String type = null;
if (typeMapping.containsKey(swaggerType.toLowerCase())) {
type = typeMapping.get(swaggerType.toLowerCase());
if (languageSpecificPrimitives.contains(type)) {
return type;
}
} else {
type = swaggerType;
}
return toModelName(type);
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public String toOperationId(String operationId) {
// throw exception if method name is empty
if (StringUtils.isEmpty(operationId)) {
throw new RuntimeException("Empty method name (operationId) not allowed");
}
// method name cannot use reserved keyword, e.g. return
if (reservedWords.contains(operationId)) {
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
}
return camelize(sanitizeName(operationId));
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
@Override
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
List<Object> models = (List<Object>) objs.get("models");
for (Object _mo : models) {
Map<String, Object> mo = (Map<String, Object>) _mo;
CodegenModel cm = (CodegenModel) mo.get("model");
for (CodegenProperty var : cm.vars) {
// check to see if model name is same as the property name
// which will result in compilation error
// if found, prepend with _ to workaround the limitation
if (var.name.equals(cm.name)) {
var.name = "_" + var.name;
}
}
}
return objs;
}
// TODO: Create a base C# abstract type to avoid duplication of language functionality
/**
* Return the default value of the property
*
* @param p Swagger property object
* @return string presentation of the default value of the property
*/
@Override
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
StringProperty dp = (StringProperty) p;
if (dp.getDefault() != null) {
return "\"" + dp.getDefault().toString() + "\"";
}
} else if (p instanceof BooleanProperty) {
BooleanProperty dp = (BooleanProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof DateProperty) {
// TODO
} else if (p instanceof DateTimeProperty) {
// TODO
} else if (p instanceof DoubleProperty) {
DoubleProperty dp = (DoubleProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof FloatProperty) {
FloatProperty dp = (FloatProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof IntegerProperty) {
IntegerProperty dp = (IntegerProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof LongProperty) {
LongProperty dp = (LongProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
}
return null;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}
public void setPackageVersion(String packageVersion) {
this.packageVersion = packageVersion;
}
public void setSourceFolder(String sourceFolder) {
this.sourceFolder = sourceFolder;
}
}

View File

@@ -1,4 +1,5 @@
io.swagger.codegen.languages.AndroidClientCodegen
io.swagger.codegen.languages.AspNet5ServerCodegen
io.swagger.codegen.languages.AsyncScalaClientCodegen
io.swagger.codegen.languages.CSharpClientCodegen
io.swagger.codegen.languages.DartClientCodegen

View File

@@ -0,0 +1,10 @@
FROM microsoft/aspnet:1.0.0-rc1-final
RUN mkdir -p /app/{{packageName}}
COPY . /app/{{packageName}}
WORKDIR /app/{{packageName}}
RUN ["dnu", "restore"]
RUN ["dnu", "pack", "--out", "artifacts"]
EXPOSE 5000/tcp
ENTRYPOINT ["dnx", "-p", "project.json", "web"]

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger/ui",
"environmentVariables": {
"ASPNET_ENV": "Development"
}
}
}
}

View File

@@ -0,0 +1,136 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using Newtonsoft.Json.Serialization;
using Swashbuckle.SwaggerGen;
using Swashbuckle.SwaggerGen.XmlComments;
namespace {{packageName}}
{
public class Startup
{
private readonly IHostingEnvironment _hostingEnv;
private readonly IApplicationEnvironment _appEnv;
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
_hostingEnv = env;
_appEnv = appEnv;
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
string xmlComments = string.Format(@"{0}{4}artifacts{4}{1}{4}{2}{3}{4}{{packageName}}.xml",
GetSolutionBasePath(),
_appEnv.Configuration,
_appEnv.RuntimeFramework.Identifier.ToLower(),
_appEnv.RuntimeFramework.Version.ToString().Replace(".", string.Empty),
Path.DirectorySeparatorChar);
// Add framework services.
services.AddMvc()
.AddJsonOptions(
opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
// services.AddWebApiConventions();
services.AddSwaggerGen();
services.ConfigureSwaggerDocument(options =>
{
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "{{packageName}}",
Description = "{{packageName}} (ASP.NET 5 Web API 2.x)"
});
options.OperationFilter(new ApplyXmlActionCommentsFixed(xmlComments));
});
services.ConfigureSwaggerSchema(options => {
options.DescribeAllEnumsAsStrings = true;
options.ModelFilter(new ApplyXmlTypeCommentsFixed(xmlComments));
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseIISPlatformHandler();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
app.UseSwaggerGen();
app.UseSwaggerUi();
}
// Taken from https://github.com/domaindrivendev/Ahoy/blob/master/test/WebSites/Basic/Startup.cs
private string GetSolutionBasePath()
{
var dir = Directory.CreateDirectory(_appEnv.ApplicationBasePath);
while (dir.Parent != null)
{
if (dir.GetDirectories("artifacts").Any())
return dir.FullName;
dir = dir.Parent;
}
throw new InvalidOperationException("Failed to detect solution base path - artifacts not found. Did you run dnu pack --out artifacts?");
}
// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
// using Swashbuckle.SwaggerGen.XmlComments;
public class ApplyXmlTypeCommentsFixed : ApplyXmlTypeComments
{
public ApplyXmlTypeCommentsFixed() : base("")
{
throw new NotImplementedException();
}
public ApplyXmlTypeCommentsFixed(string filePath): base(filePath)
{
}
}
public class ApplyXmlActionCommentsFixed : ApplyXmlActionComments
{
public ApplyXmlActionCommentsFixed() : base("")
{
throw new NotImplementedException();
}
public ApplyXmlActionCommentsFixed(string filePath): base(filePath)
{
}
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@@ -0,0 +1 @@
{{#isBodyParam}}[FromBody]{{&dataType}} {{paramName}}{{/isBodyParam}}

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
if ! type dnvm > /dev/null 2>&1; then
source /usr/local/lib/dnx/bin/dnvm.sh
fi
if ! type dnu > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
dnvm install latest -runtime coreclr -alias default
dnvm install default -runtime mono -alias default
else
dnvm use default -runtime mono
fi
dnu restore src/{{packageName}}/ && \
dnu build src/{{packageName}}/ && \
dnu pack src/{{packageName}}/ --out artifacts && \
echo "Now, run the following to start the project: dnx --project src/{{packageName}}/project.json web"

View File

@@ -0,0 +1,45 @@
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.AspNet.Mvc;
using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations;
using {{packageName}}.Models;
namespace {{packageName}}.Controllers
{ {{#operations}}
/// <summary>
/// {{description}}
/// </summary>{{#description}}{{#basePath}}
[Route("{{basePath}}")]
{{/basePath}}[Description("{{description}}")]{{/description}}
public class {{classname}}Controller : Controller
{ {{#operation}}
/// <summary>
/// {{#summary}}{{summary}}{{/summary}}
/// </summary>
{{#notes}}/// <remarks>{{notes}}</remarks>{{/notes}}{{#allParams}}
/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}{{#responses}}
/// <response code="{{code}}">{{message}}</response>{{/responses}}
[{{httpMethod}}]
[Route("{{path}}")]
[SwaggerOperation("{{operationId}}")]{{#returnType}}
[SwaggerResponse(200, type: typeof({{&returnType}}))]{{/returnType}}
public {{#returnType}}IActionResult{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{ {{#returnType}}
string exampleJson = null;
{{#isListCollection}}{{>listReturn}}{{/isListCollection}}{{^isListCollection}}{{#isMapContainer}}{{>mapReturn}}{{/isMapContainer}}{{^isMapContainer}}{{>objectReturn}}{{/isMapContainer}}{{/isListCollection}}
{{!TODO: defaultResponse, examples, auth, consumes, produces, nickname, externalDocs, imports, security}}
return new ObjectResult(example);{{/returnType}}{{^returnType}}
throw new NotImplementedException();{{/returnType}}
}
{{/operation}}
}
{{/operations}}
}

View File

@@ -0,0 +1 @@
{{#isFormParam}}[FromForm]{{&dataType}} {{paramName}}{{/isFormParam}}

View File

@@ -0,0 +1,208 @@
PID
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
bower_components/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt

View File

@@ -0,0 +1,8 @@
{
"projects": [ "src", "." ],
"sdk": {
"version": "1.0.0-rc1-final",
"runtime": "coreclr",
"architecture": "x64"
}
}

View File

@@ -0,0 +1 @@
{{#isHeaderParam}}[FromHeader]{{&dataType}} {{paramName}}{{/isHeaderParam}}

View File

@@ -0,0 +1,4 @@
var example = exampleJson != null
? JsonConvert.DeserializeObject<{{returnContainer}}<{{#returnType}}{{{returnType}}}{{/returnType}}>>(exampleJson)
: Enumerable.Empty<{{#returnType}}{{{returnType}}}{{/returnType}}>();

View File

@@ -0,0 +1,4 @@
var example = exampleJson != null
? JsonConvert.DeserializeObject<Dictionary<{{#returnType}}{{{returnType}}}{{/returnType}}>>(exampleJson)
: new Dictionary<{{#returnType}}{{{returnType}}}{{/returnType}}>();

View File

@@ -0,0 +1,134 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
{{#models}}
{{#model}}
namespace {{packageName}}.Models
{
/// <summary>
/// {{description}}
/// </summary>
public class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}>
{
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary>
public {{classname}}()
{
{{#vars}}{{#defaultValue}}this.{{name}} = {{{defaultValue}}};
{{/defaultValue}}{{/vars}}
}
{{#vars}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
/// </summary>{{#description}}
/// <value>{{{description}}}</value>{{/description}}
public {{{datatype}}} {{name}} { get; set; }
{{/vars}}
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class {{classname}} {\n");
{{#vars}}sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
{{/vars}}
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public {{#parent}} new {{/parent}}string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals(({{classname}})obj);
}
/// <summary>
/// Returns true if {{classname}} instances are equal
/// </summary>
/// <param name="other">Instance of {{classname}} to be compared</param>
/// <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}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}}
(
this.{{name}} == other.{{name}} ||
this.{{name}} != null &&
this.{{name}}.SequenceEqual(other.{{name}})
){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}{{^vars}}false{{/vars}};
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
{{#vars}}
if (this.{{name}} != null)
hash = hash * 59 + this.{{name}}.GetHashCode();
{{/vars}}
return hash;
}
}
#region Operators
public static bool operator ==({{classname}} left, {{classname}} right)
{
return Equals(left, right);
}
public static bool operator !=({{classname}} left, {{classname}} right)
{
return !Equals(left, right);
}
#endregion Operators
}
{{/model}}
{{/models}}
}

View File

@@ -0,0 +1,4 @@
var example = exampleJson != null
? JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}>(exampleJson)
: default({{#returnType}}{{{returnType}}}{{/returnType}});

View File

@@ -0,0 +1 @@
{{#isPathParam}}[FromRoute]{{&dataType}} {{paramName}}{{/isPathParam}}

View File

@@ -0,0 +1,41 @@
{
"version": "{{packageVersion}}-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "{{packageName}}"
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug" : "1.0.0-rc1-final",
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}

View File

@@ -0,0 +1 @@
{{#isQueryParam}}[FromQuery]{{&dataType}} {{paramName}}{{/isQueryParam}}

View File

@@ -0,0 +1 @@
{{!TODO: Need iterable tags object...}}{{#tags}}, Tags = new[] { {{/tags}}"{{#tags}}{{tag}} {{/tags}}"{{#tags}} }{{/tags}}

View File

@@ -0,0 +1,42 @@
# Welcome to ASP.NET 5 Preview
We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new.
ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854).
Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks).
We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015.
The ASP.NET Team
### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016)
### This application consists of:
* Sample pages using ASP.NET MVC 6
* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources
* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939)
#### NEW CONCEPTS
* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008)
* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012)
* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013)
* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014)
* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849)
* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850)
#### CUSTOMIZE APP
* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600)
* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602)
* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603)
* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606)
* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604)
* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009)
* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848)
#### DEPLOY
* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851)
* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852)
* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853)
* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609)
* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019)
We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015)

View File

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

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>
</configuration>

View File

@@ -0,0 +1,44 @@
package io.swagger.codegen.aspnet5;
import io.swagger.codegen.AbstractOptionsTest;
import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.languages.AspNet5ServerCodegen;
import io.swagger.codegen.languages.CSharpClientCodegen;
import io.swagger.codegen.options.AspNet5ServerOptionsProvider;
import io.swagger.codegen.options.CSharpClientOptionsProvider;
import mockit.Expectations;
import mockit.Tested;
public class AspNet5ServerOptionsTest extends AbstractOptionsTest {
@Tested
private AspNet5ServerCodegen serverCodegen;
public AspNet5ServerOptionsTest() {
super(new AspNet5ServerOptionsProvider());
}
@Override
protected CodegenConfig getCodegenConfig() {
return serverCodegen;
}
@SuppressWarnings("unused")
@Override
protected void setExpectations() {
new Expectations(serverCodegen) {{
serverCodegen.setPackageName(AspNet5ServerOptionsProvider.PACKAGE_NAME_VALUE);
times = 1;
serverCodegen.setPackageVersion(AspNet5ServerOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;
serverCodegen.setSourceFolder(AspNet5ServerOptionsProvider.SOURCE_FOLDER_VALUE);
times = 1;
serverCodegen.useDateTimeOffset(true);
times = 1;
serverCodegen.setUseCollection(false);
times = 1;
serverCodegen.setReturnICollection(false);
times = 1;
}};
}
}

View File

@@ -0,0 +1,35 @@
package io.swagger.codegen.options;
import com.google.common.collect.ImmutableMap;
import io.swagger.codegen.CodegenConstants;
import java.util.Map;
public class AspNet5ServerOptionsProvider implements OptionsProvider {
public static final String PACKAGE_NAME_VALUE = "swagger_server_aspnet5";
public static final String PACKAGE_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String SOURCE_FOLDER_VALUE = "src_aspnet5";
@Override
public String getLanguage() {
return "aspnet5";
}
@Override
public Map<String, String> createOptions() {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true")
.put(CodegenConstants.USE_DATETIME_OFFSET, "true")
.put(CodegenConstants.USE_COLLECTION, "false")
.put(CodegenConstants.RETURN_ICOLLECTION, "false")
.build();
}
@Override
public boolean isServer() {
return true;
}
}

View File

@@ -0,0 +1 @@
artifacts/

View File

@@ -0,0 +1,17 @@
#!/usr/bin/env bash
if ! type dnvm > /dev/null 2>&1; then
source /usr/local/lib/dnx/bin/dnvm.sh
fi
if ! type dnu > /dev/null 2>&1 || [ -z "$SKIP_DNX_INSTALL" ]; then
dnvm install latest -runtime coreclr -alias default
dnvm install default -runtime mono -alias default
else
dnvm use default -runtime mono
fi
dnu restore src/IO.Swagger/ && \
dnu build src/IO.Swagger/ && \
dnu pack src/IO.Swagger/ --out artifacts && \
echo "Now, run the following to start the project: dnx --project src/IO.Swagger/project.json web"

View File

@@ -0,0 +1,8 @@
{
"projects": [ "src", "." ],
"sdk": {
"version": "1.0.0-rc1-final",
"runtime": "coreclr",
"architecture": "x64"
}
}

View File

@@ -0,0 +1,208 @@
PID
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
# Visual Studio 2015 cache/options directory
.vs/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile
# Visual Studio profiler
*.psess
*.vsp
*.vspx
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# Windows Azure Build Output
csx/
*.build.csdef
# Windows Store app package directory
AppPackages/
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
bower_components/
orleans.codegen.cs
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt

View File

@@ -0,0 +1,212 @@
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.AspNet.Mvc;
using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations;
using IO.Swagger.Models;
namespace IO.Swagger.Controllers
{
/// <summary>
///
/// </summary>
public class PetApiController : Controller
{
/// <summary>
/// Update an existing pet
/// </summary>
/// <remarks></remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Pet not found</response>
/// <response code="405">Validation exception</response>
[HttpPut]
[Route("/pet")]
[SwaggerOperation("UpdatePet")]
public void UpdatePet([FromBody]Pet body)
{
throw new NotImplementedException();
}
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <remarks></remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <response code="405">Invalid input</response>
[HttpPost]
[Route("/pet")]
[SwaggerOperation("AddPet")]
public void AddPet([FromBody]Pet body)
{
throw new NotImplementedException();
}
/// <summary>
/// Finds Pets by status
/// </summary>
/// <remarks>Multiple status values can be provided with comma seperated strings</remarks>
/// <param name="status">Status values that need to be considered for filter</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid status value</response>
[HttpGet]
[Route("/pet/findByStatus")]
[SwaggerOperation("FindPetsByStatus")]
[SwaggerResponse(200, type: typeof(List<Pet>))]
public IActionResult FindPetsByStatus([FromQuery]List<string> status)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
: default(List<Pet>);
return new ObjectResult(example);
}
/// <summary>
/// Finds Pets by tags
/// </summary>
/// <remarks>Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.</remarks>
/// <param name="tags">Tags to filter by</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid tag value</response>
[HttpGet]
[Route("/pet/findByTags")]
[SwaggerOperation("FindPetsByTags")]
[SwaggerResponse(200, type: typeof(List<Pet>))]
public IActionResult FindPetsByTags([FromQuery]List<string> tags)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
: default(List<Pet>);
return new ObjectResult(example);
}
/// <summary>
/// Find pet by ID
/// </summary>
/// <remarks>Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions</remarks>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Pet not found</response>
[HttpGet]
[Route("/pet/{petId}")]
[SwaggerOperation("GetPetById")]
[SwaggerResponse(200, type: typeof(Pet))]
public IActionResult GetPetById([FromRoute]long? petId)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<Pet>(exampleJson)
: default(Pet);
return new ObjectResult(example);
}
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <remarks></remarks>
/// <param name="petId">ID of pet that needs to be updated</param>
/// <param name="name">Updated name of the pet</param>
/// <param name="status">Updated status of the pet</param>
/// <response code="405">Invalid input</response>
[HttpPost]
[Route("/pet/{petId}")]
[SwaggerOperation("UpdatePetWithForm")]
public void UpdatePetWithForm([FromRoute]string petId, [FromForm]string name, [FromForm]string status)
{
throw new NotImplementedException();
}
/// <summary>
/// Deletes a pet
/// </summary>
/// <remarks></remarks>
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <response code="400">Invalid pet value</response>
[HttpDelete]
[Route("/pet/{petId}")]
[SwaggerOperation("DeletePet")]
public void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey)
{
throw new NotImplementedException();
}
/// <summary>
/// uploads an image
/// </summary>
/// <remarks></remarks>
/// <param name="petId">ID of pet to update</param>
/// <param name="additionalMetadata">Additional data to pass to server</param>
/// <param name="file">file to upload</param>
/// <response code="0">successful operation</response>
[HttpPost]
[Route("/pet/{petId}/uploadImage")]
[SwaggerOperation("UploadFile")]
public void UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]Stream file)
{
throw new NotImplementedException();
}
/// <summary>
/// Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
/// </summary>
/// <remarks>Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions</remarks>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Pet not found</response>
[HttpGet]
[Route("/pet/{petId}/testing_byte_array=true")]
[SwaggerOperation("GetPetByIdWithByteArray")]
[SwaggerResponse(200, type: typeof(byte[]))]
public IActionResult GetPetByIdWithByteArray([FromRoute]long? petId)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<byte[]>(exampleJson)
: default(byte[]);
return new ObjectResult(example);
}
/// <summary>
/// Fake endpoint to test byte array in body parameter for adding a new pet to the store
/// </summary>
/// <remarks></remarks>
/// <param name="body">Pet object in the form of byte array</param>
/// <response code="405">Invalid input</response>
[HttpPost]
[Route("/pet/testing_byte_array=true")]
[SwaggerOperation("AddPetUsingByteArray")]
public void AddPetUsingByteArray([FromBody]byte[] body)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,105 @@
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.AspNet.Mvc;
using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations;
using IO.Swagger.Models;
namespace IO.Swagger.Controllers
{
/// <summary>
///
/// </summary>
public class StoreApiController : Controller
{
/// <summary>
/// Returns pet inventories by status
/// </summary>
/// <remarks>Returns a map of status codes to quantities</remarks>
/// <response code="200">successful operation</response>
[HttpGet]
[Route("/store/inventory")]
[SwaggerOperation("GetInventory")]
[SwaggerResponse(200, type: typeof(Dictionary<string, int?>))]
public IActionResult GetInventory()
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<Dictionary<string, int?>>(exampleJson)
: default(Dictionary<string, int?>);
return new ObjectResult(example);
}
/// <summary>
/// Place an order for a pet
/// </summary>
/// <remarks></remarks>
/// <param name="body">order placed for purchasing the pet</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid Order</response>
[HttpPost]
[Route("/store/order")]
[SwaggerOperation("PlaceOrder")]
[SwaggerResponse(200, type: typeof(Order))]
public IActionResult PlaceOrder([FromBody]Order body)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<Order>(exampleJson)
: default(Order);
return new ObjectResult(example);
}
/// <summary>
/// Find purchase order by ID
/// </summary>
/// <remarks>For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions</remarks>
/// <param name="orderId">ID of pet that needs to be fetched</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Order not found</response>
[HttpGet]
[Route("/store/order/{orderId}")]
[SwaggerOperation("GetOrderById")]
[SwaggerResponse(200, type: typeof(Order))]
public IActionResult GetOrderById([FromRoute]string orderId)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<Order>(exampleJson)
: default(Order);
return new ObjectResult(example);
}
/// <summary>
/// Delete purchase order by ID
/// </summary>
/// <remarks>For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors</remarks>
/// <param name="orderId">ID of the order that needs to be deleted</param>
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Order not found</response>
[HttpDelete]
[Route("/store/order/{orderId}")]
[SwaggerOperation("DeleteOrder")]
public void DeleteOrder([FromRoute]string orderId)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,161 @@
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.AspNet.Mvc;
using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations;
using IO.Swagger.Models;
namespace IO.Swagger.Controllers
{
/// <summary>
///
/// </summary>
public class UserApiController : Controller
{
/// <summary>
/// Create user
/// </summary>
/// <remarks>This can only be done by the logged in user.</remarks>
/// <param name="body">Created user object</param>
/// <response code="0">successful operation</response>
[HttpPost]
[Route("/user")]
[SwaggerOperation("CreateUser")]
public void CreateUser([FromBody]User body)
{
throw new NotImplementedException();
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <remarks></remarks>
/// <param name="body">List of user object</param>
/// <response code="0">successful operation</response>
[HttpPost]
[Route("/user/createWithArray")]
[SwaggerOperation("CreateUsersWithArrayInput")]
public void CreateUsersWithArrayInput([FromBody]List<User> body)
{
throw new NotImplementedException();
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <remarks></remarks>
/// <param name="body">List of user object</param>
/// <response code="0">successful operation</response>
[HttpPost]
[Route("/user/createWithList")]
[SwaggerOperation("CreateUsersWithListInput")]
public void CreateUsersWithListInput([FromBody]List<User> body)
{
throw new NotImplementedException();
}
/// <summary>
/// Logs user into the system
/// </summary>
/// <remarks></remarks>
/// <param name="username">The user name for login</param>
/// <param name="password">The password for login in clear text</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid username/password supplied</response>
[HttpGet]
[Route("/user/login")]
[SwaggerOperation("LoginUser")]
[SwaggerResponse(200, type: typeof(string))]
public IActionResult LoginUser([FromQuery]string username, [FromQuery]string password)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<string>(exampleJson)
: default(string);
return new ObjectResult(example);
}
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <remarks></remarks>
/// <response code="0">successful operation</response>
[HttpGet]
[Route("/user/logout")]
[SwaggerOperation("LogoutUser")]
public void LogoutUser()
{
throw new NotImplementedException();
}
/// <summary>
/// Get user by user name
/// </summary>
/// <remarks></remarks>
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
/// <response code="200">successful operation</response>
/// <response code="400">Invalid username supplied</response>
/// <response code="404">User not found</response>
[HttpGet]
[Route("/user/{username}")]
[SwaggerOperation("GetUserByName")]
[SwaggerResponse(200, type: typeof(User))]
public IActionResult GetUserByName([FromRoute]string username)
{
string exampleJson = null;
var example = exampleJson != null
? JsonConvert.DeserializeObject<User>(exampleJson)
: default(User);
return new ObjectResult(example);
}
/// <summary>
/// Updated user
/// </summary>
/// <remarks>This can only be done by the logged in user.</remarks>
/// <param name="username">name that need to be deleted</param>
/// <param name="body">Updated user object</param>
/// <response code="400">Invalid user supplied</response>
/// <response code="404">User not found</response>
[HttpPut]
[Route("/user/{username}")]
[SwaggerOperation("UpdateUser")]
public void UpdateUser([FromRoute]string username, [FromBody]User body)
{
throw new NotImplementedException();
}
/// <summary>
/// Delete user
/// </summary>
/// <remarks>This can only be done by the logged in user.</remarks>
/// <param name="username">The name that needs to be deleted</param>
/// <response code="400">Invalid username supplied</response>
/// <response code="404">User not found</response>
[HttpDelete]
[Route("/user/{username}")]
[SwaggerOperation("DeleteUser")]
public void DeleteUser([FromRoute]string username)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,10 @@
FROM microsoft/aspnet:1.0.0-rc1-final
RUN mkdir -p /app/IO.Swagger
COPY . /app/IO.Swagger
WORKDIR /app/IO.Swagger
RUN ["dnu", "restore"]
RUN ["dnu", "pack", "--out", "artifacts"]
EXPOSE 5000/tcp
ENTRYPOINT ["dnx", "-p", "project.json", "web"]

View File

@@ -0,0 +1,138 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Models
{
/// <summary>
///
/// </summary>
public class Category : IEquatable<Category>
{
/// <summary>
/// Initializes a new instance of the <see cref="Category" /> class.
/// </summary>
public Category()
{
}
/// <summary>
/// Gets or Sets Id
/// </summary>
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Category {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Category)obj);
}
/// <summary>
/// Returns true if Category instances are equal
/// </summary>
/// <param name="other">Instance of Category to be compared</param>
/// <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)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int 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();
return hash;
}
}
#region Operators
public static bool operator ==(Category left, Category right)
{
return Equals(left, right);
}
public static bool operator !=(Category left, Category right)
{
return !Equals(left, right);
}
#endregion Operators
}
}

View File

@@ -0,0 +1,199 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Models
{
/// <summary>
///
/// </summary>
public class Order : IEquatable<Order>
{
/// <summary>
/// Initializes a new instance of the <see cref="Order" /> class.
/// </summary>
public Order()
{
}
/// <summary>
/// Gets or Sets Id
/// </summary>
public long? Id { get; set; }
/// <summary>
/// Gets or Sets PetId
/// </summary>
public long? PetId { get; set; }
/// <summary>
/// Gets or Sets Quantity
/// </summary>
public int? Quantity { get; set; }
/// <summary>
/// Gets or Sets ShipDate
/// </summary>
public DateTime? ShipDate { get; set; }
/// <summary>
/// Order Status
/// </summary>
/// <value>Order Status</value>
public string Status { get; set; }
/// <summary>
/// Gets or Sets Complete
/// </summary>
public bool? Complete { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Order {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" PetId: ").Append(PetId).Append("\n");
sb.Append(" Quantity: ").Append(Quantity).Append("\n");
sb.Append(" ShipDate: ").Append(ShipDate).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append(" Complete: ").Append(Complete).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Order)obj);
}
/// <summary>
/// Returns true if Order instances are equal
/// </summary>
/// <param name="other">Instance of Order to be compared</param>
/// <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)
) &&
(
this.PetId == other.PetId ||
this.PetId != null &&
this.PetId.Equals(other.PetId)
) &&
(
this.Quantity == other.Quantity ||
this.Quantity != null &&
this.Quantity.Equals(other.Quantity)
) &&
(
this.ShipDate == other.ShipDate ||
this.ShipDate != null &&
this.ShipDate.Equals(other.ShipDate)
) &&
(
this.Status == other.Status ||
this.Status != null &&
this.Status.Equals(other.Status)
) &&
(
this.Complete == other.Complete ||
this.Complete != null &&
this.Complete.Equals(other.Complete)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int 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();
return hash;
}
}
#region Operators
public static bool operator ==(Order left, Order right)
{
return Equals(left, right);
}
public static bool operator !=(Order left, Order right)
{
return !Equals(left, right);
}
#endregion Operators
}
}

View File

@@ -0,0 +1,199 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Models
{
/// <summary>
///
/// </summary>
public class Pet : IEquatable<Pet>
{
/// <summary>
/// Initializes a new instance of the <see cref="Pet" /> class.
/// </summary>
public Pet()
{
}
/// <summary>
/// Gets or Sets Id
/// </summary>
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
public Category Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or Sets PhotoUrls
/// </summary>
public List<string> PhotoUrls { get; set; }
/// <summary>
/// Gets or Sets Tags
/// </summary>
public List<Tag> Tags { get; set; }
/// <summary>
/// pet status in the store
/// </summary>
/// <value>pet status in the store</value>
public string Status { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Pet {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
sb.Append(" Tags: ").Append(Tags).Append("\n");
sb.Append(" Status: ").Append(Status).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Pet)obj);
}
/// <summary>
/// Returns true if Pet instances are equal
/// </summary>
/// <param name="other">Instance of Pet to be compared</param>
/// <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)
) &&
(
this.Category == other.Category ||
this.Category != null &&
this.Category.Equals(other.Category)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
) &&
(
this.PhotoUrls == other.PhotoUrls ||
this.PhotoUrls != null &&
this.PhotoUrls.SequenceEqual(other.PhotoUrls)
) &&
(
this.Tags == other.Tags ||
this.Tags != null &&
this.Tags.SequenceEqual(other.Tags)
) &&
(
this.Status == other.Status ||
this.Status != null &&
this.Status.Equals(other.Status)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int 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();
return hash;
}
}
#region Operators
public static bool operator ==(Pet left, Pet right)
{
return Equals(left, right);
}
public static bool operator !=(Pet left, Pet right)
{
return !Equals(left, right);
}
#endregion Operators
}
}

View File

@@ -0,0 +1,138 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Models
{
/// <summary>
///
/// </summary>
public class Tag : IEquatable<Tag>
{
/// <summary>
/// Initializes a new instance of the <see cref="Tag" /> class.
/// </summary>
public Tag()
{
}
/// <summary>
/// Gets or Sets Id
/// </summary>
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class Tag {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Tag)obj);
}
/// <summary>
/// Returns true if Tag instances are equal
/// </summary>
/// <param name="other">Instance of Tag to be compared</param>
/// <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)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int 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();
return hash;
}
}
#region Operators
public static bool operator ==(Tag left, Tag right)
{
return Equals(left, right);
}
public static bool operator !=(Tag left, Tag right)
{
return !Equals(left, right);
}
#endregion Operators
}
}

View File

@@ -0,0 +1,229 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Models
{
/// <summary>
///
/// </summary>
public class User : IEquatable<User>
{
/// <summary>
/// Initializes a new instance of the <see cref="User" /> class.
/// </summary>
public User()
{
}
/// <summary>
/// Gets or Sets Id
/// </summary>
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Username
/// </summary>
public string Username { get; set; }
/// <summary>
/// Gets or Sets FirstName
/// </summary>
public string FirstName { get; set; }
/// <summary>
/// Gets or Sets LastName
/// </summary>
public string LastName { get; set; }
/// <summary>
/// Gets or Sets Email
/// </summary>
public string Email { get; set; }
/// <summary>
/// Gets or Sets Password
/// </summary>
public string Password { get; set; }
/// <summary>
/// Gets or Sets Phone
/// </summary>
public string Phone { get; set; }
/// <summary>
/// User Status
/// </summary>
/// <value>User Status</value>
public int? UserStatus { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class User {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Username: ").Append(Username).Append("\n");
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
sb.Append(" LastName: ").Append(LastName).Append("\n");
sb.Append(" Email: ").Append(Email).Append("\n");
sb.Append(" Password: ").Append(Password).Append("\n");
sb.Append(" Phone: ").Append(Phone).Append("\n");
sb.Append(" UserStatus: ").Append(UserStatus).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((User)obj);
}
/// <summary>
/// Returns true if User instances are equal
/// </summary>
/// <param name="other">Instance of User to be compared</param>
/// <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)
) &&
(
this.Username == other.Username ||
this.Username != null &&
this.Username.Equals(other.Username)
) &&
(
this.FirstName == other.FirstName ||
this.FirstName != null &&
this.FirstName.Equals(other.FirstName)
) &&
(
this.LastName == other.LastName ||
this.LastName != null &&
this.LastName.Equals(other.LastName)
) &&
(
this.Email == other.Email ||
this.Email != null &&
this.Email.Equals(other.Email)
) &&
(
this.Password == other.Password ||
this.Password != null &&
this.Password.Equals(other.Password)
) &&
(
this.Phone == other.Phone ||
this.Phone != null &&
this.Phone.Equals(other.Phone)
) &&
(
this.UserStatus == other.UserStatus ||
this.UserStatus != null &&
this.UserStatus.Equals(other.UserStatus)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int 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();
return hash;
}
}
#region Operators
public static bool operator ==(User left, User right)
{
return Equals(left, right);
}
public static bool operator !=(User left, User right)
{
return !Equals(left, right);
}
#endregion Operators
}
}

View File

@@ -0,0 +1,12 @@
{
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger/ui",
"environmentVariables": {
"ASPNET_ENV": "Development"
}
}
}
}

View File

@@ -0,0 +1,136 @@
using System;
using System.IO;
using System.Linq;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using Newtonsoft.Json.Serialization;
using Swashbuckle.SwaggerGen;
using Swashbuckle.SwaggerGen.XmlComments;
namespace IO.Swagger
{
public class Startup
{
private readonly IHostingEnvironment _hostingEnv;
private readonly IApplicationEnvironment _appEnv;
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
{
_hostingEnv = env;
_appEnv = appEnv;
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
string xmlComments = string.Format(@"{0}{4}artifacts{4}{1}{4}{2}{3}{4}IO.Swagger.xml",
GetSolutionBasePath(),
_appEnv.Configuration,
_appEnv.RuntimeFramework.Identifier.ToLower(),
_appEnv.RuntimeFramework.Version.ToString().Replace(".", string.Empty),
Path.DirectorySeparatorChar);
// Add framework services.
services.AddMvc()
.AddJsonOptions(
opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });
// Uncomment the following line to add Web API services which makes it easier to port Web API 2 controllers.
// You will also need to add the Microsoft.AspNet.Mvc.WebApiCompatShim package to the 'dependencies' section of project.json.
// services.AddWebApiConventions();
services.AddSwaggerGen();
services.ConfigureSwaggerDocument(options =>
{
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "IO.Swagger",
Description = "IO.Swagger (ASP.NET 5 Web API 2.x)"
});
options.OperationFilter(new ApplyXmlActionCommentsFixed(xmlComments));
});
services.ConfigureSwaggerSchema(options => {
options.DescribeAllEnumsAsStrings = true;
options.ModelFilter(new ApplyXmlTypeCommentsFixed(xmlComments));
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseIISPlatformHandler();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
app.UseSwaggerGen();
app.UseSwaggerUi();
}
// Taken from https://github.com/domaindrivendev/Ahoy/blob/master/test/WebSites/Basic/Startup.cs
private string GetSolutionBasePath()
{
var dir = Directory.CreateDirectory(_appEnv.ApplicationBasePath);
while (dir.Parent != null)
{
if (dir.GetDirectories("artifacts").Any())
return dir.FullName;
dir = dir.Parent;
}
throw new InvalidOperationException("Failed to detect solution base path - artifacts not found. Did you run dnu pack --out artifacts?");
}
// Entry point for the application.
public static void Main(string[] args) => WebApplication.Run<Startup>(args);
}
// using Swashbuckle.SwaggerGen.XmlComments;
public class ApplyXmlTypeCommentsFixed : ApplyXmlTypeComments
{
public ApplyXmlTypeCommentsFixed() : base("")
{
throw new NotImplementedException();
}
public ApplyXmlTypeCommentsFixed(string filePath): base(filePath)
{
}
}
public class ApplyXmlActionCommentsFixed : ApplyXmlActionComments
{
public ApplyXmlActionCommentsFixed() : base("")
{
throw new NotImplementedException();
}
public ApplyXmlActionCommentsFixed(string filePath): base(filePath)
{
}
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Verbose",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@@ -0,0 +1,41 @@
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"tooling": {
"defaultNamespace": "IO.Swagger"
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug" : "1.0.0-rc1-final",
"Swashbuckle.SwaggerGen": "6.0.0-rc1-final",
"Swashbuckle.SwaggerUi": "6.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}

View File

@@ -0,0 +1,42 @@
# Welcome to ASP.NET 5 Preview
We've made some big updates in this release, so its **important** that you spend a few minutes to learn whats new.
ASP.NET 5 has been rearchitected to make it **lean** and **composable**. It's fully **open source** and available on [GitHub](http://go.microsoft.com/fwlink/?LinkID=517854).
Your new project automatically takes advantage of modern client-side utilities like [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) and [npm](http://go.microsoft.com/fwlink/?LinkId=518005) (to add client-side libraries) and [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) (for client-side build and automation tasks).
We hope you enjoy the new capabilities in ASP.NET 5 and Visual Studio 2015.
The ASP.NET Team
### You've created a new ASP.NET 5 project. [Learn what's new](http://go.microsoft.com/fwlink/?LinkId=518016)
### This application consists of:
* Sample pages using ASP.NET MVC 6
* [Gulp](http://go.microsoft.com/fwlink/?LinkId=518007) and [Bower](http://go.microsoft.com/fwlink/?LinkId=518004) for managing client-side resources
* Theming using [Bootstrap](http://go.microsoft.com/fwlink/?LinkID=398939)
#### NEW CONCEPTS
* [The 'wwwroot' explained](http://go.microsoft.com/fwlink/?LinkId=518008)
* [Configuration in ASP.NET 5](http://go.microsoft.com/fwlink/?LinkId=518012)
* [Dependency Injection](http://go.microsoft.com/fwlink/?LinkId=518013)
* [Razor TagHelpers](http://go.microsoft.com/fwlink/?LinkId=518014)
* [Manage client packages using Gulp](http://go.microsoft.com/fwlink/?LinkID=517849)
* [Develop on different platforms](http://go.microsoft.com/fwlink/?LinkID=517850)
#### CUSTOMIZE APP
* [Add Controllers and Views](http://go.microsoft.com/fwlink/?LinkID=398600)
* [Add Data using EntityFramework](http://go.microsoft.com/fwlink/?LinkID=398602)
* [Add Authentication using Identity](http://go.microsoft.com/fwlink/?LinkID=398603)
* [Add real time support using SignalR](http://go.microsoft.com/fwlink/?LinkID=398606)
* [Add Class library](http://go.microsoft.com/fwlink/?LinkID=398604)
* [Add Web APIs with MVC 6](http://go.microsoft.com/fwlink/?LinkId=518009)
* [Add client packages using Bower](http://go.microsoft.com/fwlink/?LinkID=517848)
#### DEPLOY
* [Run your app locally](http://go.microsoft.com/fwlink/?LinkID=517851)
* [Run your app on ASP.NET Core 5](http://go.microsoft.com/fwlink/?LinkID=517852)
* [Run commands in your 'project.json'](http://go.microsoft.com/fwlink/?LinkID=517853)
* [Publish to Microsoft Azure Web Sites](http://go.microsoft.com/fwlink/?LinkID=398609)
* [Publish to the file system](http://go.microsoft.com/fwlink/?LinkId=518019)
We would love to hear your [feedback](http://go.microsoft.com/fwlink/?LinkId=518015)

View File

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

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false"/>
</system.webServer>
</configuration>