Add ConfigurationType Types to generated OpenAPI

This allows clients to see and work with the associated types for each NamedConfiguration key, even if the UpdateNamedConfiguration endpoint doesn't properly advertise its types.
This commit is contained in:
David Mouse 2022-04-01 01:55:28 -04:00
parent 2133c6e348
commit e9ce82445e
3 changed files with 30 additions and 1 deletions

View File

@ -398,6 +398,12 @@ namespace Emby.Server.Implementations.AppBase
});
}
/// <inheritdoc />
public ConfigurationStore[] GetConfigurationStores()
{
return _configurationStores;
}
/// <inheritdoc />
public Type GetConfigurationType(string key)
{

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.ApiClient;
using MediaBrowser.Model.Entities;
@ -14,6 +15,17 @@ namespace Jellyfin.Server.Filters
/// </summary>
public class AdditionalModelFilter : IDocumentFilter
{
private readonly IServerConfigurationManager _serverConfigurationManager;
/// <summary>
/// Initializes a new instance of the <see cref="AdditionalModelFilter"/> class.
/// </summary>
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
public AdditionalModelFilter(IServerConfigurationManager serverConfigurationManager)
{
_serverConfigurationManager = serverConfigurationManager;
}
/// <inheritdoc />
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
{
@ -29,6 +41,11 @@ namespace Jellyfin.Server.Filters
context.SchemaGenerator.GenerateSchema(typeof(SessionMessageType), context.SchemaRepository);
context.SchemaGenerator.GenerateSchema(typeof(ServerDiscoveryInfo), context.SchemaRepository);
foreach (var configuration in _serverConfigurationManager.GetConfigurationStores())
{
context.SchemaGenerator.GenerateSchema(configuration.ConfigurationType, context.SchemaRepository);
}
}
}
}

View File

@ -60,6 +60,12 @@ namespace MediaBrowser.Common.Configuration
/// <returns>System.Object.</returns>
object GetConfiguration(string key);
/// <summary>
/// Gets the array of coniguration stores.
/// </summary>
/// <returns>Array of ConfigurationStore.</returns>
ConfigurationStore[] GetConfigurationStores();
/// <summary>
/// Gets the type of the configuration.
/// </summary>