Skip to content

Commit

Permalink
Merge branch 'v13/dev' into v13/feature/extension-model
Browse files Browse the repository at this point in the history
  • Loading branch information
kjac committed Feb 15, 2023
2 parents e4223ef + bf4e745 commit 04ea016
Show file tree
Hide file tree
Showing 21 changed files with 635 additions and 3,074 deletions.
5 changes: 4 additions & 1 deletion build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ stages:
}
}
dotnet pack $(solution) --configuration $(buildConfiguration) --no-build --output $(Build.ArtifactStagingDirectory)/nupkg
foreach($csproj in Get-ChildItem –Path "src/" -Recurse -Filter *.csproj)
{
dotnet pack $csproj --configuration $(buildConfiguration) --no-build --output $(Build.ArtifactStagingDirectory)/nupkg
}
- script: |
sha="$(Build.SourceVersion)"
sha=${sha:0:7}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;

namespace Umbraco.Cms.Api.Common.Configuration;

public class ConfigureApiBehaviorOptions : IConfigureOptions<ApiBehaviorOptions>
{
public void Configure(ApiBehaviorOptions options) =>
// disable ProblemDetails as default result type for every non-success response (i.e. 404)
// - see https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.apibehavioroptions.suppressmapclienterrors
options.SuppressMapClientErrors = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Umbraco.Cms.Api.Common.Json;

public class NamedSystemTextJsonInputFormatter : SystemTextJsonInputFormatter
internal class NamedSystemTextJsonInputFormatter : SystemTextJsonInputFormatter
{
private readonly string _jsonOptionsName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace Umbraco.Cms.Api.Common.Json;

public class NamedSystemTextJsonOutputFormatter : SystemTextJsonOutputFormatter

internal class NamedSystemTextJsonOutputFormatter : SystemTextJsonOutputFormatter
{
private readonly string _jsonOptionsName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Api.Management.ViewModels.Dictionary;
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
using Umbraco.Cms.Core;

namespace Umbraco.Cms.Api.Management.Controllers.Dictionary;

Expand All @@ -25,7 +26,7 @@ public AllDictionaryController(IDictionaryItemService dictionaryItemService, IUm
public async Task<ActionResult<PagedViewModel<DictionaryOverviewViewModel>>> All(int skip = 0, int take = 100)
{
// unfortunately we can't paginate here...we'll have to get all and paginate in memory
IDictionaryItem[] items = (await _dictionaryItemService.GetDescendantsAsync(null)).ToArray();
IDictionaryItem[] items = (await _dictionaryItemService.GetDescendantsAsync(Constants.System.RootKey)).ToArray();
var model = new PagedViewModel<DictionaryOverviewViewModel>
{
Total = items.Length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ExportDictionaryController(IDictionaryItemService dictionaryItemService,
[HttpGet("{key:guid}/export")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(FileContentResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<IActionResult> Export(Guid key, bool includeChildren = false)
{
IDictionaryItem? dictionaryItem = await _dictionaryItemService.GetAsync(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public async Task<IActionResult> Setup(InstallViewModel installData)
InstallData data = _mapper.Map<InstallData>(installData)!;
await _installService.Install(data);

var backOfficePath = _globalSettings.GetBackOfficePath(_hostingEnvironment);
return Created(backOfficePath, null);
return Ok();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public UpdateLanguageController(

[HttpPut($"{{{nameof(isoCode)}}}")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> Update(string isoCode, LanguageUpdateModel languageUpdateModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ByNameSavedSearchLogViewerController(ILogViewerService logViewerService,
/// <returns>The saved log search or not found result.</returns>
[HttpGet("{name}")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(typeof(SavedLogSearchViewModel), StatusCodes.Status200OK)]
public async Task<ActionResult<SavedLogSearchViewModel>> ByName(string name)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DeleteSavedSearchLogViewerController : SavedSearchLogViewerControll
/// <returns>The result of the deletion.</returns>
[HttpDelete("{name}")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> Delete(string name)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public BuildModelsBuilderController(
}

[HttpPost("build")]
[ProducesResponseType(typeof(CreatedResult), StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status428PreconditionRequired)]
[MapToApiVersion("1.0")]
public async Task<IActionResult> BuildModels()
Expand All @@ -46,7 +46,7 @@ public async Task<IActionResult> BuildModels()
Type = "Error",
};

return await Task.FromResult(new ObjectResult(problemDetailsModel) { StatusCode = StatusCodes.Status428PreconditionRequired });
return new ObjectResult(problemDetailsModel) { StatusCode = StatusCodes.Status428PreconditionRequired };
}

_modelGenerator.GenerateModels();
Expand All @@ -57,6 +57,6 @@ public async Task<IActionResult> BuildModels()
_mbErrors.Report("Failed to build models.", e);
}

return await Task.FromResult(Created("api/v1/modelsBuilderDashboard", null));
return Ok();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ByIdRelationController(IRelationService relationService, IRelationViewMod
[HttpGet("{id:int}")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(RelationViewModel), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult> ById(int id)
{
IRelation? relation = _relationService.GetById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ private static IUmbracoBuilder AddOpenIddict(this IUmbracoBuilder builder)
{
// Enable the authorization and token endpoints.
options
.SetAuthorizationEndpointUris(Controllers.Security.Paths.BackOfficeApiAuthorizationEndpoint)
.SetTokenEndpointUris(Controllers.Security.Paths.BackOfficeApiTokenEndpoint);
.SetAuthorizationEndpointUris(Controllers.Security.Paths.BackOfficeApiAuthorizationEndpoint.TrimStart('/'))
.SetTokenEndpointUris(Controllers.Security.Paths.BackOfficeApiTokenEndpoint.TrimStart('/'));

// Enable authorization code flow with PKCE
options
Expand Down
5 changes: 1 addition & 4 deletions src/Umbraco.Cms.Api.Management/ManagementApiComposer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
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;
Expand All @@ -9,7 +6,6 @@
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;

Expand Down Expand Up @@ -46,6 +42,7 @@ public void Compose(IUmbracoBuilder builder)

services
.ConfigureOptions<ConfigureMvcOptions>()
.ConfigureOptions<ConfigureApiBehaviorOptions>()
.Configure<UmbracoPipelineOptions>(options =>
{
options.AddFilter(new UmbracoPipelineFilter(
Expand Down
Loading

0 comments on commit 04ea016

Please sign in to comment.