From 5296013d89d085e67b5b5a8deb8521b7b722da0e Mon Sep 17 00:00:00 2001 From: Kenn Jacobsen Date: Mon, 27 May 2024 19:38:57 +0200 Subject: [PATCH] Enrich the datatype references output with content type data (#16417) --- .../DataTypeReferencePresentationFactory.cs | 9 +++- src/Umbraco.Cms.Api.Management/OpenApi.json | 45 +++++++++++++++---- .../DataTypeContentTypeReferenceModel.cs | 12 +++++ .../DataTypeReferenceResponseModel.cs | 4 +- 4 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeContentTypeReferenceModel.cs diff --git a/src/Umbraco.Cms.Api.Management/Factories/DataTypeReferencePresentationFactory.cs b/src/Umbraco.Cms.Api.Management/Factories/DataTypeReferencePresentationFactory.cs index aa6b150a94..25382c7209 100644 --- a/src/Umbraco.Cms.Api.Management/Factories/DataTypeReferencePresentationFactory.cs +++ b/src/Umbraco.Cms.Api.Management/Factories/DataTypeReferencePresentationFactory.cs @@ -47,8 +47,13 @@ public class DataTypeReferencePresentationFactory : IDataTypeReferencePresentati IEnumerable propertyAliases = propertyAliasesByGuid[contentType.Key]; yield return new DataTypeReferenceResponseModel { - Id = contentType.Key, - Type = usagesByEntityType.Key, + ContentType = new DataTypeContentTypeReferenceModel + { + Id = contentType.Key, + Name = contentType.Name, + Icon = contentType.Icon, + Type = usagesByEntityType.Key, + }, Properties = contentType .PropertyTypes .Where(propertyType => propertyAliases.InvariantContains(propertyType.Alias)) diff --git a/src/Umbraco.Cms.Api.Management/OpenApi.json b/src/Umbraco.Cms.Api.Management/OpenApi.json index 6528b84091..6cd20dc3ce 100644 --- a/src/Umbraco.Cms.Api.Management/OpenApi.json +++ b/src/Umbraco.Cms.Api.Management/OpenApi.json @@ -35399,6 +35399,34 @@ ], "type": "string" }, + "DataTypeContentTypeReferenceModel": { + "required": [ + "icon", + "id", + "name", + "type" + ], + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "type": { + "type": "string", + "nullable": true + }, + "name": { + "type": "string", + "nullable": true + }, + "icon": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, "DataTypeItemResponseModel": { "required": [ "id", @@ -35457,18 +35485,17 @@ }, "DataTypeReferenceResponseModel": { "required": [ - "id", - "properties", - "type" + "contentType", + "properties" ], "type": "object", "properties": { - "id": { - "type": "string", - "format": "uuid" - }, - "type": { - "type": "string" + "contentType": { + "oneOf": [ + { + "$ref": "#/components/schemas/DataTypeContentTypeReferenceModel" + } + ] }, "properties": { "type": "array", diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeContentTypeReferenceModel.cs b/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeContentTypeReferenceModel.cs new file mode 100644 index 0000000000..d89033584d --- /dev/null +++ b/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeContentTypeReferenceModel.cs @@ -0,0 +1,12 @@ +namespace Umbraco.Cms.Api.Management.ViewModels.DataType; + +public class DataTypeContentTypeReferenceModel +{ + public required Guid Id { get; set; } + + public required string? Type { get; set; } + + public required string? Name { get; set; } + + public required string? Icon { get; set; } +} diff --git a/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeReferenceResponseModel.cs b/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeReferenceResponseModel.cs index 7c9c54a72d..2aa7dc39d5 100644 --- a/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeReferenceResponseModel.cs +++ b/src/Umbraco.Cms.Api.Management/ViewModels/DataType/DataTypeReferenceResponseModel.cs @@ -2,9 +2,7 @@ public class DataTypeReferenceResponseModel { - public required Guid Id { get; init; } - - public required string Type { get; init; } + public required DataTypeContentTypeReferenceModel ContentType { get; init; } public required IEnumerable Properties { get; init; } }