Skip to content

Commit

Permalink
Remove custom Maestro swagger page (#3847)
Browse files Browse the repository at this point in the history
  • Loading branch information
premun authored Aug 20, 2024
1 parent 4396011 commit d463c1a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 88 deletions.
10 changes: 7 additions & 3 deletions eng/enforce-issue.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,14 @@ elseif ($prDetail.title -match "\[automated\]") {
$hasIssue = $prDetail.body -Match "github\.com/dotnet/(.+)/issues/(\d+)"
if (-not $hasIssue) {
# Or for https://dev.azure.com/dnceng/internal/_workitems/edit/45126
$hasIssue = $prDetail.body -Match "dev\.azure\.com/dnceng/internal/_workitems"
$hasIssue = $prDetail.body -Match "dev\.azure\.com/(.+)/(.+)/_workitems"
if (-not $hasIssue) {
Write-Host "##vso[task.LogIssue type=error;]Link to the corresponding GitHub/AzDO issue is missing in the PR description. Check failed."
exit 1
# Or for https://dev.azure.com/dnceng/internal/_workitems/edit/12345
$hasIssue = $prDetail.body -Match "(.+)\.visualstudio\.com/(.+)/_workitems"
if (-not $hasIssue) {
Write-Host "##vso[task.LogIssue type=error;]Link to the corresponding GitHub/AzDO issue is missing in the PR description. Check failed."
exit 1
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/Maestro/Maestro.Web/Maestro.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" />
<PackageReference Include="Octokit" />
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" />
<PackageReference Include="System.Text.Encodings.Web" />
<!--
NuGet.Protocol is not directly used but it's a transitive dependency of Microsoft.VisualStudio.Web.CodeGeneration.Design.
Expand Down
70 changes: 0 additions & 70 deletions src/Maestro/Maestro.Web/Pages/SwaggerUi.cshtml

This file was deleted.

19 changes: 15 additions & 4 deletions src/Maestro/Maestro.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public override void ConfigureServices(IServiceCollection services)
options.Conventions.AuthorizeFolder("/", AuthenticationConfiguration.MsftAuthorizationPolicyName);
options.Conventions.AllowAnonymousToPage("/Index");
options.Conventions.AllowAnonymousToPage("/Error");
options.Conventions.AllowAnonymousToPage("/SwaggerUi");
})
.AddFluentValidation(options => options.RegisterValidatorsFromAssemblyContaining<Startup>())
.AddGitHubWebHooks()
Expand Down Expand Up @@ -294,7 +293,7 @@ public override void ConfigureServices(IServiceCollection services)
doc.Servers = new List<OpenApiServer>
{
new() {
Url = $"{(http ? "http" : "https")}://{req.Host.Value}/",
Url = $"{req.Scheme}://{req.Host.Value}/",
},
};

Expand Down Expand Up @@ -411,7 +410,6 @@ private void ConfigureApi(IApplicationBuilder app)

return next();
});
app.UseSwagger();

app.UseAuthentication();
app.UseRouting();
Expand Down Expand Up @@ -489,6 +487,20 @@ public override void Configure(IApplicationBuilder app)
new PhysicalFileProvider(Path.Combine(Environment.CurrentDirectory, "wwwroot"))),
});
}

app.UseSwagger();
app.UseSwaggerUI(options => // Enable Swagger UI only in local dev env
{
options.DocumentTitle = "Maestro API";

var versions = app.ApplicationServices.GetRequiredService<VersionedControllerProvider>().Versions.Keys
.OrderByDescending(x => x);

foreach (var version in versions)
{
options.SwaggerEndpoint($"/api/{version}/swagger.json", $"Maestro API {version}");
}
});
}
else
{
Expand Down Expand Up @@ -554,7 +566,6 @@ public override void Configure(IApplicationBuilder app)
ConfigureCookieAuthedApi);
}

app.UseRewriter(new RewriteOptions().AddRedirect("^swagger(/ui)?/?$", "/swagger/ui/index.html"));
app.UseStatusCodePagesWithReExecute("/Error", "?code={0}");
app.UseCookiePolicy();
app.UseStaticFiles();
Expand Down
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions src/Maestro/Maestro.Web/wwwroot/swagger/ui/swagger-ui.css

This file was deleted.

2 changes: 0 additions & 2 deletions src/Maestro/Maestro.Web/wwwroot/swagger/ui/swagger-ui.js

This file was deleted.

0 comments on commit d463c1a

Please sign in to comment.