4

I begin with Swashbuckle, i make a Web API in .NET Core with Swashbuckle. I need to deploy my API in a sub-application of an IIS site

IIS infrastructure

I would like the access to swagger UI to be done via this url :

http://ip:80/myApi/swagger 

I would like the access to the methods to be done by this url :

http://ip:80/myApi/api/[controller]/methode 

ConfigureServices(IServiceCollection services)

 services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { Title = "My REST API", Version = "v1" }); }); 

Configure(IApplicationBuilder app..)

if (env.IsEnvironment("ProdIT")) { app.UseSwagger(c => { c.PreSerializeFilters.Add((swaggerDoc, httpReq) => swaggerDoc.BasePath = "/myApi/"); c.RouteTemplate = "myApi/api-docs/{documentName}/swagger.json"; }); app.UseSwaggerUI(c => { c.RoutePrefix = "myApi/swagger"; c.SwaggerEndpoint("/myApi/api-docs/v1/swagger.json", "MY REST API V1");}); 

Route Controller

[Route("api/[controller]")] 

Could you tell me what's wrong with my code?

Thanks in advance

1 Answer 1

4

I had the same issue and I resolved it by configuring the SwaggerUI like that;

app.UseSwaggerUI(c => { c.SwaggerEndpoint("v1/swagger.json", "MY REST API V1");}); } 
Sign up to request clarification or add additional context in comments.

1 Comment

Ok, with this endpoint and i update swashbuckle from 2.3 to 2.5 it's work

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.