Remove template scaffolding from the API (#15659)

* Remove template scaffolding from the API

* Regenerate OpenApi.json

* Regenerate OpenApi.json after forward merging
This commit is contained in:
Kenn Jacobsen
2024-02-07 09:07:54 +01:00
committed by GitHub
parent 79866e0370
commit 9d07268ead
5 changed files with 0 additions and 153 deletions

View File

@@ -1,31 +0,0 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Api.Management.ViewModels.Template;
using Umbraco.Cms.Core.IO;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Services;
namespace Umbraco.Cms.Api.Management.Controllers.Template;
[ApiVersion("1.0")]
public class ScaffoldTemplateController : TemplateControllerBase
{
private readonly ITemplateService _templateService;
public ScaffoldTemplateController(ITemplateService templateService) => _templateService = templateService;
[HttpGet("scaffold")]
[MapToApiVersion("1.0")]
[ProducesResponseType(typeof(TemplateScaffoldResponseModel), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<ActionResult<TemplateScaffoldResponseModel>> Scaffold([FromQuery(Name = "masterTemplateId")] Guid? masterTemplateId)
{
var scaffoldViewModel = new TemplateScaffoldResponseModel
{
Content = await _templateService.GetScaffoldAsync(masterTemplateId),
};
return await Task.FromResult(Ok(scaffoldViewModel));
}
}

View File

@@ -19798,86 +19798,6 @@
]
}
},
"/umbraco/management/api/v1/template/scaffold": {
"get": {
"tags": [
"Template"
],
"operationId": "GetTemplateScaffold",
"parameters": [
{
"name": "masterTemplateId",
"in": "query",
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/TemplateScaffoldResponseModel"
}
]
}
},
"text/json": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/TemplateScaffoldResponseModel"
}
]
}
},
"text/plain": {
"schema": {
"oneOf": [
{
"$ref": "#/components/schemas/TemplateScaffoldResponseModel"
}
]
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"text/plain": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"401": {
"description": "The resource is protected and requires an authentication token"
}
},
"security": [
{
"Backoffice User": [ ]
}
]
}
},
"/umbraco/management/api/v1/tree/template/children": {
"get": {
"tags": [
@@ -31033,19 +30953,6 @@
},
"additionalProperties": false
},
"TemplateScaffoldResponseModel": {
"required": [
"content"
],
"type": "object",
"properties": {
"content": {
"minLength": 1,
"type": "string"
}
},
"additionalProperties": false
},
"TemporaryFileResponseModel": {
"required": [
"fileName",

View File

@@ -1,9 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Umbraco.Cms.Api.Management.ViewModels.Template;
public class TemplateScaffoldResponseModel
{
[Required]
public string Content { get; set; } = string.Empty;
}

View File

@@ -44,13 +44,6 @@ public interface ITemplateService : IService
/// <returns>The <see cref="ITemplate" /> object matching the identifier, or null.</returns>
Task<ITemplate?> GetAsync(Guid id);
/// <summary>
/// Gets the scaffold code for a template.
/// </summary>
/// <param name="masterTemplateKey"></param>
/// <returns></returns>
Task<string> GetScaffoldAsync(Guid? masterTemplateKey);
/// <summary>
/// Gets the template descendants
/// </summary>

View File

@@ -182,19 +182,6 @@ public class TemplateService : RepositoryService, ITemplateService
}
}
/// <inheritdoc />
public async Task<string> GetScaffoldAsync(Guid? masterTemplateKey)
{
string? masterAlias = null;
if (masterTemplateKey is not null)
{
ITemplate? masterTemplate = await GetAsync(masterTemplateKey.Value);
masterAlias = masterTemplate?.Alias;
}
return _defaultViewContentProvider.GetDefaultFileContent(masterAlias);
}
/// <inheritdoc />
public async Task<IEnumerable<ITemplate>> GetDescendantsAsync(int masterTemplateId)
{