0

I am new to using JetBrains Rider and I have always used VSCode on my Mac. I have seen a very weird behavior from JetBrains Rider. The behavior is that when I host Web API with Swagger tool kit, and run that code using VSCode, the swagger page does show me option to switch between HTTP and HTTPS.

However though, when I run the same exact code with JetBrains Rider, I do not even get option to choose between HTTP/HTTPS. It loads with HTTPS by default and that is pretty much it, I do not have an option to switch after that point.

This is really confusing because it is the same exact code and code is what drives if a user can run this API in HTTP or HTTPS mode. But it sounds like there is something that Rider is doing OR not doing which is causing this unexpected behavior.

A few more details:

We are using Swashbuckle.AspNetCore tool kit and the code that is responsible for setting up HTTP protocol is

app.UseSwagger(c =>
            {                    
                c.RouteTemplate = "gms/swagger/{documentName}/swagger.json";
                c.PreSerializeFilters.Add((swaggerDoc, httpReq) =>
                {
                    swaggerDoc.Servers = new List<OpenApiServer>
                    {
                        new OpenApiServer { Url = $"https://{httpReq.Host.Value}" }
                    };

#if DEBUG
                    if (env.IsDevelopment())
                    {
                        // Enable http option for local dev environment
                        swaggerDoc.Servers.Add(new OpenApiServer { Url = $"http://{httpReq.Host.Value}" });
                    }
#endif
                });
                c.SerializeAsV2 = true;
            });

and yes, the environment variable is set to develop when this code is executed.

Is there anything I need to do to change this behavior?

Lost
  • 12,007
  • 32
  • 121
  • 193
  • Hi, could you please share any code that reproduces this behavior? Which Swagger toolkit do you use, and how's it integrated with your code? – ForNeVeR Oct 02 '20 at 09:56
  • I updated code above with more details. Please let me know if more details are required. – Lost Oct 02 '20 at 16:03
  • I am sorry, but it is still unclear how to run your code. What is `c`? I've tried pasting your code inside of `app.UseSwaggerUI(c => { … })` of my Swashbuckle example app, but it says me that there's no `SwaggerUIOptions.PreSerializeFilters`. Could you please provide a more complete example? – ForNeVeR Oct 05 '20 at 07:28
  • @Lost did you check if code inside DEBUG is being executed? – Dipen Shah Oct 05 '20 at 17:55
  • Yeah, debug is true. As I said, the same code verbatim works with different IDE(VS-Code) – Lost Oct 06 '20 at 01:18
  • @ForNeVeR My bad. I updated the code to include the details that you need. – Lost Oct 06 '20 at 01:20

0 Answers0