Skip to content

Commit

Permalink
Fixed a bug in cbl import flow and disabled swagger gen due to it not…
Browse files Browse the repository at this point in the history
… supporting [FromQuery] on a post
  • Loading branch information
majora2007 committed Sep 10, 2024
1 parent d35e828 commit 5853d01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
8 changes: 4 additions & 4 deletions API/API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<LangVersion>latestmajor</LangVersion>
</PropertyGroup>

<!-- <Target Name="PostBuild" AfterTargets="Build" Condition=" '$(Configuration)' == 'Debug' ">-->
<!-- <Delete Files="../openapi.json" />-->
<!-- <Exec Command="swagger tofile &#45;&#45;output ../openapi.json bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).dll v1" />-->
<!-- </Target>-->
<Target Name="PostBuild" AfterTargets="Build" Condition=" '$(Configuration)' == 'Debug' ">
<Delete Files="../openapi.json" />
<Exec Command="swagger tofile --output ../openapi.json bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).dll v1" />
</Target>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>false</DebugSymbols>
Expand Down
15 changes: 9 additions & 6 deletions API/Controllers/CBLController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using API.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;

namespace API.Controllers;

Expand All @@ -31,16 +32,17 @@ public CblController(IReadingListService readingListService, IDirectoryService d
/// If this returns errors, the cbl will always be rejected by Kavita.
/// </summary>
/// <param name="cbl">FormBody with parameter name of cbl</param>
/// <param name="comicVineMatching">Use comic vine matching or not. Defaults to false</param>
/// <param name="useComicVineMatching">Use comic vine matching or not. Defaults to false</param>
/// <returns></returns>
[HttpPost("validate")]
public async Task<ActionResult<CblImportSummaryDto>> ValidateCbl(IFormFile cbl, [FromQuery] bool comicVineMatching = false)
[SwaggerIgnore]
public async Task<ActionResult<CblImportSummaryDto>> ValidateCbl(IFormFile cbl, [FromQuery] bool useComicVineMatching = false)
{
var userId = User.GetUserId();
try
{
var cblReadingList = await SaveAndLoadCblFile(cbl);
var importSummary = await _readingListService.ValidateCblFile(userId, cblReadingList, comicVineMatching);
var importSummary = await _readingListService.ValidateCblFile(userId, cblReadingList, useComicVineMatching);
importSummary.FileName = cbl.FileName;
return Ok(importSummary);
}
Expand Down Expand Up @@ -82,16 +84,17 @@ public async Task<ActionResult<CblImportSummaryDto>> ValidateCbl(IFormFile cbl,
/// </summary>
/// <param name="cbl">FormBody with parameter name of cbl</param>
/// <param name="dryRun">If true, will only emulate the import but not perform. This should be done to preview what will happen</param>
/// <param name="comicVineMatching">Use comic vine matching or not. Defaults to false</param>
/// <param name="useComicVineMatching">Use comic vine matching or not. Defaults to false</param>
/// <returns></returns>
[HttpPost("import")]
public async Task<ActionResult<CblImportSummaryDto>> ImportCbl(IFormFile cbl, [FromQuery] bool dryRun = false, [FromQuery] bool comicVineMatching = false)
[SwaggerIgnore]
public async Task<ActionResult<CblImportSummaryDto>> ImportCbl(IFormFile cbl, [FromQuery] bool dryRun = false, [FromQuery] bool useComicVineMatching = false)
{
try
{
var userId = User.GetUserId();
var cblReadingList = await SaveAndLoadCblFile(cbl);
var importSummary = await _readingListService.CreateReadingListFromCbl(userId, cblReadingList, dryRun, comicVineMatching);
var importSummary = await _readingListService.CreateReadingListFromCbl(userId, cblReadingList, dryRun, useComicVineMatching);
importSummary.FileName = cbl.FileName;

return Ok(importSummary);
Expand Down

0 comments on commit 5853d01

Please sign in to comment.