Fixes the swagger ui access
All checks were successful
Dotnet build and test / build (pull_request) Successful in 12m25s
All checks were successful
Dotnet build and test / build (pull_request) Successful in 12m25s
This commit is contained in:
parent
8e3862ed26
commit
a793996b70
2 changed files with 23 additions and 3 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -44,5 +44,8 @@ DataDir/
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
# gitleaks scan output (local secret-scan report, not for the repo)
|
# gitleaks scan output (local secret-scan report, not for the repo)
|
||||||
gitleaks-report.json
|
/gitleaks-report.json
|
||||||
|
/test-report.html
|
||||||
|
/test-report.xml
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Yavsc.Models;
|
using Yavsc.Models;
|
||||||
|
|
@ -82,8 +83,17 @@ namespace Yavsc.Controllers
|
||||||
return CreatedAtRoute("GetComment", new { id = comment.Id }, new { id = comment.Id, dateCreated = comment.DateCreated });
|
return CreatedAtRoute("GetComment", new { id = comment.Id }, new { id = comment.Id, dateCreated = comment.DateCreated });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Actions MVC scaffoldées (vues CRUD) ---------------------
|
||||||
|
// Ces actions ne font pas partie de la surface d'API documentée
|
||||||
|
// par Swagger. Elles sont exclues de l'ApiExplorer : sinon, comme
|
||||||
|
// le contrôleur porte [Route("~/api/v1/blogcomments")], leurs
|
||||||
|
// [HttpPost] sans template propre atterrissent sur la même route
|
||||||
|
// "POST api/v1/blogcomments" que l'action Post ci-dessus, et
|
||||||
|
// Swashbuckle lève une SwaggerGeneratorException (conflicting
|
||||||
|
// method/path) au démarrage de /swagger.
|
||||||
// GET: Comments
|
// GET: Comments
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> Index()
|
public async Task<IActionResult> Index()
|
||||||
{
|
{
|
||||||
var applicationDbContext = _context.Comment.Include(c => c.Post);
|
var applicationDbContext = _context.Comment.Include(c => c.Post);
|
||||||
|
|
@ -91,6 +101,7 @@ namespace Yavsc.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Comments/Details/5
|
// GET: Comments/Details/5
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> Details(long? id)
|
public async Task<IActionResult> Details(long? id)
|
||||||
{
|
{
|
||||||
if (id == null)
|
if (id == null)
|
||||||
|
|
@ -109,6 +120,7 @@ namespace Yavsc.Controllers
|
||||||
|
|
||||||
// GET: Comments/Create (MVC form endpoint)
|
// GET: Comments/Create (MVC form endpoint)
|
||||||
[HttpGet("form")]
|
[HttpGet("form")]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public IActionResult Create()
|
public IActionResult Create()
|
||||||
{
|
{
|
||||||
ViewBag.ReceiverId = new SelectList(_context.BlogSpot, "Id", "Title");
|
ViewBag.ReceiverId = new SelectList(_context.BlogSpot, "Id", "Title");
|
||||||
|
|
@ -118,6 +130,7 @@ namespace Yavsc.Controllers
|
||||||
// POST: Comments/Create (MVC form endpoint)
|
// POST: Comments/Create (MVC form endpoint)
|
||||||
[HttpPost("form")]
|
[HttpPost("form")]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> Create(Comment comment)
|
public async Task<IActionResult> Create(Comment comment)
|
||||||
{
|
{
|
||||||
comment.UserCreated = User.GetUserId();
|
comment.UserCreated = User.GetUserId();
|
||||||
|
|
@ -138,6 +151,7 @@ namespace Yavsc.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Comments/Edit/5
|
// GET: Comments/Edit/5
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> Edit(long? id)
|
public async Task<IActionResult> Edit(long? id)
|
||||||
{
|
{
|
||||||
if (id == null)
|
if (id == null)
|
||||||
|
|
@ -157,6 +171,7 @@ namespace Yavsc.Controllers
|
||||||
// POST: Comments/Edit/5
|
// POST: Comments/Edit/5
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> Edit(Comment comment)
|
public async Task<IActionResult> Edit(Comment comment)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
|
|
@ -171,6 +186,7 @@ namespace Yavsc.Controllers
|
||||||
|
|
||||||
// GET: Comments/Delete/5
|
// GET: Comments/Delete/5
|
||||||
[ActionName("Delete")]
|
[ActionName("Delete")]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> Delete(long? id)
|
public async Task<IActionResult> Delete(long? id)
|
||||||
{
|
{
|
||||||
if (id == null)
|
if (id == null)
|
||||||
|
|
@ -190,6 +206,7 @@ namespace Yavsc.Controllers
|
||||||
// POST: Comments/Delete/5
|
// POST: Comments/Delete/5
|
||||||
[HttpPost, ActionName("Delete")]
|
[HttpPost, ActionName("Delete")]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> DeleteConfirmed(long id)
|
public async Task<IActionResult> DeleteConfirmed(long id)
|
||||||
{
|
{
|
||||||
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
Comment comment = await _context.Comment.SingleAsync(m => m.Id == id);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue