* Support polymophism when sending or receiving interfaces * Handle attempts to deserialize interfaces nicer * updated OpenApi.json * Update src/Umbraco.Cms.Api.Common/Json/NamedSystemTextJsonInputFormatter.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Cms.Api.Management/ManagementApiComposer.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Cms.Api.Management/OpenApi/ConfigureUmbracoSwaggerGenOptions.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Update src/Umbraco.Infrastructure/Serialization/UmbracoJsonTypeInfoResolver.cs Co-authored-by: Mole <nikolajlauridsen@protonmail.ch> * Invert to avoid nesting * Updated OpenApi.json * Update schema --------- Co-authored-by: Mole <nikolajlauridsen@protonmail.ch>
72 lines
2.7 KiB
C#
72 lines
2.7 KiB
C#
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
using System.Text.Json.Serialization.Metadata;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Options;
|
|
using Umbraco.Cms.Core.Composing;
|
|
using Umbraco.Cms.Core.DependencyInjection;
|
|
using Umbraco.Cms.Api.Common.Configuration;
|
|
using Umbraco.Cms.Api.Common.DependencyInjection;
|
|
using Umbraco.Cms.Api.Management.DependencyInjection;
|
|
using Umbraco.Cms.Api.Management.Serialization;
|
|
using Umbraco.Cms.Infrastructure.Serialization;
|
|
using Umbraco.Cms.Web.Common.ApplicationBuilder;
|
|
using Umbraco.New.Cms.Core.Models.Configuration;
|
|
|
|
namespace Umbraco.Cms.Api.Management;
|
|
|
|
public class ManagementApiComposer : IComposer
|
|
{
|
|
public void Compose(IUmbracoBuilder builder)
|
|
{
|
|
// TODO Should just call a single extension method that can be called fromUmbracoTestServerTestBase too, instead of calling this method
|
|
|
|
IServiceCollection services = builder.Services;
|
|
|
|
builder
|
|
.AddJson()
|
|
.AddNewInstaller()
|
|
.AddUpgrader()
|
|
.AddSearchManagement()
|
|
.AddTrees()
|
|
.AddLanguages()
|
|
.AddDictionary()
|
|
.AddFileUpload()
|
|
.AddHealthChecks()
|
|
.AddModelsBuilder()
|
|
.AddRedirectUrl()
|
|
.AddTrackedReferences()
|
|
.AddDataTypes()
|
|
.AddTemplates()
|
|
.AddLogViewer()
|
|
.AddBackOfficeAuthentication()
|
|
.AddApiVersioning()
|
|
.AddSwaggerGen();
|
|
|
|
services
|
|
.ConfigureOptions<ConfigureMvcOptions>()
|
|
.Configure<UmbracoPipelineOptions>(options =>
|
|
{
|
|
options.AddFilter(new UmbracoPipelineFilter(
|
|
"BackOfficeManagementApiFilter",
|
|
applicationBuilder => applicationBuilder.UseProblemDetailsExceptionHandling(),
|
|
applicationBuilder => applicationBuilder.UseSwagger(),
|
|
applicationBuilder => applicationBuilder.UseEndpoints()));
|
|
})
|
|
.AddControllers()
|
|
.AddJsonOptions(_ =>
|
|
{
|
|
// any generic JSON options go here
|
|
})
|
|
.AddJsonOptions(New.Cms.Core.Constants.JsonOptionsNames.BackOffice, _ => { });
|
|
|
|
services.ConfigureOptions<ConfigureUmbracoBackofficeJsonOptions>( );
|
|
|
|
// FIXME: when this is moved to core, make the AddUmbracoOptions extension private again and remove core InternalsVisibleTo for Umbraco.Cms.Api.Management
|
|
builder.AddUmbracoOptions<NewBackOfficeSettings>();
|
|
// FIXME: remove this when NewBackOfficeSettings is moved to core
|
|
services.AddSingleton<IValidateOptions<NewBackOfficeSettings>, NewBackOfficeSettingsValidator>();
|
|
}
|
|
}
|
|
|