Closed Scal-Human closed 3 months ago
Hi @Scal-Human,
I tried to reproduce the issue you're experiencing, but it works for me using the following code:
app.UseSwaggerUI(Style.DeepSea, (SwaggerUIOptions options) => { options.DisplayOperationId(); });
Do you see the loaded styles in your browser sources? Are there any errors printed in your browser console? Have you cleared your browser cache?
Hello, Thank you for your concern. No, I do not see any error, neither on the console, nor is the browser. The style is simply ignored on both Windows and Linux (Docker container). FYI: using the options was a test I removed anyway. Thanks for your job, by the way ;-) Scal
Oh, okay. I will investigate further. For now, I close this issue because I can't reproduce it, and it doesn't seem to be a bug. Thank you!
Thank you Tarek. In the meantime, I had to change the order of the middlewares I am using in my tests (trying to find common ground for all future servers), and with those changes, I added back a SwaggerUIOptions to have a standard openapi.json name instead of swagger.json and it now works.
app.UseSwaggerUI(Style.Dark, (SwaggerUIOptions options) => {
options.SwaggerEndpoint("v1/openapi.json", "Version 1");
options.RoutePrefix = "api";
});
Unfortunately, I do not have anymore the exact code that was not working (but it was really simple). What I suggest is for you not to investigate for now, and will come back to you if I can reproduce the case that was not working.
Thank you for your time, Scal
@Scal-Human, here's the error. It's not being recognized.
Here's the code,
app.UseSwagger();
app.UseSwaggerUI(
ModernStyle.Dark,
c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PodiumApi v1");
c.RoutePrefix = string.Empty; // this changes the default path
c.EnableTryItOutByDefault();
c.DocExpansion(DocExpansion.None);
});
This is the error when trying to build.
Startup.cs(76,9): Error CS1929 : 'IApplicationBuilder' does not contain a definition for 'UseSwaggerUI' and the best extension method overload 'StyleSwaggerUIBuilderExtensions.UseSwaggerUI(WebApplication, BaseStyle, SwaggerUIOptions)' requires a receiver of type 'Microsoft.AspNetCore.Builder.WebApplication'
Yeah, that error occurs because the methods extend WebApplication
, not IApplicationBuilder
.
I'll go ahead and update them to support that interface as well. Ty @oasaleh
@oasaleh You found it, super. Many thanks
@Scal-Human @oasaleh I'm back just to inform you I have added the IApplicationBuilder support (and other stuff) on version 1.0.0 (See the latest release)! Please upgrade your package to check it out. :D
@teociaps Thank you, have a nice day.
Guidelines
Project Version
0.5.0.0
.NET Version
net8.0
What happened?
Does nothing when defining SwaggerUIOptions along with the style
Steps to reproduce
app.UseSwaggerUI(Style.DeepSea, (SwaggerUIOptions options) => { options.DisplayOperationId(); });
Expected behavior
Changes the theme.
Additional Information
Works when removing the SwaggerUIOptions.
app.UseSwaggerUI(Style.DeepSea);