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.
pull/7561/head
David Mouse 3 years ago
parent 2133c6e348
commit e9ce82445e

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

@ -1,4 +1,5 @@
using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.ApiClient; using MediaBrowser.Model.ApiClient;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
@ -14,6 +15,17 @@ namespace Jellyfin.Server.Filters
/// </summary> /// </summary>
public class AdditionalModelFilter : IDocumentFilter 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 /> /// <inheritdoc />
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) 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(SessionMessageType), context.SchemaRepository);
context.SchemaGenerator.GenerateSchema(typeof(ServerDiscoveryInfo), context.SchemaRepository); context.SchemaGenerator.GenerateSchema(typeof(ServerDiscoveryInfo), context.SchemaRepository);
foreach (var configuration in _serverConfigurationManager.GetConfigurationStores())
{
context.SchemaGenerator.GenerateSchema(configuration.ConfigurationType, context.SchemaRepository);
}
} }
} }
} }

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

Loading…
Cancel
Save