Skip to content

Extend example of "JS With Backend" to include Swagger/Swashbuckle support? #123

Answered by maartenba
dmontgomery asked this question in BFF
Discussion options

You must be logged in to vote

Interesting question! And a great opportunity to dig into some internals :-) I take it you are seeing an inexplicable 401 Unauthorized when invoking the API using Swagger UI?

I'll assume we're using the JsBffSample/FrontendHost/Program.cs as-is, and then explain some of the required additions. Also, you will need the Swashbuckle.AspNetCore NuGet package installed.

With that, let's start! You will want to add the required services for Swashbuckle and the Swagger UI first:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();
+ builder.Services.AddEndpointsApiExplorer();
+ builder.Services.AddSwaggerGen();

Next, you'll want to configure the request pipeline. …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dmontgomery
Comment options

Answer selected by dmontgomery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
BFF
Labels
None yet
2 participants