diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 19fe0b108..2a4a8fb13 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -398,6 +398,12 @@ namespace Emby.Server.Implementations.AppBase }); } + /// + public ConfigurationStore[] GetConfigurationStores() + { + return _configurationStores; + } + /// public Type GetConfigurationType(string key) { diff --git a/Jellyfin.Api/Controllers/ConfigurationController.cs b/Jellyfin.Api/Controllers/ConfigurationController.cs index 60529e990..464fadc06 100644 --- a/Jellyfin.Api/Controllers/ConfigurationController.cs +++ b/Jellyfin.Api/Controllers/ConfigurationController.cs @@ -86,21 +86,23 @@ namespace Jellyfin.Api.Controllers /// Updates named configuration. /// /// Configuration key. + /// Configuration. /// Named configuration updated. /// Update status. [HttpPost("Configuration/{key}")] [Authorize(Policy = Policies.RequiresElevation)] [ProducesResponseType(StatusCodes.Status204NoContent)] - public async Task UpdateNamedConfiguration([FromRoute, Required] string key) + public ActionResult UpdateNamedConfiguration([FromRoute, Required] string key, [FromBody, Required] JsonDocument configuration) { var configurationType = _configurationManager.GetConfigurationType(key); - var configuration = await JsonSerializer.DeserializeAsync(Request.Body, configurationType, _serializerOptions).ConfigureAwait(false); - if (configuration == null) + var deserializedConfiguration = configuration.Deserialize(configurationType, _serializerOptions); + + if (deserializedConfiguration == null) { throw new ArgumentException("Body doesn't contain a valid configuration"); } - _configurationManager.SaveConfiguration(key, configuration); + _configurationManager.SaveConfiguration(key, deserializedConfiguration); return NoContent(); } diff --git a/Jellyfin.Server/Filters/AdditionalModelFilter.cs b/Jellyfin.Server/Filters/AdditionalModelFilter.cs index 87a59e0b4..44e5b0d1e 100644 --- a/Jellyfin.Server/Filters/AdditionalModelFilter.cs +++ b/Jellyfin.Server/Filters/AdditionalModelFilter.cs @@ -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 /// public class AdditionalModelFilter : IDocumentFilter { + private readonly IServerConfigurationManager _serverConfigurationManager; + + /// + /// Initializes a new instance of the class. + /// + /// Instance of the interface. + public AdditionalModelFilter(IServerConfigurationManager serverConfigurationManager) + { + _serverConfigurationManager = serverConfigurationManager; + } + /// 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); + } } } } diff --git a/MediaBrowser.Common/Configuration/IConfigurationManager.cs b/MediaBrowser.Common/Configuration/IConfigurationManager.cs index fc63d9350..e6696a571 100644 --- a/MediaBrowser.Common/Configuration/IConfigurationManager.cs +++ b/MediaBrowser.Common/Configuration/IConfigurationManager.cs @@ -60,6 +60,12 @@ namespace MediaBrowser.Common.Configuration /// System.Object. object GetConfiguration(string key); + /// + /// Gets the array of coniguration stores. + /// + /// Array of ConfigurationStore. + ConfigurationStore[] GetConfigurationStores(); + /// /// Gets the type of the configuration. ///