From a541e24508dbf0d5155c7be18205ad82572fc0e1 Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 21 Feb 2023 09:18:57 +0100 Subject: [PATCH 1/5] Add variance info to property type output --- .../Mapping/ContentType/ContentTypeMapDefinition.cs | 3 +++ src/Umbraco.Cms.Api.Management/OpenApi.json | 6 ++++++ .../ViewModels/ContentType/PropertyTypeViewModelBase.cs | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/Umbraco.Cms.Api.Management/Mapping/ContentType/ContentTypeMapDefinition.cs b/src/Umbraco.Cms.Api.Management/Mapping/ContentType/ContentTypeMapDefinition.cs index 0591bf3676..97dd0a8666 100644 --- a/src/Umbraco.Cms.Api.Management/Mapping/ContentType/ContentTypeMapDefinition.cs +++ b/src/Umbraco.Cms.Api.Management/Mapping/ContentType/ContentTypeMapDefinition.cs @@ -1,6 +1,7 @@ using Umbraco.Cms.Api.Management.ViewModels.ContentType; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Models; +using Umbraco.Extensions; namespace Umbraco.Cms.Api.Management.Mapping.ContentType; @@ -29,6 +30,8 @@ public abstract class ContentTypeMapDefinition Date: Tue, 21 Feb 2023 09:22:00 +0100 Subject: [PATCH 2/5] Update src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs Co-authored-by: Bjarke Berg --- .../Controllers/Document/ByKeyDocumentController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs index a9a60196a0..b4a8dfc859 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs @@ -22,7 +22,7 @@ public class ByKeyDocumentController : DocumentControllerBase [MapToApiVersion("1.0")] [ProducesResponseType(typeof(DocumentViewModel), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task> ByKey(Guid key) + public async Task ByKey(Guid key) { IContent? content = _contentService.GetById(key); if (content == null) From ee4bfa8f5a2b8a2e749f758c3bd7d5e8f311fce9 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 21 Feb 2023 09:22:09 +0100 Subject: [PATCH 3/5] Update src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs Co-authored-by: Bjarke Berg --- .../Controllers/DocumentType/ByKeyDocumentTypeController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs b/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs index 54492f875f..06135fc9d9 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs @@ -22,7 +22,7 @@ public class ByKeyDocumentTypeController : DocumentTypeControllerBase [MapToApiVersion("1.0")] [ProducesResponseType(typeof(DocumentTypeViewModel), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] - public async Task> ByKey(Guid key) + public async Task ByKey(Guid key) { IContentType? contentType = _contentTypeService.Get(key); if (contentType == null) From 6982b38ebde1752328572a8fd93395ca0ac50349 Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Tue, 21 Feb 2023 09:22:19 +0100 Subject: [PATCH 4/5] Update src/Umbraco.Cms.Api.Management/Factories/ContentUrlFactory.cs Co-authored-by: Bjarke Berg --- .../Factories/ContentUrlFactory.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Umbraco.Cms.Api.Management/Factories/ContentUrlFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/ContentUrlFactory.cs index 620caa02e6..9327038b76 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/ContentUrlFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/ContentUrlFactory.cs @@ -45,11 +45,7 @@ public class ContentUrlFactory : IContentUrlFactory public async Task> GetUrlsAsync(IContent content) { - if (_umbracoContextAccessor.TryGetUmbracoContext(out IUmbracoContext? umbracoContext) == false) - { - _loggerFactory.CreateLogger().LogWarning($"Unable to create an Umbraco context while attempting to get URLs for content: {content.Key}"); - return Array.Empty(); - } + IUmbracoContext umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); UrlInfo[] urlInfos = (await content.GetContentUrlsAsync( _publishedRouter, From 8541919880dcdb4207aa1fb861300c9f878a01f1 Mon Sep 17 00:00:00 2001 From: kjac Date: Tue, 21 Feb 2023 09:32:49 +0100 Subject: [PATCH 5/5] Add a few FIXME comments about async entity retrieval --- .../Controllers/Document/ByKeyDocumentController.cs | 1 + .../Controllers/DocumentType/ByKeyDocumentTypeController.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs b/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs index b4a8dfc859..1644eac84b 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/Document/ByKeyDocumentController.cs @@ -24,6 +24,7 @@ public class ByKeyDocumentController : DocumentControllerBase [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task ByKey(Guid key) { + // FIXME: create and use an async get method here. IContent? content = _contentService.GetById(key); if (content == null) { diff --git a/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs b/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs index 06135fc9d9..8fc1d43293 100644 --- a/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs +++ b/src/Umbraco.Cms.Api.Management/Controllers/DocumentType/ByKeyDocumentTypeController.cs @@ -24,6 +24,7 @@ public class ByKeyDocumentTypeController : DocumentTypeControllerBase [ProducesResponseType(StatusCodes.Status404NotFound)] public async Task ByKey(Guid key) { + // FIXME: create and use an async get method here. IContentType? contentType = _contentTypeService.Get(key); if (contentType == null) {