diff --git a/README.md b/README.md index f37ff6f872c..df6bcbc3e6a 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,7 @@ AbstractJavaJAXRSServerCodegen.java AbstractTypeScriptClientCodegen.java AkkaScalaClientCodegen.java AndroidClientCodegen.java +AspNet5ServerCodegen.java AsyncScalaClientCodegen.java CSharpClientCodegen.java ClojureClientCodegen.java @@ -587,6 +588,15 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -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 +``` + ### To build the codegen library This will create the swagger-codegen library from source. diff --git a/bin/aspnet5-petstore-server.sh b/bin/aspnet5-petstore-server.sh new file mode 100644 index 00000000000..276d2a6e4b0 --- /dev/null +++ b/bin/aspnet5-petstore-server.sh @@ -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 diff --git a/bin/windows/aspnet5-petstore-server.bat b/bin/windows/aspnet5-petstore-server.bat new file mode 100644 index 00000000000..b71809f7006 --- /dev/null +++ b/bin/windows/aspnet5-petstore-server.bat @@ -0,0 +1,10 @@ +set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar + +If Not Exist %executable% ( + mvn clean package +) + +set JAVA_OPTS=%JAVA_OPTS% -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties +set ags=generate -t modules\swagger-codegen\src\main\resources\aspnet5 -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l aspnet5 -o samples\server\petstore\aspnet5 + +java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java new file mode 100644 index 00000000000..25ed44826ea --- /dev/null +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNet5ServerCodegen.java @@ -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 collectionTypes; + protected Set 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( + Arrays.asList( + "IList", "List", + "ICollection", "Collection", + "IEnumerable") + ); + mapTypes = new HashSet( + Arrays.asList("IDictionary") + ); + + reservedWords = new HashSet( + 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( + 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(); + 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 postProcessOperations(Map objs) { + super.postProcessOperations(objs); + if(objs != null) { + Map operations = (Map) objs.get("operations"); + if (operations != null) { + List ops = (List) 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 and Collection + 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) + ""; + } + 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 postProcessModels(Map objs) { + List models = (List) objs.get("models"); + for (Object _mo : models) { + Map mo = (Map) _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; + } +} diff --git a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig index 93884a9562c..f4d4f5a63e5 100644 --- a/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig +++ b/modules/swagger-codegen/src/main/resources/META-INF/services/io.swagger.codegen.CodegenConfig @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache new file mode 100644 index 00000000000..8ff1b8faeed --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Dockerfile.mustache @@ -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"] diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json b/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json new file mode 100644 index 00000000000..7d41a0f84b9 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger/ui", + "environmentVariables": { + "ASPNET_ENV": "Development" + } + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache new file mode 100644 index 00000000000..c4e9d328cc7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/Startup.mustache @@ -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(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) + { + + } + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json b/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json new file mode 100644 index 00000000000..e5472e562b7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Verbose", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/bodyParam.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/bodyParam.mustache new file mode 100644 index 00000000000..02b0fa1d2de --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/bodyParam.mustache @@ -0,0 +1 @@ +{{#isBodyParam}}[FromBody]{{&dataType}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/build.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/build.mustache new file mode 100644 index 00000000000..0a63bfeaf3d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/build.mustache @@ -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" \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache new file mode 100644 index 00000000000..e9c5c919898 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/controller.mustache @@ -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}} + /// + /// {{description}} + /// {{#description}}{{#basePath}} + [Route("{{basePath}}")] + {{/basePath}}[Description("{{description}}")]{{/description}} + public class {{classname}}Controller : Controller + { {{#operation}} + + /// + /// {{#summary}}{{summary}}{{/summary}} + /// + {{#notes}}/// {{notes}}{{/notes}}{{#allParams}} + /// {{description}}{{/allParams}}{{#responses}} + /// {{message}}{{/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}} +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/formParam.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/formParam.mustache new file mode 100644 index 00000000000..1e743e1e4c7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/formParam.mustache @@ -0,0 +1 @@ +{{#isFormParam}}[FromForm]{{&dataType}} {{paramName}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/gitignore b/modules/swagger-codegen/src/main/resources/aspnet5/gitignore new file mode 100644 index 00000000000..cd9b840e549 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/gitignore @@ -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 diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/global.json b/modules/swagger-codegen/src/main/resources/aspnet5/global.json new file mode 100644 index 00000000000..4a6d1feac95 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/global.json @@ -0,0 +1,8 @@ +{ + "projects": [ "src", "." ], + "sdk": { + "version": "1.0.0-rc1-final", + "runtime": "coreclr", + "architecture": "x64" + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/headerParam.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/headerParam.mustache new file mode 100644 index 00000000000..e61cadb1131 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/headerParam.mustache @@ -0,0 +1 @@ +{{#isHeaderParam}}[FromHeader]{{&dataType}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/listReturn.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/listReturn.mustache new file mode 100644 index 00000000000..d609e67148c --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/listReturn.mustache @@ -0,0 +1,4 @@ + + var example = exampleJson != null + ? JsonConvert.DeserializeObject<{{returnContainer}}<{{#returnType}}{{{returnType}}}{{/returnType}}>>(exampleJson) + : Enumerable.Empty<{{#returnType}}{{{returnType}}}{{/returnType}}>(); \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/mapReturn.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/mapReturn.mustache new file mode 100644 index 00000000000..856fb1b3507 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/mapReturn.mustache @@ -0,0 +1,4 @@ + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : new Dictionary<{{#returnType}}{{{returnType}}}{{/returnType}}>(); \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache new file mode 100644 index 00000000000..bb4e7af9d76 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/model.mustache @@ -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 +{ + /// + /// {{description}} + /// + public partial class {{classname}} : {{#parent}}{{{parent}}}, {{/parent}} IEquatable<{{classname}}> + { + /// + /// Initializes a new instance of the class. + /// + public {{classname}}() + { + {{#vars}}{{#defaultValue}}this.{{name}} = {{{defaultValue}}}; + {{/defaultValue}}{{/vars}} + } + + {{#vars}} + /// + /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + /// {{#description}} + /// {{{description}}}{{/description}} + public {{{datatype}}} {{name}} { get; set; } + + {{/vars}} + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + 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(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public {{#parent}} new {{/parent}}string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + 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); + } + + /// + /// Returns true if {{classname}} instances are equal + /// + /// Instance of {{classname}} to be compared + /// Boolean + 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}}; + } + + /// + /// Gets the hash code + /// + /// Hash code + 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}} +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/objectReturn.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/objectReturn.mustache new file mode 100644 index 00000000000..4059a61ac0b --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/objectReturn.mustache @@ -0,0 +1,4 @@ + + var example = exampleJson != null + ? JsonConvert.DeserializeObject<{{#returnType}}{{{returnType}}}{{/returnType}}>(exampleJson) + : default({{#returnType}}{{{returnType}}}{{/returnType}}); \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/pathParam.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/pathParam.mustache new file mode 100644 index 00000000000..5aa27eb4cb3 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/pathParam.mustache @@ -0,0 +1 @@ +{{#isPathParam}}[FromRoute]{{&dataType}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/project.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/project.mustache new file mode 100644 index 00000000000..018084bc7e1 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/project.mustache @@ -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" + ] +} diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/queryParam.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/queryParam.mustache new file mode 100644 index 00000000000..42ce87a2b7f --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/queryParam.mustache @@ -0,0 +1 @@ +{{#isQueryParam}}[FromQuery]{{&dataType}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/tags.mustache b/modules/swagger-codegen/src/main/resources/aspnet5/tags.mustache new file mode 100644 index 00000000000..c97df19949e --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/tags.mustache @@ -0,0 +1 @@ +{{!TODO: Need iterable tags object...}}{{#tags}}, Tags = new[] { {{/tags}}"{{#tags}}{{tag}} {{/tags}}"{{#tags}} }{{/tags}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/README.md b/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s 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) diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/index.html b/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/index.html new file mode 100644 index 00000000000..c8c055b34f7 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/web.config b/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/web.config new file mode 100644 index 00000000000..e70a7778d60 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/aspnet5/wwwroot/web.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/aspnet5/AspNet5ServerOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/aspnet5/AspNet5ServerOptionsTest.java new file mode 100644 index 00000000000..8c53c8913f3 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/aspnet5/AspNet5ServerOptionsTest.java @@ -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; + }}; + } +} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AspNet5ServerOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AspNet5ServerOptionsProvider.java new file mode 100644 index 00000000000..962fc1182d3 --- /dev/null +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/AspNet5ServerOptionsProvider.java @@ -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 createOptions() { + ImmutableMap.Builder builder = new ImmutableMap.Builder(); + 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; + } +} diff --git a/samples/server/petstore/aspnet5/.gitignore b/samples/server/petstore/aspnet5/.gitignore new file mode 100644 index 00000000000..e4349f244a1 --- /dev/null +++ b/samples/server/petstore/aspnet5/.gitignore @@ -0,0 +1 @@ +artifacts/ \ No newline at end of file diff --git a/samples/server/petstore/aspnet5/build.sh b/samples/server/petstore/aspnet5/build.sh new file mode 100755 index 00000000000..5d6402baee7 --- /dev/null +++ b/samples/server/petstore/aspnet5/build.sh @@ -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" \ No newline at end of file diff --git a/samples/server/petstore/aspnet5/global.json b/samples/server/petstore/aspnet5/global.json new file mode 100644 index 00000000000..4a6d1feac95 --- /dev/null +++ b/samples/server/petstore/aspnet5/global.json @@ -0,0 +1,8 @@ +{ + "projects": [ "src", "." ], + "sdk": { + "version": "1.0.0-rc1-final", + "runtime": "coreclr", + "architecture": "x64" + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/.gitignore b/samples/server/petstore/aspnet5/src/IO.Swagger/.gitignore new file mode 100644 index 00000000000..cd9b840e549 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/.gitignore @@ -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 diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs new file mode 100644 index 00000000000..8eb740a1e4e --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/PetApi.cs @@ -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 +{ + /// + /// + /// + public class PetApiController : Controller + { + + /// + /// Update an existing pet + /// + /// + /// Pet object that needs to be added to the store + /// Invalid ID supplied + /// Pet not found + /// Validation exception + [HttpPut] + [Route("/pet")] + [SwaggerOperation("UpdatePet")] + public void UpdatePet([FromBody]Pet body) + { + throw new NotImplementedException(); + } + + + /// + /// Add a new pet to the store + /// + /// + /// Pet object that needs to be added to the store + /// Invalid input + [HttpPost] + [Route("/pet")] + [SwaggerOperation("AddPet")] + public void AddPet([FromBody]Pet body) + { + throw new NotImplementedException(); + } + + + /// + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma seperated strings + /// Status values that need to be considered for filter + /// successful operation + /// Invalid status value + [HttpGet] + [Route("/pet/findByStatus")] + [SwaggerOperation("FindPetsByStatus")] + [SwaggerResponse(200, type: typeof(List))] + public IActionResult FindPetsByStatus([FromQuery]List status) + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + + return new ObjectResult(example); + } + + + /// + /// Finds Pets by tags + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// Tags to filter by + /// successful operation + /// Invalid tag value + [HttpGet] + [Route("/pet/findByTags")] + [SwaggerOperation("FindPetsByTags")] + [SwaggerResponse(200, type: typeof(List))] + public IActionResult FindPetsByTags([FromQuery]List tags) + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); + + return new ObjectResult(example); + } + + + /// + /// Find pet by ID + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Pet not found + [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(exampleJson) + : default(Pet); + + return new ObjectResult(example); + } + + + /// + /// Updates a pet in the store with form data + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// Invalid input + [HttpPost] + [Route("/pet/{petId}")] + [SwaggerOperation("UpdatePetWithForm")] + public void UpdatePetWithForm([FromRoute]string petId, [FromForm]string name, [FromForm]string status) + { + throw new NotImplementedException(); + } + + + /// + /// Deletes a pet + /// + /// + /// Pet id to delete + /// + /// Invalid pet value + [HttpDelete] + [Route("/pet/{petId}")] + [SwaggerOperation("DeletePet")] + public void DeletePet([FromRoute]long? petId, [FromHeader]string apiKey) + { + throw new NotImplementedException(); + } + + + /// + /// uploads an image + /// + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// successful operation + [HttpPost] + [Route("/pet/{petId}/uploadImage")] + [SwaggerOperation("UploadFile")] + public void UploadFile([FromRoute]long? petId, [FromForm]string additionalMetadata, [FromForm]Stream file) + { + throw new NotImplementedException(); + } + + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Pet not found + [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(exampleJson) + : default(byte[]); + + return new ObjectResult(example); + } + + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// Pet object in the form of byte array + /// Invalid input + [HttpPost] + [Route("/pet/testing_byte_array=true")] + [SwaggerOperation("AddPetUsingByteArray")] + public void AddPetUsingByteArray([FromBody]byte[] body) + { + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs new file mode 100644 index 00000000000..347c46abd69 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/StoreApi.cs @@ -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 +{ + /// + /// + /// + public class StoreApiController : Controller + { + + /// + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + /// successful operation + [HttpGet] + [Route("/store/inventory")] + [SwaggerOperation("GetInventory")] + [SwaggerResponse(200, type: typeof(Dictionary))] + public IActionResult GetInventory() + { + string exampleJson = null; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(Dictionary); + + return new ObjectResult(example); + } + + + /// + /// Place an order for a pet + /// + /// + /// order placed for purchasing the pet + /// successful operation + /// Invalid Order + [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(exampleJson) + : default(Order); + + return new ObjectResult(example); + } + + + /// + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// ID of pet that needs to be fetched + /// successful operation + /// Invalid ID supplied + /// Order not found + [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(exampleJson) + : default(Order); + + return new ObjectResult(example); + } + + + /// + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// ID of the order that needs to be deleted + /// Invalid ID supplied + /// Order not found + [HttpDelete] + [Route("/store/order/{orderId}")] + [SwaggerOperation("DeleteOrder")] + public void DeleteOrder([FromRoute]string orderId) + { + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs new file mode 100644 index 00000000000..180dc4aa00a --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Controllers/UserApi.cs @@ -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 +{ + /// + /// + /// + public class UserApiController : Controller + { + + /// + /// Create user + /// + /// This can only be done by the logged in user. + /// Created user object + /// successful operation + [HttpPost] + [Route("/user")] + [SwaggerOperation("CreateUser")] + public void CreateUser([FromBody]User body) + { + throw new NotImplementedException(); + } + + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/user/createWithArray")] + [SwaggerOperation("CreateUsersWithArrayInput")] + public void CreateUsersWithArrayInput([FromBody]List body) + { + throw new NotImplementedException(); + } + + + /// + /// Creates list of users with given input array + /// + /// + /// List of user object + /// successful operation + [HttpPost] + [Route("/user/createWithList")] + [SwaggerOperation("CreateUsersWithListInput")] + public void CreateUsersWithListInput([FromBody]List body) + { + throw new NotImplementedException(); + } + + + /// + /// Logs user into the system + /// + /// + /// The user name for login + /// The password for login in clear text + /// successful operation + /// Invalid username/password supplied + [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(exampleJson) + : default(string); + + return new ObjectResult(example); + } + + + /// + /// Logs out current logged in user session + /// + /// + /// successful operation + [HttpGet] + [Route("/user/logout")] + [SwaggerOperation("LogoutUser")] + public void LogoutUser() + { + throw new NotImplementedException(); + } + + + /// + /// Get user by user name + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// successful operation + /// Invalid username supplied + /// User not found + [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(exampleJson) + : default(User); + + return new ObjectResult(example); + } + + + /// + /// Updated user + /// + /// This can only be done by the logged in user. + /// name that need to be deleted + /// Updated user object + /// Invalid user supplied + /// User not found + [HttpPut] + [Route("/user/{username}")] + [SwaggerOperation("UpdateUser")] + public void UpdateUser([FromRoute]string username, [FromBody]User body) + { + throw new NotImplementedException(); + } + + + /// + /// Delete user + /// + /// This can only be done by the logged in user. + /// The name that needs to be deleted + /// Invalid username supplied + /// User not found + [HttpDelete] + [Route("/user/{username}")] + [SwaggerOperation("DeleteUser")] + public void DeleteUser([FromRoute]string username) + { + throw new NotImplementedException(); + } + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Dockerfile b/samples/server/petstore/aspnet5/src/IO.Swagger/Dockerfile new file mode 100644 index 00000000000..af879b80ab0 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Dockerfile @@ -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"] diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs new file mode 100644 index 00000000000..0ae013fb688 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Category.cs @@ -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 +{ + /// + /// + /// + public partial class Category : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + public Category() + { + + } + + + /// + /// Gets or Sets Id + /// + public long? Id { get; set; } + + + /// + /// Gets or Sets Name + /// + public string Name { get; set; } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + 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(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + 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); + } + + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + 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) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + 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 + + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs new file mode 100644 index 00000000000..e8bd7610bb6 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Order.cs @@ -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 +{ + /// + /// + /// + public partial class Order : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + public Order() + { + + } + + + /// + /// Gets or Sets Id + /// + public long? Id { get; set; } + + + /// + /// Gets or Sets PetId + /// + public long? PetId { get; set; } + + + /// + /// Gets or Sets Quantity + /// + public int? Quantity { get; set; } + + + /// + /// Gets or Sets ShipDate + /// + public DateTime? ShipDate { get; set; } + + + /// + /// Order Status + /// + /// Order Status + public string Status { get; set; } + + + /// + /// Gets or Sets Complete + /// + public bool? Complete { get; set; } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + 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(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + 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); + } + + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + 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) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + 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 + + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs new file mode 100644 index 00000000000..5cf91ebe054 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Pet.cs @@ -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 +{ + /// + /// + /// + public partial class Pet : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + public Pet() + { + + } + + + /// + /// Gets or Sets Id + /// + public long? Id { get; set; } + + + /// + /// Gets or Sets Category + /// + public Category Category { get; set; } + + + /// + /// Gets or Sets Name + /// + public string Name { get; set; } + + + /// + /// Gets or Sets PhotoUrls + /// + public List PhotoUrls { get; set; } + + + /// + /// Gets or Sets Tags + /// + public List Tags { get; set; } + + + /// + /// pet status in the store + /// + /// pet status in the store + public string Status { get; set; } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + 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(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + 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); + } + + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + 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) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + 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 + + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs new file mode 100644 index 00000000000..159e65015f4 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/Tag.cs @@ -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 +{ + /// + /// + /// + public partial class Tag : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + public Tag() + { + + } + + + /// + /// Gets or Sets Id + /// + public long? Id { get; set; } + + + /// + /// Gets or Sets Name + /// + public string Name { get; set; } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + 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(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + 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); + } + + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + 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) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + 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 + + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs new file mode 100644 index 00000000000..c20ef235807 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Models/User.cs @@ -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 +{ + /// + /// + /// + public partial class User : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + public User() + { + + } + + + /// + /// Gets or Sets Id + /// + public long? Id { get; set; } + + + /// + /// Gets or Sets Username + /// + public string Username { get; set; } + + + /// + /// Gets or Sets FirstName + /// + public string FirstName { get; set; } + + + /// + /// Gets or Sets LastName + /// + public string LastName { get; set; } + + + /// + /// Gets or Sets Email + /// + public string Email { get; set; } + + + /// + /// Gets or Sets Password + /// + public string Password { get; set; } + + + /// + /// Gets or Sets Phone + /// + public string Phone { get; set; } + + + /// + /// User Status + /// + /// User Status + public int? UserStatus { get; set; } + + + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + 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(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + 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); + } + + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + 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) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + 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 + + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Properties/launchSettings.json b/samples/server/petstore/aspnet5/src/IO.Swagger/Properties/launchSettings.json new file mode 100644 index 00000000000..7d41a0f84b9 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger/ui", + "environmentVariables": { + "ASPNET_ENV": "Development" + } + } + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/Startup.cs b/samples/server/petstore/aspnet5/src/IO.Swagger/Startup.cs new file mode 100644 index 00000000000..21cb3aa6042 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/Startup.cs @@ -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(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) + { + + } + } +} \ No newline at end of file diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/appsettings.json b/samples/server/petstore/aspnet5/src/IO.Swagger/appsettings.json new file mode 100644 index 00000000000..e5472e562b7 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Verbose", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/project.json b/samples/server/petstore/aspnet5/src/IO.Swagger/project.json new file mode 100644 index 00000000000..7317a7c0d0c --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/project.json @@ -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" + ] +} diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/README.md b/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/README.md new file mode 100644 index 00000000000..6a0b78471a3 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/README.md @@ -0,0 +1,42 @@ +# Welcome to ASP.NET 5 Preview + +We've made some big updates in this release, so it’s **important** that you spend a few minutes to learn what’s 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) diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/index.html b/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/index.html new file mode 100644 index 00000000000..c8c055b34f7 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/web.config b/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/web.config new file mode 100644 index 00000000000..e70a7778d60 --- /dev/null +++ b/samples/server/petstore/aspnet5/src/IO.Swagger/wwwroot/web.config @@ -0,0 +1,9 @@ + + + + + + + + +