diff --git a/src/Umbraco.Cms.ManagementApi/Controllers/Search/SearcherSearchSearchController.cs b/src/Umbraco.Cms.ManagementApi/Controllers/Search/SearcherSearchSearchController.cs index 36463ac3d8ed..3b9f7f6f8510 100644 --- a/src/Umbraco.Cms.ManagementApi/Controllers/Search/SearcherSearchSearchController.cs +++ b/src/Umbraco.Cms.ManagementApi/Controllers/Search/SearcherSearchSearchController.cs @@ -19,7 +19,7 @@ public class SearcherSearchSearchController : SearchControllerBase [HttpGet("searcher/{searcherName}/search")] [MapToApiVersion("1.0")] - [ProducesResponseType(typeof(PagedViewModel>), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(PagedViewModel), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] public async Task>> GetSearchResults(string searcherName, string? query, int skip, int take) { diff --git a/src/Umbraco.Cms.ManagementApi/Factories/IndexViewModelFactory.cs b/src/Umbraco.Cms.ManagementApi/Factories/IndexViewModelFactory.cs index 902d05a9cd8f..a23e22156e1b 100644 --- a/src/Umbraco.Cms.ManagementApi/Factories/IndexViewModelFactory.cs +++ b/src/Umbraco.Cms.ManagementApi/Factories/IndexViewModelFactory.cs @@ -37,6 +37,21 @@ public IndexViewModel Create(IIndex index) Attempt isHealthy = indexDiag.IsHealthy(); + var properties = new Dictionary(); + + foreach (var property in indexDiag.Metadata) + { + if (property.Value is null) + { + properties[property.Key] = null; + } + else + { + var propertyType = property.Value.GetType(); + properties[property.Key] = propertyType.IsClass && !propertyType.IsArray ? property.Value?.ToString() : property.Value; + } + } + var indexerModel = new IndexViewModel { Name = index.Name, @@ -45,6 +60,7 @@ public IndexViewModel Create(IIndex index) SearcherName = index.Searcher.Name, DocumentCount = indexDiag.GetDocumentCount(), FieldCount = indexDiag.GetFieldNames().Count(), + ProviderProperties = properties, }; return indexerModel; diff --git a/src/Umbraco.Cms.ManagementApi/OpenApi.json b/src/Umbraco.Cms.ManagementApi/OpenApi.json index 1e5a80b5a173..d2c27c5746bd 100644 --- a/src/Umbraco.Cms.ManagementApi/OpenApi.json +++ b/src/Umbraco.Cms.ManagementApi/OpenApi.json @@ -2827,7 +2827,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PagedPaged" + "$ref": "#/components/schemas/PagedSearchResult" } } } @@ -4854,11 +4854,18 @@ "additionalProperties": false }, "Index": { + "required": [ + "canRebuild", + "documentCount", + "fieldCount", + "isHealthy", + "name" + ], "type": "object", "properties": { "name": { - "type": "string", - "nullable": true + "minLength": 1, + "type": "string" }, "healthStatus": { "type": "string", @@ -4882,6 +4889,11 @@ "fieldCount": { "type": "integer", "format": "int32" + }, + "providerProperties": { + "type": "object", + "additionalProperties": {}, + "nullable": true } }, "additionalProperties": false @@ -5754,26 +5766,6 @@ }, "additionalProperties": false }, - "PagedPaged": { - "required": [ - "items", - "total" - ], - "type": "object", - "properties": { - "total": { - "type": "integer", - "format": "int64" - }, - "items": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PagedSearchResult" - } - } - }, - "additionalProperties": false - }, "PagedRecycleBinItem": { "required": [ "items", diff --git a/src/Umbraco.Cms.ManagementApi/ViewModels/Search/IndexViewModel.cs b/src/Umbraco.Cms.ManagementApi/ViewModels/Search/IndexViewModel.cs index c28b6c5e025b..9a63bc88862c 100644 --- a/src/Umbraco.Cms.ManagementApi/ViewModels/Search/IndexViewModel.cs +++ b/src/Umbraco.Cms.ManagementApi/ViewModels/Search/IndexViewModel.cs @@ -1,18 +1,27 @@ -namespace Umbraco.Cms.ManagementApi.ViewModels.Search; +using System.ComponentModel.DataAnnotations; + +namespace Umbraco.Cms.ManagementApi.ViewModels.Search; public class IndexViewModel { + [Required] public string Name { get; init; } = null!; public string? HealthStatus { get; init; } + [Required] public bool IsHealthy => HealthStatus == "Healthy"; + [Required] public bool CanRebuild { get; init; } public string SearcherName { get; init; } = null!; + [Required] public long DocumentCount { get; init; } + [Required] public int FieldCount { get; init; } + + public IReadOnlyDictionary? ProviderProperties { get; init; } }