CrestApps Recipes
Generate accurate Orchard Core recipe schemas
You are an Orchard Core expert. The CrestApps Recipes module publishes JSON Schema for Orchard Core and CrestApps recipe steps, one schema per step, composed into a single recipe schema with a steps array. It does not replace Orchard Core's recipe handlers; it describes the payloads they accept so that recipes generated by people or AI agents can be validated before they run.
Guidelines
- Install
CrestApps.OrchardCore.Recipesin the web or startup project and enable theCrestApps.OrchardCore.Recipesfeature. It depends onOrchardCore.Recipes.Core. - Wrap every recipe JSON example in the root
{ "steps": [ ... ] }format. - A schema is not a handler. A step still executes only when its owning feature registers the Orchard Core recipe handler.
- Schemas are feature gated. Each step, part, field or contribution is registered from a
[RequireFeatures(...)]startup, so the composed schema lists only what the tenant can import. - Register a custom
IRecipeStepas a scoped service. A step schema must declare anameproperty with aconstvalue; that const keys the step's branch in the composed schema. - Extend a composed step (
Layers,Sitemaps,deployment,AdminMenu,Queries,UrlRewriting,Placements,WorkflowType) with a per-type contribution and itsAdd...Schema<T>()extension. Do not replace the step. - Surface dynamic values (content types, roles, cultures, index profiles) as non-restrictive
examples, never asenum, so custom values stay valid. - Keep contributions open (additional properties allowed) unless the type can never receive an extra member.
- Sealed classes and file-scoped namespaces in C# samples. View models may stay unsealed.
Feature overview
| Feature ID | Purpose |
|---|---|
| CrestApps.OrchardCore.Recipes | JSON Schema services, feature-gated step schemas, schema-aware JSON import editor |
| OrchardCore.Recipes.Core | Orchard Core recipe infrastructure (dependency) |
{
"steps": [
{
"name": "Feature",
"enable": [
"CrestApps.OrchardCore.Recipes"
],
"disable": []
}
]
}
What the module provides
- Always registered:
settings,custom-settings,commandandrecipesstep schemas (step names match case insensitively),RecipeSchemaService,RecipeExecutionService,IRecipeSchemaExampleServiceandIContentItemSchemaService. - Feature gated Orchard Core steps such as
Feature,Themes,ContentDefinition,ReplaceContentDefinition,DeleteContentDefinition,Content,Users,Roles, media, templates, Lucene, Elasticsearch, Azure AI Search, index profiles, OpenID and external login settings, translations and feature profiles. - Composed polymorphic steps (
Layers,Sitemaps,deployment,AdminMenu,Queries,UrlRewriting,Placements,WorkflowType). - Content part and field schemas for Orchard Core parts and fields, plus contributions registered by CrestApps modules themselves when Recipes is enabled (for example
PhoneField,AddressField,RolePickerPart,UserFullNamePart,AIProfilePart,OmnichannelContactPart,ProductPart,SubscriptionPart,TaxationPart, and theRolePickerPartContentAccessControlSettingsenvelope). - About 80
Settingsstep contributions (ISiteSettingsSchemaDefinition) for Orchard Core and CrestApps site settings, such asDisplayNameSettingsandUserAvatarOptions. - CrestApps step schemas, each gated on its feature:
AIProfile,CreateAIProfileFromTemplate,AIProfileTemplate,AIDeployment,DeleteAIDeployments,AIProviderConnections,AIDataSource,AIToolInstances,McpConnection,McpPrompt,McpResource,A2AConnection,AIPersonas,TimeZoneMaps,IndexUsers,Currencies,StripeSettings, and the Contact Center, Omnichannel, Telephony, Telnyx and Asterisk configuration steps. See references/crestapps-step-schemas.md. - Most other CrestApps modules register the schemas of their own steps next to their recipe handlers, gated on their feature and on
CrestApps.OrchardCore.Recipes(for example Business Hours, Tickets, Knowledge Base, Service Levels, Timeline, Invoicing, Payroll, Banking, Approvals, Learning, Staff, Reports, Webhooks and Tenant Hierarchy), so they appear in the composed schema only when both are on. - Recent schema changes:
ContactCenterBusinessHoursCalendaris kept only for older recipes (each calendar is imported as a Business Hours schedule with the same id; new recipes useBusinessHoursSchedules);OmnichannelLeadStatusgainedIsContacted;OmnichannelMessageTemplategainedScopeandFillsPlaceholders; theAIChatAdminWidgetSettingssection gainedSendPageContext; theAICostSettingssection is gone (the carrier price isTelephonyCostSettings, set through theSettingsstep with no schema).
Schema-aware JSON import
With the feature enabled, the Orchard Core Deployment > JSON Import screen is replaced (through a view location expander) by a Monaco editor fed with RecipeSchemaService.GetRecipeSchemaAsync(), so administrators get autocomplete and validation for every registered step.
Retrieve schemas in application code
RecipeSchemaService (namespace CrestApps.OrchardCore.Recipes.Core.Services) is scoped.
| Member | Returns |
|---|---|
| GetRecipeSchemaAsync(cancellationToken) | The full recipe schema with every registered step |
| GetRecipeSchemaAsync(requestedStep, cancellationToken) | The recipe schema narrowed to one step, or null when no registered step has that name |
| GetStepSchemaAsync(stepName, cancellationToken) | The schema of one step, or null |
| GetStepNames() | Names of the steps with a registered IRecipeStep |
using CrestApps.OrchardCore.Recipes.Core.Services;
using Json.Schema;
namespace MyModule;
public sealed class RecipeSchemaLookup
{
private readonly RecipeSchemaService _recipeSchemaService;
public RecipeSchemaLookup(RecipeSchemaService recipeSchemaService)
{
_recipeSchemaService = recipeSchemaService;
}
public ValueTask<JsonSchema> GetContentDefinitionRecipeSchemaAsync(CancellationToken cancellationToken)
=> _recipeSchemaService.GetRecipeSchemaAsync("ContentDefinition", cancellationToken);
}
How the composed schema behaves:
- Step names are matched case insensitively and offered as
examplesonsteps[].name, so an unknown step name still validates as an open object. - A step whose
GetSchemaAsyncreturnsnullgets a permissive fallback (nameconst, additional properties allowed). - Orchard Core does not expose handler names, so a handler without a registered
IRecipeStepis not listed. - Nothing is cached across calls by the service. Recompute after features change.
Define a custom recipe step schema
Implement IRecipeStep (namespace CrestApps.OrchardCore.Recipes.Core), or derive from RecipeStepSchemaBase (namespace ...Schemas.Steps), which caches the result of CreateSchema().
using CrestApps.OrchardCore.Recipes.Core.Schemas.Steps;
using Json.Schema;
namespace MyModule.Recipes;
public sealed class ProductSettingsRecipeStep : RecipeStepSchemaBase
{
public override string Name => "ProductSettings";
protected override JsonSchema CreateSchema()
=> new JsonSchemaBuilder()
.Type(SchemaValueType.Object)
.Properties(
("name", new JsonSchemaBuilder()
.Type(SchemaValueType.String)
.Const("ProductSettings")),
("AllowBackorders", new JsonSchemaBuilder()
.Type(SchemaValueType.Boolean)
.Description("Whether out-of-stock products can still be ordered.")))
.Required("name")
.AdditionalProperties(false)
.Build();
}
using CrestApps.OrchardCore.Recipes.Core;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
namespace MyModule;
[RequireFeatures("CrestApps.OrchardCore.Recipes")]
public sealed class RecipesSchemaStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IRecipeStep, ProductSettingsRecipeStep>();
}
}
Put the registration in a startup gated on both your feature and CrestApps.OrchardCore.Recipes so your module does not require the Recipes feature at runtime. Pair the schema with an Orchard Core recipe handler (see the framework orchardcore-recipes skill) when the step is executable.
Describe a site settings section for the Settings step
The Settings step composes one property per registered ISiteSettingsSchemaDefinition. Derive from SiteSettingsSchemaBase (namespace ...Schemas.SiteSettings); Name is the property name under the step, normally the settings class name.
using CrestApps.OrchardCore.Recipes.Core.Schemas.SiteSettings;
using Json.Schema;
namespace MyModule.Recipes;
public sealed class ProductSettingsSchema : SiteSettingsSchemaBase
{
public override string Name => "ProductSettings";
protected override JsonSchemaBuilder BuildSchemaCore()
=> new JsonSchemaBuilder()
.Type(SchemaValueType.Object)
.Properties(
("AllowBackorders", new JsonSchemaBuilder().Type(SchemaValueType.Boolean)))
.AdditionalProperties(false);
}
Register it with services.AddScoped<ISiteSettingsSchemaDefinition, ProductSettingsSchema>(); behind the feature whose SiteDisplayDriver<TSettings> owns the settings.
Condition rules
A step or settings property that holds a "match all/any of these conditions" rule (CrestApps.OrchardCore.Conditions) describes it with ConditionRuleSchema.Build(description, sourceDescription) (namespace CrestApps.OrchardCore.Recipes.Core.Schemas). The schema is an object (or null) with Match (ConditionMatch: All or Any) and Conditions, each with Source, Operator (ConditionOperator names) and string Values in the invariant culture. Conditional fields (ShowWhen) and work order rules use it.
("ShowWhen", ConditionRuleSchema.Build(
"When the field is shown. Empty shows it always.",
"The technical name of the field whose value is tested."))
Extend content definition and content item schemas
IContentSchemaDefinition contributes the Settings envelope of a part or field to ContentDefinition and ReplaceContentDefinition. PartSchemaDefinitionBase and FieldSchemaDefinitionBase also contribute the payload used by the Content step. Contributions are grouped by Name, so several contributors to the same part or field merge instead of replacing each other.
using CrestApps.OrchardCore.Recipes.Core.Schemas.Fields;
using Json.Schema;
namespace MyModule.Schemas;
public sealed class RatingFieldSchemaDefinition : FieldSchemaDefinitionBase
{
public override string Name => "RatingField";
protected override JsonSchemaBuilder BuildSettingsCore()
=> new JsonSchemaBuilder()
.Type(SchemaValueType.Object)
.Properties(
("RatingFieldSettings", new JsonSchemaBuilder()
.Type(SchemaValueType.Object)
.Properties(
("Maximum", new JsonSchemaBuilder().Type(SchemaValueType.Integer)))
.AdditionalProperties(false)))
.AdditionalProperties(true);
protected override JsonSchemaBuilder BuildFieldSchemaCore()
=> new JsonSchemaBuilder()
.Type(SchemaValueType.Object)
.Properties(
("Value", new JsonSchemaBuilder().Type(SchemaValueType.Integer)))
.AdditionalProperties(true);
}
services.AddScoped<IContentSchemaDefinition, RatingFieldSchemaDefinition>();
Read references/content-schemas.md for part schemas, the two settings surfaces (ContentParts[].Settings and ContentTypePartDefinitionRecords[].Settings), container parts (IContainedContentPartSchemaDefinition), and complete ContentDefinition and Content examples.
Extend composed recipe step schemas
Each polymorphic step composes its schema from one contribution per condition, source, step, node, filter or activity. The base class adds the shared members; you describe only the type's own members. Register the contribution behind the feature that owns the type.
| Step | Base class | Registration | Keyed by | Recipes gate |
|---|---|---|---|---|
| Layers conditions | RuleConditionSchemaDefinitionBase, OperandConditionSchemaDefinitionBase, ConditionGroupSchemaDefinitionBase | AddRuleConditionSchema<T>() | Name + $type | OrchardCore.Layers |
| Layers operators | RuleConditionOperatorSchemaDefinitionBase, StringOperatorSchemaDefinitionBase | AddRuleConditionOperatorSchema<T>() | $type | OrchardCore.Layers |
| Sitemaps | SitemapSourceSchemaDefinitionBase | AddSitemapSourceSchema<T>() | $type | OrchardCore.Sitemaps |
| deployment | DeploymentStepSchemaDefinitionBase | AddDeploymentStepSchema<T>() | StepType (the Type value) | OrchardCore.Deployment |
| AdminMenu | AdminNodeSchemaDefinitionBase | AddAdminNodeSchema<T>() | $type | OrchardCore.AdminMenu |
| Queries | QuerySourceSchemaDefinitionBase | AddQuerySourceSchema<T>() | Name (the Source value) | OrchardCore.Queries |
| UrlRewriting | RewriteRuleSourceSchemaDefinitionBase | AddRewriteRuleSourceSchema<T>() | Name (the Source value) | OrchardCore.UrlRewriting |
| Placements | PlacementNodeFilterSchemaDefinitionBase | AddPlacementNodeFilterSchema<T>() | Key | OrchardCore.Placements |
| WorkflowType | WorkflowActivitySchemaDefinitionBase | AddWorkflowActivitySchema<T>() | activity Name | OrchardCore.Workflows |
Base classes live in CrestApps.OrchardCore.Recipes.Core.Schemas.<Family> (Rules, Rules.Conditions, Rules.Operators, Sitemaps, Deployment, AdminMenu, Queries, UrlRewriting, Placements, Workflows). The Add...Schema<T>() extensions live in Microsoft.Extensions.DependencyInjection. When two definitions share a name, the last registered wins, which lets you override a built-in description.
Example, a deployment step contribution:
using CrestApps.OrchardCore.Recipes.Core.Schemas.Deployment;
using Json.Schema;
namespace MyModule.Schemas;
public sealed class ProductCatalogDeploymentStepSchema : DeploymentStepSchemaDefinitionBase
{
public override string StepType => "ProductCatalogDeploymentStep";
protected override string DisplayText => "Product catalog";
protected override string Description => "Exports the product catalog.";
protected override IEnumerable<(string Name, JsonSchemaBuilder Schema)> GetPropertyDefinitions(DeploymentStepSchemaContext context)
{
yield return ("IncludeArchived", DeploymentSchemaBuilders.Boolean("When true, archived products are included."));
yield return ("ContentTypes", DeploymentSchemaBuilders.StringArray("Content types to export.", context.Examples.ContentTypeNames));
}
}
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
namespace MyModule;
[RequireFeatures("CrestApps.OrchardCore.Recipes", "OrchardCore.Deployment")]
public sealed class DeploymentSchemaStartup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddDeploymentStepSchema<ProductCatalogDeploymentStepSchema>();
}
}
Read these references for the full contract, built-in coverage and examples of each family:
- references/composed-step-schemas.md for rule conditions and operators, sitemap sources, deployment steps, admin menu nodes, query sources, URL rewrite rules and placement node filters.
- references/workflow-activity-schemas.md for workflow events and tasks, expression properties, outcomes and conditional requirements.
Surface live tenant example values
IRecipeSchemaExampleService.GetExamplesAsync() returns a RecipeSchemaExamples snapshot with ContentTypeNames, ContentPartNames, CultureNames, RoleNames and IndexProfileNames. Family definitions receive it as context.Examples (admin menu, deployment, query, rule, sitemap and workflow contexts).
- On an operand condition, override
GetValueExamples(RecipeSchemaExamples examples). - Use builder overloads that take examples, such as
DeploymentSchemaBuilders.StringArray(description, itemExamples),WorkflowActivitySchemaBuilders.String(description, examples)andWorkflowActivitySchemaBuilders.StringArray(description, itemExamples). - Otherwise call JsonSchema.Net's
.Examples(...)yourself. The internalWithSuggestionshelper is not public.
Never turn an example list into an enum. Examples are non-restrictive, so a recipe that references a type, role, culture or index added later still validates.
Execute a generated recipe
RecipeExecutionService.ExecuteRecipeAsync(JsonNode data) writes the JSON to a temporary Recipe.json under the tenant temp directory and imports it through every registered IDeploymentTargetHandler in sequence. It returns false and logs the exception when anything fails.
using System.Text.Json.Nodes;
using CrestApps.OrchardCore.Recipes.Core.Services;
namespace MyModule;
public sealed class GeneratedRecipeExecutor
{
private readonly RecipeExecutionService _recipeExecutionService;
public GeneratedRecipeExecutor(RecipeExecutionService recipeExecutionService)
{
_recipeExecutionService = recipeExecutionService;
}
public Task<bool> ExecuteAsync(JsonObject recipe)
=> _recipeExecutionService.ExecuteRecipeAsync(recipe);
}
Validate generated JSON against RecipeSchemaService first, authorize the caller for every operation the recipe performs, and never run untrusted Command or deployment payloads without review.
Upgrading from 2.x
RecipeSchemaServiceno longer reflects overNamedRecipeStepHandlerregistrations and no longer caches step names inIMemoryCachefor an hour. Step names now come only from registeredIRecipeStepservices, so register anIRecipeStepfor every custom step you want listed.
Troubleshooting
- A specialized schema is missing: the owning feature (or CrestApps Recipes) is disabled for the tenant.
- A custom step does not show its properties: its schema has no
nameproperty with aconst, so it is not keyed into the composed union. - Custom part or field settings are absent from
ContentDefinition: theIContentSchemaDefinitionwas not registered while Recipes is enabled. - Do not add a part contributor only to restate its fields; the
Contentschema composes attached fields through their own definitions. - A composed contribution is missing: confirm the matching
Add...Schema<T>()call sits behind the right[RequireFeatures(...)]gate. - Match a deployment step on
StepType, a query or rewrite rule on itsSourcevalue, and a placement filter on itsKey. - Tenant examples are missing from an exported schema: the export host did not register the source service (
IContentDefinitionManager,ILocalizationService,IRoleServiceorIIndexProfileStore). Missing examples never fail validation.