Skip to content

Commit 313ffe7

Browse files
authored
Merge pull request saineshwar#5 from anomepani/master
Added Swagger for API Documentation and set as starting page for webapi.
2 parents 5e898fc + 567d0ee commit 313ffe7

File tree

4 files changed

+46
-24
lines changed

4 files changed

+46
-24
lines changed

WebGYM/WebGYM/Startup.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Microsoft.Extensions.Configuration;
1616
using Microsoft.Extensions.DependencyInjection;
1717
using Microsoft.IdentityModel.Tokens;
18+
using Swashbuckle.AspNetCore.Swagger;
1819
using WebGYM.Common;
1920
using WebGYM.Concrete;
2021
using WebGYM.Interface;
@@ -114,6 +115,12 @@ public void ConfigureServices(IServiceCollection services)
114115
.AllowCredentials()
115116
.WithExposedHeaders("X-Pagination"));
116117
});
118+
119+
// Register the Swagger generator, defining 1 or more Swagger documents
120+
services.AddSwaggerGen(c =>
121+
{
122+
c.SwaggerDoc("v1", new Info { Title = "WebGym API", Version = "v1" });
123+
});
117124
}
118125

119126
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -133,6 +140,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
133140
app.UseAuthentication();
134141

135142
app.UseCors("CorsPolicy");
143+
// Enable middleware to serve generated Swagger as a JSON endpoint.
144+
app.UseSwagger();
145+
146+
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
147+
// specifying the Swagger JSON endpoint.
148+
app.UseSwaggerUI(c =>
149+
{
150+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebGym API V1");
151+
//Reference document: https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-2.2&tabs=visual-studio
152+
//To serve the Swagger UI at the app's root (http://localhost:<port>/), set the RoutePrefix property to an empty string:
153+
c.RoutePrefix = string.Empty;
154+
});
136155
app.UseMvc(routes =>
137156
{
138157
routes.MapRoute(

WebGYM/WebGYM/WebGYM.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
99
<PackageReference Include="Microsoft.AspNetCore.App" />
1010
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
11+
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
1112
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.8.8" />
1213
</ItemGroup>
1314

gym-project/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,25 @@
2222
"@angular/platform-browser": "~7.0.0",
2323
"@angular/platform-browser-dynamic": "~7.0.0",
2424
"@angular/router": "~7.0.0",
25+
"classlist.js": "^1.1.20150312",
2526
"core-js": "^2.5.4",
2627
"hammerjs": "^2.0.8",
2728
"html2canvas": "^1.0.0-alpha.12",
2829
"jspdf": "^1.5.2",
2930
"ngx-bootstrap": "^3.1.2",
3031
"rxjs": "~6.3.3",
32+
"web-animations-js": "^2.3.1",
3133
"xlsx": "^0.14.1",
3234
"zone.js": "~0.8.26"
3335
},
3436
"devDependencies": {
35-
"@angular-devkit/build-angular": "~0.10.0",
37+
"@angular-devkit/build-angular": "^0.13.0",
3638
"@angular/cli": "~7.0.6",
3739
"@angular/compiler-cli": "~7.0.0",
3840
"@angular/language-service": "~7.0.0",
39-
"@types/node": "~8.9.4",
4041
"@types/jasmine": "~2.8.8",
4142
"@types/jasminewd2": "~2.0.3",
43+
"@types/node": "~8.9.4",
4244
"codelyzer": "~4.5.0",
4345
"jasmine-core": "~2.99.1",
4446
"jasmine-spec-reporter": "~4.2.1",

gym-project/src/polyfills.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,55 +19,55 @@
1919
*/
2020

2121
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
22-
// import 'core-js/es6/symbol';
23-
// import 'core-js/es6/object';
24-
// import 'core-js/es6/function';
25-
// import 'core-js/es6/parse-int';
26-
// import 'core-js/es6/parse-float';
27-
// import 'core-js/es6/number';
28-
// import 'core-js/es6/math';
29-
// import 'core-js/es6/string';
30-
// import 'core-js/es6/date';
31-
// import 'core-js/es6/array';
32-
// import 'core-js/es6/regexp';
33-
// import 'core-js/es6/map';
34-
// import 'core-js/es6/weak-map';
35-
// import 'core-js/es6/set';
22+
import 'core-js/es6/symbol';
23+
import 'core-js/es6/object';
24+
import 'core-js/es6/function';
25+
import 'core-js/es6/parse-int';
26+
import 'core-js/es6/parse-float';
27+
import 'core-js/es6/number';
28+
import 'core-js/es6/math';
29+
import 'core-js/es6/string';
30+
import 'core-js/es6/date';
31+
import 'core-js/es6/array';
32+
import 'core-js/es6/regexp';
33+
import 'core-js/es6/map';
34+
import 'core-js/es6/weak-map';
35+
import 'core-js/es6/set';
3636

3737
/**
3838
* If the application will be indexed by Google Search, the following is required.
3939
* Googlebot uses a renderer based on Chrome 41.
4040
* https://developers.google.com/search/docs/guides/rendering
4141
**/
42-
// import 'core-js/es6/array';
42+
import 'core-js/es6/array';
4343

4444
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
45-
// import 'classlist.js'; // Run `npm install --save classlist.js`.
45+
import 'classlist.js'; // Run `npm install --save classlist.js`.
4646

4747
/** IE10 and IE11 requires the following for the Reflect API. */
48-
// import 'core-js/es6/reflect';
48+
import 'core-js/es6/reflect';
4949

5050
/**
5151
* Web Animations `@angular/platform-browser/animations`
5252
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
5353
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
5454
**/
55-
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
55+
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
5656

5757
/**
5858
* By default, zone.js will patch all possible macroTask and DomEvents
5959
* user can disable parts of macroTask/DomEvents patch by setting following flags
6060
*/
6161

62-
// (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
63-
// (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
64-
// (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
62+
(window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
63+
(window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
64+
(window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
6565

6666
/*
6767
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
6868
* with the following flag, it will bypass `zone.js` patch for IE/Edge
6969
*/
70-
// (window as any).__Zone_enable_cross_context_check = true;
70+
(window as any).__Zone_enable_cross_context_check = true;
7171

7272
/***************************************************************************************************
7373
* Zone JS is required by default for Angular itself.

0 commit comments

Comments
 (0)