-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V14: Reintroduce umbraco api controller as obsolete (#16263)
* Revert "v14: Remove mentions of UmbracoApiController (#15863)" This reverts commit 30e2dea. * Obsolete UmbracoApiController * Added a few more obsoletion messages * Removed some of the reintroduced stuff again * Add obsoletion to FrontEndRoutes controller --------- Co-authored-by: kjac <kja@umbraco.dk>
- Loading branch information
Showing
17 changed files
with
581 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Umbraco.Cms.Core.Composing; | ||
|
||
namespace Umbraco.Cms.Core; | ||
|
||
[Obsolete("This will be removed in Umbraco 15.")] | ||
public class UmbracoApiControllerTypeCollection : BuilderCollectionBase<Type> | ||
{ | ||
public UmbracoApiControllerTypeCollection(Func<IEnumerable<Type>> items) | ||
: base(items) | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Umbraco.Web.Common/Attributes/UmbracoApiControllerAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Umbraco.Cms.Web.Common.ApplicationModels; | ||
|
||
namespace Umbraco.Cms.Web.Common.Attributes; | ||
|
||
|
||
[AttributeUsage(AttributeTargets.Class)] | ||
[Obsolete("No-op attribute. Will be removed in Umbraco 15.")] | ||
public sealed class UmbracoApiControllerAttribute : Attribute | ||
{ | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Umbraco.Web.Common/Controllers/UmbracoApiController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Umbraco.Cms.Core.Composing; | ||
|
||
namespace Umbraco.Cms.Web.Common.Controllers; | ||
|
||
/// <summary> | ||
/// Provides a base class for auto-routed Umbraco API controllers. | ||
/// </summary> | ||
[Obsolete(""" | ||
WARNING | ||
The UmbracoAPIController does not work exactly as in previous versions of Umbraco because serialization is now done using System.Text.Json. | ||
Please verify your API responses still work as expect. | ||
We recommend using regular ASP.NET Core ApiControllers for your APIs so that OpenAPI specifications are generated. | ||
Read more about this here: https://learn.microsoft.com/en-us/aspnet/core/web-api/ | ||
UmbracoAPIController will be removed in Umbraco 15. | ||
""")] | ||
public abstract class UmbracoApiController : UmbracoApiControllerBase, IDiscoverable | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UmbracoApiController" /> class. | ||
/// </summary> | ||
protected UmbracoApiController() | ||
{ | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Umbraco.Web.Common/Controllers/UmbracoApiControllerBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Umbraco.Cms.Core.Features; | ||
using Umbraco.Cms.Web.Common.Attributes; | ||
using Umbraco.Cms.Web.Common.Authorization; | ||
|
||
namespace Umbraco.Cms.Web.Common.Controllers; | ||
|
||
/// <summary> | ||
/// Provides a base class for Umbraco API controllers. | ||
/// </summary> | ||
/// <remarks> | ||
/// <para>These controllers are NOT auto-routed.</para> | ||
/// <para>The base class is <see cref="ControllerBase" /> which are netcore API controllers without any view support</para> | ||
/// </remarks> | ||
[Authorize(Policy = AuthorizationPolicies.UmbracoFeatureEnabled)] | ||
[UmbracoApiController] | ||
[Obsolete("This will be removed in Umbraco 15.")] | ||
public abstract class UmbracoApiControllerBase : ControllerBase, IUmbracoFeature | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="UmbracoApiControllerBase" /> class. | ||
/// </summary> | ||
protected UmbracoApiControllerBase() | ||
{ | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Umbraco.Web.Common/Controllers/UmbracoApiControllerTypeCollectionBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Cms.Core.Composing; | ||
|
||
namespace Umbraco.Cms.Web.Common.Controllers; | ||
|
||
[Obsolete("This will be removed in Umbraco 15.")] | ||
public class UmbracoApiControllerTypeCollectionBuilder : TypeCollectionBuilderBase< | ||
UmbracoApiControllerTypeCollectionBuilder, UmbracoApiControllerTypeCollection, UmbracoApiController> | ||
{ | ||
protected override UmbracoApiControllerTypeCollectionBuilder This => this; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Umbraco.Cms.Core.Composing; | ||
using Umbraco.Cms.Web.Common.Controllers; | ||
|
||
namespace Umbraco.Extensions; | ||
|
||
public static class TypeLoaderExtensions | ||
{ | ||
/// <summary> | ||
/// Gets all types implementing <see cref="UmbracoApiController" />. | ||
/// </summary> | ||
public static IEnumerable<Type> GetUmbracoApiControllers(this TypeLoader typeLoader) | ||
=> typeLoader.GetTypes<UmbracoApiController>(); | ||
} |
Oops, something went wrong.