File tree Expand file tree Collapse file tree 1 file changed +2
-23
lines changed
BervProject.WebApi.Boilerplate Expand file tree Collapse file tree 1 file changed +2
-23
lines changed Original file line number Diff line number Diff line change 1515using Microsoft . Extensions . DependencyInjection ;
1616using Microsoft . Extensions . Hosting ;
1717using Microsoft . Extensions . Logging ;
18- using Microsoft . OpenApi . Models ;
1918using NLog . Web ;
2019
2120var builder = WebApplication . CreateBuilder ( args ) ;
5655
5756builder . Services . AddControllers ( ) ;
5857builder . Services . AddApiVersioning ( ) ;
59- builder . Services . AddSwaggerGen ( options =>
60- {
61- var xmlFilename = $ "{ Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name } .xml";
62- options . IncludeXmlComments ( Path . Combine ( AppContext . BaseDirectory , xmlFilename ) ) ;
63- options . SwaggerDoc ( "v1" , new OpenApiInfo
64- {
65- Version = "v1" ,
66- Title = "Boilerplate API" ,
67- Description = "An ASP.NET Core Web API"
68- } ) ;
69- } ) ;
58+ builder . Services . AddOpenApi ( ) ;
7059
7160var app = builder . Build ( ) ;
7261
8877// register essential things
8978if ( app . Environment . IsDevelopment ( ) )
9079{
80+ app . MapOpenApi ( ) ;
9181 app . UseDeveloperExceptionPage ( ) ;
9282}
9383else
10090
10191app . UseAuthorization ( ) ;
10292
103- app . UseSwagger ( c =>
104- {
105- c . RouteTemplate = "api/docs/{documentName}/swagger.json" ;
106- } ) ;
107-
108- app . UseSwaggerUI ( c =>
109- {
110- c . SwaggerEndpoint ( "/api/docs/v1/swagger.json" , "My API V1" ) ;
111- c . RoutePrefix = "api/docs" ;
112- } ) ;
113-
11493app . MapDefaultEndpoints ( ) ;
11594
11695app . MapControllers ( ) ;
You can’t perform that action at this time.
0 commit comments