fix: Improve Swagger documentation (#4652)

* Upgrade Swashbuckle dependency

* Document /token response

* Add support for Newtonsoft annotations in Swagger

* Remove unecessary ActionResult [skip ci]
pull/4667/head
sephrat 2 years ago committed by GitHub
parent ae430e700c
commit 181892bcfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Ombi.Api.Plex.Models
{
@ -38,6 +39,9 @@ namespace Ombi.Api.Plex.Models
public string grandparentTheme { get; set; }
public string chapterSource { get; set; }
public Medium[] Media { get; set; }
[JsonProperty("guids")]
public List<PlexGuids> Guid { get; set; } = new List<PlexGuids>();
}

@ -16,9 +16,20 @@ using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Ombi.Core.Settings;
using Ombi.Settings.Settings.Models;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
namespace Ombi.Controllers.V1
{
public class Token
{
[JsonProperty("access_token")]
public string AccessToken { get; set; }
public DateTime Expiration { get; set; }
}
[ApiV1]
[Produces("application/json")]
[ApiController]
@ -47,6 +58,7 @@ namespace Ombi.Controllers.V1
/// <returns></returns>
[HttpPost]
[ProducesResponseType(401)]
[ProducesResponseType(typeof(Token), 200)]
public async Task<IActionResult> GetToken([FromBody] UserAuthModel model)
{
if (!model.UsePlexOAuth)
@ -161,10 +173,10 @@ namespace Ombi.Controllers.V1
await _userManager.UpdateAsync(user);
return new JsonResult(new
return Ok(new Token
{
access_token = accessToken,
expiration = token.ValidTo
AccessToken = accessToken,
Expiration = token.ValidTo
});
}

@ -79,6 +79,8 @@ namespace Ombi
c.DescribeAllParametersInCamelCase();
});
services.AddSwaggerGenNewtonsoftSupport();
}
public static void AddAppSettingsValues(this IServiceCollection services, IConfigurationRoot configuration)

@ -79,7 +79,8 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.3.1" />
<PackageReference Include="System.Security.Cryptography.Csp" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.0" />

Loading…
Cancel
Save