Skip to content

Commit 6953fc3

Browse files
committed
Fix api sources generation and correct references
1 parent 541c82d commit 6953fc3

29 files changed

+728
-618
lines changed

src/Umbraco.Cms.Integrations.Search.Algolia/AlgoliaComposer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public void Compose(IUmbracoBuilder builder)
5050
Version = "Latest",
5151
Description = $"Describes the {Constants.ManagementApi.ApiTitle} available for handling indices."
5252
});
53+
54+
options.CustomOperationIds(e => $"{e.ActionDescriptor.RouteValues["action"]}");
5355
});
5456
}
5557

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/BuildIndexController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Algolia.Search.Models.Search;
22
using Asp.Versioning;
3+
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Logging;
56
using System.Text.Json;
@@ -15,6 +16,7 @@
1516
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1617
{
1718
[ApiVersion("1.0")]
19+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
1820
public class BuildIndexController : SearchControllerBase
1921
{
2022
public BuildIndexController(
@@ -41,6 +43,7 @@ public BuildIndexController(
4143
}
4244

4345
[HttpPost("index/build")]
46+
[ProducesResponseType(typeof(Result), StatusCodes.Status200OK)]
4447
public async Task<IActionResult> BuildIndex([FromBody] IndexConfiguration indexConfiguration)
4548
{
4649
var index = IndexStorage.GetById(indexConfiguration.Id);

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/DeleteIndexController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Algolia.Search.Models.Search;
22
using Asp.Versioning;
3+
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Logging;
56
using Umbraco.Cms.Core.Routing;
@@ -13,6 +14,7 @@
1314
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1415
{
1516
[ApiVersion("1.0")]
17+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
1618
public class DeleteIndexController : SearchControllerBase
1719
{
1820
public DeleteIndexController(
@@ -39,6 +41,7 @@ public DeleteIndexController(
3941
}
4042

4143
[HttpDelete("index/{id:int}")]
44+
[ProducesResponseType(typeof(Result), StatusCodes.Status200OK)]
4245
public async Task<IActionResult> DeleteIndex(int id)
4346
{
4447
var indexName = IndexStorage.GetById(id).Name;

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/GetContentTypesController.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1818
{
1919
[ApiVersion("1.0")]
20+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
2021
public class GetContentTypesController : SearchControllerBase
2122
{
2223
private readonly IContentTypeService _contentTypeService;
@@ -47,9 +48,14 @@ public GetContentTypesController(
4748
}
4849

4950
[HttpGet("content-type")]
51+
[ProducesResponseType(typeof(List<ContentTypeDto>), StatusCodes.Status200OK)]
52+
public IActionResult GetContentTypes() => Ok(GetContentTypes());
53+
5054
[HttpGet("content-type/index/{id:int}")]
5155
[ProducesResponseType(typeof(List<ContentTypeDto>), StatusCodes.Status200OK)]
52-
public IActionResult GetContentTypes(int? id)
56+
public IActionResult GetContentTypesByIndexId(int id) => Ok(GetContentTypes(id));
57+
58+
private List<ContentTypeDto> GetContentTypes(int? id)
5359
{
5460
IndexConfiguration indexConfiguration = new IndexConfiguration();
5561
var list = new List<ContentTypeDto>();
@@ -98,15 +104,14 @@ public IActionResult GetContentTypes(int? id)
98104
Icon = contentType.Icon,
99105
Alias = contentType.Alias,
100106
Name = contentType.Name,
101-
Selected = indexConfiguration != null
102-
&& indexConfiguration.ContentData != null
107+
Selected = indexConfiguration != null
108+
&& indexConfiguration.ContentData != null
103109
&& indexConfiguration.ContentData.Any(p => p.Alias == contentType.Alias),
104110
Properties = properties.AsEnumerable()
105111
});
106112
}
107113

108-
return Ok(list);
114+
return list;
109115
}
110-
111116
}
112117
}

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/GetIndexByIdController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Algolia.Search.Models.Search;
22
using Asp.Versioning;
3+
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Logging;
56
using System.Text.Json;
@@ -15,6 +16,7 @@
1516
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1617
{
1718
[ApiVersion("1.0")]
19+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
1820
public class GetIndexByIdController : SearchControllerBase
1921
{
2022
public GetIndexByIdController(
@@ -42,6 +44,7 @@ public GetIndexByIdController(
4244
}
4345

4446
[HttpGet("index/{id:int}")]
47+
[ProducesResponseType(typeof(IndexConfiguration), StatusCodes.Status200OK)]
4548
public IActionResult GetIndexById(int id)
4649
{
4750
var index = IndexStorage.GetById(id);

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/GetIndicesController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1818
{
1919
[ApiVersion("1.0")]
20+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
2021
public class GetIndicesController : SearchControllerBase
2122
{
2223
public GetIndicesController(

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/SaveIndexController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Algolia.Search.Models.Search;
22
using Asp.Versioning;
3+
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Logging;
56
using System.Text.Json;
@@ -14,6 +15,7 @@
1415
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1516
{
1617
[ApiVersion("1.0")]
18+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
1719
public class SaveIndexController : SearchControllerBase
1820
{
1921
public SaveIndexController(
@@ -41,6 +43,7 @@ public SaveIndexController(
4143
}
4244

4345
[HttpPost("index")]
46+
[ProducesResponseType(typeof(Result), StatusCodes.Status200OK)]
4447
public async Task<IActionResult> SaveIndex([FromBody] IndexConfiguration index)
4548
{
4649
IndexStorage.AddOrUpdate(new AlgoliaIndex

src/Umbraco.Cms.Integrations.Search.Algolia/Api/Management/Controllers/SearchIndexController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Algolia.Search.Models.Search;
22
using Asp.Versioning;
3+
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.Extensions.Logging;
56
using Umbraco.Cms.Core.Routing;
@@ -13,6 +14,7 @@
1314
namespace Umbraco.Cms.Integrations.Search.Algolia.Api.Management.Controllers
1415
{
1516
[ApiVersion("1.0")]
17+
[ApiExplorerSettings(GroupName = Constants.ManagementApi.GroupName)]
1618
public class SearchIndexController : SearchControllerBase
1719
{
1820
public SearchIndexController(
@@ -39,6 +41,7 @@ public SearchIndexController(
3941
}
4042

4143
[HttpGet("index/{indexId:int}/search")]
44+
[ProducesResponseType(typeof(Response), StatusCodes.Status200OK)]
4245
public IActionResult Search(int indexId, string query)
4346
{
4447
var index = IndexStorage.GetById(indexId);

src/Umbraco.Cms.Integrations.Search.Algolia/Client/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
"build": "tsc && vite build",
1313
"preview": "vite preview",
1414
"watch": "vite build --watch",
15-
"generate:api": "openapi-ts --input https://localhost:44340/umbraco/swagger/AlgoliaSearch/swagger.json --output Client/src/api --debug true --enums typescript --lint true --schemas false"
16-
},
17-
"dependencies": {
18-
"lit": "^3.1.2"
15+
"generate:api": "openapi-ts --input http://localhost:6583/umbraco/swagger/AlgoliaSearch/swagger.json --output src/api --debug true --enums typescript --lint true --schemas false"
1916
},
2017
"devDependencies": {
2118
"@hey-api/openapi-ts": "^0.37.3",

src/Umbraco.Cms.Integrations.Search.Algolia/Client/src/api/core/ApiError.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ import type { ApiRequestOptions } from './ApiRequestOptions';
22
import type { ApiResult } from './ApiResult';
33

44
export class ApiError extends Error {
5-
public readonly url: string;
6-
public readonly status: number;
7-
public readonly statusText: string;
8-
public readonly body: unknown;
9-
public readonly request: ApiRequestOptions;
5+
public readonly url: string;
6+
public readonly status: number;
7+
public readonly statusText: string;
8+
public readonly body: unknown;
9+
public readonly request: ApiRequestOptions;
1010

11-
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
12-
super(message);
11+
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
12+
super(message);
1313

14-
this.name = 'ApiError';
15-
this.url = response.url;
16-
this.status = response.status;
17-
this.statusText = response.statusText;
18-
this.body = response.body;
19-
this.request = request;
20-
}
21-
}
14+
this.name = 'ApiError';
15+
this.url = response.url;
16+
this.status = response.status;
17+
this.statusText = response.statusText;
18+
this.body = response.body;
19+
this.request = request;
20+
}
21+
}

0 commit comments

Comments
 (0)