1- using System . Collections . Generic ;
21using Microsoft . AspNetCore . Builder ;
32using Microsoft . AspNetCore . Hosting ;
43using Microsoft . OpenApi . Models ;
76using Microsoft . Extensions . Hosting ;
87using Swashbuckle . Servers . Extension ;
98
10- namespace SampleApp9000
9+ namespace SampleApp9000 ;
10+
11+ public class Startup
1112{
12- public class Startup
13+ public Startup ( IConfiguration configuration )
1314 {
14- public Startup ( IConfiguration configuration )
15- {
16- Configuration = configuration ;
17- }
15+ Configuration = configuration ;
16+ }
1817
19- public IConfiguration Configuration { get ; }
18+ public IConfiguration Configuration { get ; }
2019
21- // This method gets called by the runtime. Use this method to add services to the container.
22- public void ConfigureServices ( IServiceCollection services )
23- {
24- services . AddControllers ( ) ;
20+ // This method gets called by the runtime. Use this method to add services to the container.
21+ public void ConfigureServices ( IServiceCollection services )
22+ {
23+ services . AddControllers ( ) ;
2524
26- services . AddSwaggerGen ( c =>
27- {
28- c . SwaggerDoc
29- (
30- "sampleapp" ,
31- new OpenApiInfo
32- {
33- Title = "Sample App 9000" ,
34- Version = "1.0.0" ,
35- Description = "Provides a simple example of the tool"
36- }
37- ) ;
25+ services . AddSwaggerGen ( c =>
26+ {
27+ c . SwaggerDoc
28+ (
29+ "sampleapp" ,
30+ new OpenApiInfo
31+ {
32+ Title = "Sample App 9000" ,
33+ Version = "1.0.0" ,
34+ Description = "Provides a simple example of the tool"
35+ }
36+ ) ;
3837
39- c . WithServers
40- (
41- new List < OpenApiServer >
42- {
43- new OpenApiServer { Url = "http://localhost:5000" } ,
44- new OpenApiServer { Url = "https://www.yourcustomdomain.com" }
45- }
46- ) ;
47- } ) ;
48- }
38+ c . WithServers
39+ (
40+ new [ ]
41+ {
42+ new OpenApiServer { Url = "http://localhost:5000" } ,
43+ new OpenApiServer { Url = "https://www.yourcustomdomain.com" }
44+ }
45+ ) ;
46+ } ) ;
47+ }
4948
50- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
51- public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
49+ // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
50+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
51+ {
52+ if ( env . IsDevelopment ( ) )
5253 {
53- if ( env . IsDevelopment ( ) )
54- {
55- app . UseDeveloperExceptionPage ( ) ;
56- }
54+ app . UseDeveloperExceptionPage ( ) ;
55+ }
5756
58- app . UseHttpsRedirection ( ) ;
57+ app . UseHttpsRedirection ( ) ;
5958
60- app . UseRouting ( ) ;
59+ app . UseRouting ( ) ;
6160
62- app . UseAuthorization ( ) ;
61+ app . UseAuthorization ( ) ;
6362
64- app . UseSwagger ( ) ;
63+ app . UseSwagger ( ) ;
6564
66- // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
67- // specifying the Swagger JSON endpoint.
68- app . UseSwaggerUI ( x =>
69- {
70- x . DocumentTitle = "SampleApp9000" ;
71- x . SwaggerEndpoint ( "/swagger/sampleapp/swagger.json" , "Sample App 9000" ) ;
72- x . RoutePrefix = string . Empty ;
73- } ) ;
65+ app . UseSwaggerUI ( x =>
66+ {
67+ x . DocumentTitle = "SampleApp9000" ;
68+ x . SwaggerEndpoint ( "/swagger/sampleapp/swagger.json" , "Sample App 9000" ) ;
69+ x . RoutePrefix = string . Empty ;
70+ } ) ;
7471
75- app . UseEndpoints ( endpoints =>
76- {
77- endpoints . MapControllers ( ) ;
78- } ) ;
79- }
72+ app . UseEndpoints ( endpoints =>
73+ {
74+ endpoints . MapControllers ( ) ;
75+ } ) ;
8076 }
81- }
77+ }
0 commit comments