Umbraco schema and operation IDs
How to apply the Umbraco schema and operation IDs for custom Management APIs
All core Management APIs have a custom scheme for their generated OpenAPI schema and operation IDs.
This scheme is strictly opt-in to avoid affecting custom APIs by default. In this article, we'll see how to opt-in to the scheme.
Schema IDs
Schema IDs are handled by ISchemaIdHandler implementations. To opt-in to the Umbraco schema IDs, we base our implementation on the core handler:
using Umbraco.Cms.Api.Common.OpenApi;
namespace UmbracoDocs.Samples;
// this schema ID handler extends the Umbraco schema IDs
// to all types in the UmbracoDocs.Samples namespace
public class SampleSchemaIdHandler : SchemaIdHandler
{
public override bool CanHandle(Type type)
=> type.Namespace == "UmbracoDocs.Samples";
}Then, we implement a composer to register the new schema ID handler:
using Umbraco.Cms.Api.Common.OpenApi;
using Umbraco.Cms.Core.Composing;
namespace UmbracoDocs.Samples;
public class SampleSchemaIdComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
=> builder.Services.AddSingleton<ISchemaIdHandler, SampleSchemaIdHandler>();
}Operation IDs
Operation IDs follow the same pattern as schema IDs. The only difference is that the IOperationIdHandler operates at the API level, not at the type level.
Again, to opt-in to the Umbraco operation IDs, we base our implementation on the core handler:
Then, we implement a composer to register the new operation ID handler:
Last updated
Was this helpful?