11using System ;
22using System . Collections . Generic ;
3+ using System . IO ;
34using System . Linq ;
5+ using System . Reflection ;
46using System . Text ;
57using System . Threading . Tasks ;
68using AutoMapper ;
1618using Microsoft . Extensions . DependencyInjection ;
1719using Microsoft . IdentityModel . Tokens ;
1820using Swashbuckle . AspNetCore . Swagger ;
21+ using Swashbuckle . AspNetCore . SwaggerUI ;
1922using WebGYM . Common ;
2023using WebGYM . Concrete ;
2124using WebGYM . Interface ;
@@ -43,7 +46,6 @@ public void ConfigureServices(IServiceCollection services)
4346 options . MinimumSameSitePolicy = SameSiteMode . None ;
4447 } ) ;
4548
46-
4749 #region MyRegion
4850 var connection = Configuration . GetConnectionString ( "DatabaseConnection" ) ;
4951 services . AddDbContext < DatabaseContext > ( options => options . UseSqlServer ( connection , b => b . UseRowNumberForPaging ( ) ) ) ;
@@ -183,6 +185,16 @@ public static IServiceCollection AddSwaggerDocumentation(this IServiceCollection
183185 {
184186 c . SwaggerDoc ( "v1.0" , new Info { Title = "Main API v1.0" , Version = "v1.0" } ) ;
185187
188+ //Locate the XML file being generated by ASP.NET...
189+ var xmlFile = $ "{ Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name } .XML";
190+ var xmlPath = Path . Combine ( AppContext . BaseDirectory , xmlFile ) ;
191+ if ( File . Exists ( xmlPath ) )
192+ {
193+ //... and tell Swagger to use those XML comments.
194+ c . IncludeXmlComments ( xmlPath ) ;
195+ }
196+
197+
186198 // Swagger 2.+ support
187199 var security = new Dictionary < string , IEnumerable < string > >
188200 {
@@ -209,7 +221,10 @@ public static IApplicationBuilder UseSwaggerDocumentation(this IApplicationBuild
209221 {
210222 c . SwaggerEndpoint ( "/swagger/v1.0/swagger.json" , "Gym Web API v1.0" ) ;
211223 c . DocumentTitle = "Title Documentation" ;
212- c . DocExpansion ( Swashbuckle . AspNetCore . SwaggerUI . DocExpansion . None ) ;
224+ //Reference link : https://stackoverflow.com/questions/22008452/collapse-expand-swagger-response-model-class
225+ //Reference link : https://swagger.io/docs/open-source-tools/swagger-ui/usage/deep-linking/
226+ // c.DocExpansion(Swashbuckle.AspNetCore.SwaggerUI.DocExpansion.None);
227+ // c.DocExpansion(DocExpansion.Full);
213228 // //Reference document: https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-2.2&tabs=visual-studio
214229 // //To serve the Swagger UI at the app's root (http://localhost:<port>/), set the RoutePrefix property to an empty string:
215230 c . RoutePrefix = string . Empty ;
0 commit comments