Skip to content

Refactor Swagger UI and static file serving order#10

Open
spboyer wants to merge 1 commit intoAzure-Samples:mainfrom
spboyer:add-swagger
Open

Refactor Swagger UI and static file serving order#10
spboyer wants to merge 1 commit intoAzure-Samples:mainfrom
spboyer:add-swagger

Conversation

@spboyer
Copy link

@spboyer spboyer commented Apr 16, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a middleware ordering issue where Swagger UI was unable to load the OpenAPI specification file. The change reorders the middleware registration so that static file serving is configured before Swagger UI, allowing the openapi.yaml file to be properly served.

Changes:

  • Reordered middleware registration to place UseStaticFiles before UseSwaggerUI
  • Added a clarifying comment explaining the importance of this ordering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

app.UseStaticFiles(new StaticFileOptions
{
// Serve openapi.yaml file
ServeUnknownFileTypes = true,
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting ServeUnknownFileTypes to true is a potential security risk as it allows serving files with any extension without proper MIME type validation. Consider using FileExtensionContentTypeProvider to explicitly allow only the .yaml extension instead.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

todo-csharp-sql: API service needs to respond with OpenAPI spec when root document is requested

2 participants