Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CleanArchitecture
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CleanArchitecture
Commits
dd6987c1
Unverified
Commit
dd6987c1
authored
Nov 02, 2017
by
Steve Smith
Committed by
GitHub
Nov 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from ardalis/ardalis/swagger
Adding Swagger
parents
f2cb9398
4136bf9f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
1 deletion
+19
-1
ToDoItemsController.cs
src/CleanArchitecture.Web/Api/ToDoItemsController.cs
+2
-1
CleanArchitecture.Web.csproj
src/CleanArchitecture.Web/CleanArchitecture.Web.csproj
+1
-0
Startup.cs
src/CleanArchitecture.Web/Startup.cs
+15
-0
Index.cshtml
src/CleanArchitecture.Web/Views/Home/Index.cshtml
+1
-0
No files found.
src/CleanArchitecture.Web/Api/ToDoItemsController.cs
View file @
dd6987c1
...
@@ -39,7 +39,8 @@ namespace CleanArchitecture.Web.Api
...
@@ -39,7 +39,8 @@ namespace CleanArchitecture.Web.Api
}
}
// POST: api/ToDoItems
// POST: api/ToDoItems
public
async
Task
<
IActionResult
>
Post
([
FromBody
]
ToDoItemDTO
item
)
[
HttpPost
]
public
IActionResult
Post
([
FromBody
]
ToDoItemDTO
item
)
{
{
var
todoItem
=
new
ToDoItem
()
var
todoItem
=
new
ToDoItem
()
{
{
...
...
src/CleanArchitecture.Web/CleanArchitecture.Web.csproj
View file @
dd6987c1
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
...
...
src/CleanArchitecture.Web/Startup.cs
View file @
dd6987c1
...
@@ -9,6 +9,7 @@ using Microsoft.Extensions.Configuration;
...
@@ -9,6 +9,7 @@ using Microsoft.Extensions.Configuration;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
StructureMap
;
using
StructureMap
;
using
Swashbuckle.AspNetCore.Swagger
;
namespace
CleanArchitecture.Web
namespace
CleanArchitecture.Web
{
{
...
@@ -32,6 +33,11 @@ namespace CleanArchitecture.Web
...
@@ -32,6 +33,11 @@ namespace CleanArchitecture.Web
services
.
AddMvc
()
services
.
AddMvc
()
.
AddControllersAsServices
();
.
AddControllersAsServices
();
services
.
AddSwaggerGen
(
c
=>
{
c
.
SwaggerDoc
(
"v1"
,
new
Info
{
Title
=
"My API"
,
Version
=
"v1"
});
});
var
container
=
new
Container
();
var
container
=
new
Container
();
container
.
Configure
(
config
=>
container
.
Configure
(
config
=>
...
@@ -83,6 +89,15 @@ namespace CleanArchitecture.Web
...
@@ -83,6 +89,15 @@ namespace CleanArchitecture.Web
app
.
UseStaticFiles
();
app
.
UseStaticFiles
();
// Enable middleware to serve generated Swagger as a JSON endpoint.
app
.
UseSwagger
();
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint.
app
.
UseSwaggerUI
(
c
=>
{
c
.
SwaggerEndpoint
(
"/swagger/v1/swagger.json"
,
"My API V1"
);
});
app
.
UseMvc
(
routes
=>
app
.
UseMvc
(
routes
=>
{
{
routes
.
MapRoute
(
routes
.
MapRoute
(
...
...
src/CleanArchitecture.Web/Views/Home/Index.cshtml
View file @
dd6987c1
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
<ul>
<ul>
<li><a asp-area="" asp-controller="ToDo" asp-action="Populate">Load Sample To Do Items</a></li>
<li><a asp-area="" asp-controller="ToDo" asp-action="Populate">Load Sample To Do Items</a></li>
<li><a asp-area="" asp-controller="ToDo" asp-action="Index">List To Do Items</a></li>
<li><a asp-area="" asp-controller="ToDo" asp-action="Index">List To Do Items</a></li>
<li><a href="/swagger">API Documentation (Swagger)</a></li>
</ul>
</ul>
</div>
</div>
<div class="col-md-6">
<div class="col-md-6">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment