Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

blazor swagger setup

//Install-Package Swashbuckle.AspNetCore
//using 

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    public void ConfigureServices(IServiceCollection services)
    {
        services.AddSwaggerGen();
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseSwagger();
        app.UseSwaggerUI(c =>
        {
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
        });
    }
}
Comment

blazor swagger setup


public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to the container.
    // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
    public void ConfigureServices(IServiceCollection services)
    {

        services.AddControllers();
        // Register the Swagger generator, defining 1 or more Swagger documents
        services.AddSwaggerGen(c =>
        {
            c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
        });
        services.AddRazorPages();
        services.AddServerSideBlazor();
        services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<IdentityUser>>();
        services.AddSingleton<WeatherForecastService>();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();
        }
        else
        {
            app.UseExceptionHandler("/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }

        // Enable middleware to serve generated Swagger as a JSON endpoint.
        app.UseSwagger();

        // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
        // specifying the Swagger JSON endpoint.
        app.UseSwaggerUI(c =>
        {
            c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
        });

        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapBlazorHub();
            endpoints.MapFallbackToPage("/_Host");
        });
    }
}

Comment

PREVIOUS NEXT
Code Example
Csharp :: how to close an application in c# 
Csharp :: how delete multiple row from relation in laravel 
Csharp :: create instance of class given class name string c# 
Csharp :: disable rigidbody unity 
Csharp :: why v-slot not working in vue 3 
Csharp :: capitalize c# 
Csharp :: https request c# 
Csharp :: WPF Confirmation MessageBox 
Csharp :: Play Sound c# 
Csharp :: c list add element 
Csharp :: unity rotate direction by angle 
Csharp :: read all lines from txt c# 
Csharp :: .net get system environment variable 
Csharp :: check shell command success 
Csharp :: unity change cursor texture 
Csharp :: how to create a delegate in c# 
Csharp :: hide button unity 
Csharp :: wpf app how to get all elements 
Csharp :: lock pc using c# 
Csharp :: git find commits by file path 
Csharp :: Pass Querystring in C# httpclient 
Csharp :: count number of properties on an object C# 
Csharp :: recursive reverse linked list 
Csharp :: c# how does comparing datetime work 
Csharp :: Customize yup number 
Csharp :: delegate in c# 
Csharp :: aspx import namespace 
Csharp :: c# object list attribute to string 
Csharp :: c# find value in datagridview 
Csharp :: how to set foreground from code wpf 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =