Added support for VERSION, APPNAME and CONTACT from Swagger file into Startup.cs (#7103)

* Added support for VERSION and APPNAME from Swagger file into Startup.cs for Swashbuckle SwaggerGen

* Ran bin/aspnetcore-petstore-server.sh

* Added contact information

* Added contact information to startup.cs
This commit is contained in:
Max K
2017-12-13 05:03:33 +01:00
committed by William Cheng
parent 1541d96b18
commit c496ec7269
2 changed files with 22 additions and 10 deletions

View File

@@ -54,11 +54,17 @@ namespace {{packageName}}
services
.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
c.SwaggerDoc("{{#version}}{{{version}}}{{/version}}{{^version}}v1{{/version}}", new Info
{
Version = "v1",
Title = "{{packageName}}",
Description = "{{packageName}} (ASP.NET Core 2.0)"
Version = "{{#version}}{{{version}}}{{/version}}{{^version}}v1{{/version}}",
Title = "{{#appName}}{{{appName}}}{{/appName}}{{^appName}}{{packageName}}{{/appName}}",
Description = "{{#appName}}{{{appName}}}{{/appName}}{{^appName}}{{packageName}}{{/appName}} (ASP.NET Core 2.0)",
Contact = new Contact()
{
Url = "{{#infoUrl}}{{{infoUrl}}}{{/infoUrl}}",
Email = "{{#infoEmail}}{{{infoEmail}}}{{/infoEmail}}"
},
TermsOfService = "{{#termsOfService}}{{{termsOfService}}}{{/termsOfService}}"
});
c.CustomSchemaIds(type => type.FriendlyId(true));
c.DescribeAllEnumsAsStrings();
@@ -87,7 +93,7 @@ namespace {{packageName}}
.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "{{packageName}}");
c.SwaggerEndpoint("/swagger/{{#version}}{{{version}}}{{/version}}{{^version}}v1{{/version}}/swagger.json", "{{#appName}}{{{appName}}}{{/appName}}{{^appName}}{{packageName}}{{/appName}}");
});
if (env.IsDevelopment())

View File

@@ -63,11 +63,17 @@ namespace IO.Swagger
services
.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info
c.SwaggerDoc("1.0.0", new Info
{
Version = "v1",
Title = "IO.Swagger",
Description = "IO.Swagger (ASP.NET Core 2.0)"
Version = "1.0.0",
Title = "Swagger Petstore",
Description = "Swagger Petstore (ASP.NET Core 2.0)",
Contact = new Contact()
{
Url = "",
Email = "apiteam@swagger.io"
},
TermsOfService = "http://swagger.io/terms/"
});
c.CustomSchemaIds(type => type.FriendlyId(true));
c.DescribeAllEnumsAsStrings();
@@ -94,7 +100,7 @@ namespace IO.Swagger
.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "IO.Swagger");
c.SwaggerEndpoint("/swagger/1.0.0/swagger.json", "Swagger Petstore");
});
if (env.IsDevelopment())