From 3218bf3f732eba0f4323270316d97d8f48d7da44 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Tue, 15 May 2018 21:45:40 -0400 Subject: [PATCH] [aspnetcore] Fix openapi.json location rename Swashbuckle generation was missing the configuration to rename from default swagger.json to openapi.json (expected by change in SwaggerUI's configuration for the endpoint). This generates to the appropriate location and updates the sample to load the Swagger UI properly on run. --- .../src/main/resources/aspnetcore/Startup.mustache | 5 ++++- .../petstore/aspnetcore/src/Org.OpenAPITools/Startup.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/aspnetcore/Startup.mustache b/modules/openapi-generator/src/main/resources/aspnetcore/Startup.mustache index 07b1b221621b..f34e2a6b2557 100644 --- a/modules/openapi-generator/src/main/resources/aspnetcore/Startup.mustache +++ b/modules/openapi-generator/src/main/resources/aspnetcore/Startup.mustache @@ -93,7 +93,10 @@ namespace {{packageName}} .UseMvc() .UseDefaultFiles() .UseStaticFiles() - .UseSwagger() + .UseSwagger(c => + { + c.RouteTemplate = "swagger/{documentName}/openapi.json"; + }) .UseSwaggerUI(c => { //TODO: Either use the SwaggerGen generated Swagger contract (generated from C# classes) diff --git a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Startup.cs b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Startup.cs index 193985f69650..05d5ff5bee11 100644 --- a/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Startup.cs +++ b/samples/server/petstore/aspnetcore/src/Org.OpenAPITools/Startup.cs @@ -100,7 +100,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF .UseMvc() .UseDefaultFiles() .UseStaticFiles() - .UseSwagger() + .UseSwagger(c => + { + c.RouteTemplate = "swagger/{documentName}/openapi.json"; + }) .UseSwaggerUI(c => { //TODO: Either use the SwaggerGen generated Swagger contract (generated from C# classes)