Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Cli.Tests/AutoConfigTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void TestConfigureAutoentitiesDefinition_WithTemplateOptions()
definitionName: "test-def",
templateRestEnabled: true,
templateGraphqlEnabled: false,
templateMcpDmlTool: "true",
templateMcpDmlTools: "true",
templateCacheEnabled: true,
templateCacheTtlSeconds: 30,
templateCacheLevel: "L1",
Expand Down Expand Up @@ -196,7 +196,7 @@ public void TestConfigureAutoentitiesDefinition_InvalidMcpDmlTool()

AutoConfigOptions options = new(
definitionName: "test-def",
templateMcpDmlTool: "invalid-value",
templateMcpDmlTools: "invalid-value",
permissions: new[] { "anonymous", "read" },
config: TEST_RUNTIME_CONFIG_FILE
);
Expand Down
8 changes: 4 additions & 4 deletions src/Cli/Commands/AutoConfigOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public AutoConfigOptions(
IEnumerable<string>? patternsInclude = null,
IEnumerable<string>? patternsExclude = null,
string? patternsName = null,
string? templateMcpDmlTool = null,
string? templateMcpDmlTools = null,
bool? templateRestEnabled = null,
bool? templateGraphqlEnabled = null,
bool? templateCacheEnabled = null,
Expand All @@ -39,7 +39,7 @@ public AutoConfigOptions(
PatternsInclude = patternsInclude;
PatternsExclude = patternsExclude;
PatternsName = patternsName;
TemplateMcpDmlTool = templateMcpDmlTool;
TemplateMcpDmlTools = templateMcpDmlTools;
TemplateRestEnabled = templateRestEnabled;
TemplateGraphqlEnabled = templateGraphqlEnabled;
TemplateCacheEnabled = templateCacheEnabled;
Expand All @@ -61,8 +61,8 @@ public AutoConfigOptions(
[Option("patterns.name", Required = false, HelpText = "Interpolation syntax for entity naming (must be unique for each generated entity). Default: '{object}'")]
public string? PatternsName { get; }

[Option("template.mcp.dml-tool", Required = false, HelpText = "Enable/disable DML tools for generated entities. Allowed values: true, false. Default: true")]
public string? TemplateMcpDmlTool { get; }
[Option("template.mcp.dml-tools", Required = false, HelpText = "Enable/disable DML tools for generated entities. Allowed values: true, false. Default: true")]
public string? TemplateMcpDmlTools { get; }

[Option("template.rest.enabled", Required = false, HelpText = "Enable/disable REST endpoint for generated entities. Allowed values: true, false. Default: true")]
public bool? TemplateRestEnabled { get; }
Expand Down
8 changes: 4 additions & 4 deletions src/Cli/ConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3109,11 +3109,11 @@ private static AutoentityPatterns BuildAutoentityPatterns(AutoConfigOptions opti
bool userProvidedCache = existingAutoentity?.Template.UserProvidedCacheOptions ?? false;

// Update MCP options
if (!string.IsNullOrWhiteSpace(options.TemplateMcpDmlTool))
if (!string.IsNullOrWhiteSpace(options.TemplateMcpDmlTools))
{
if (!bool.TryParse(options.TemplateMcpDmlTool, out bool mcpDmlToolValue))
if (!bool.TryParse(options.TemplateMcpDmlTools, out bool mcpDmlToolValue))
{
_logger.LogError("Invalid value for template.mcp.dml-tool: {value}. Valid values are: true, false", options.TemplateMcpDmlTool);
_logger.LogError("Invalid value for template.mcp.dml-tools: {value}. Valid values are: true, false", options.TemplateMcpDmlTools);
return null;
}

Expand All @@ -3122,7 +3122,7 @@ private static AutoentityPatterns BuildAutoentityPatterns(AutoConfigOptions opti
bool? dmlToolValue = mcpDmlToolValue;
mcp = new EntityMcpOptions(customToolEnabled: customToolEnabled, dmlToolsEnabled: dmlToolValue);
userProvidedMcp = true;
_logger.LogInformation("Updated template.mcp.dml-tool for definition '{DefinitionName}'", options.DefinitionName);
_logger.LogInformation("Updated template.mcp.dml-tools for definition '{DefinitionName}'", options.DefinitionName);
}

// Update REST options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ protected override async Task GenerateAutoentitiesIntoEntities(IReadOnlyDictiona
if (!entities.TryAdd(entityName, generatedEntity) || !runtimeConfig.TryAddGeneratedAutoentityNameToDataSourceName(entityName, autoentityName))
{
throw new DataApiBuilderException(
message: $"Entity with name '{entityName}' already exists. Cannot create new entity from autoentities definition '{autoentityName}'.",
message: $"Entity '{entityName}' conflicts with autoentity pattern '{autoentityName}'. Use --patterns.exclude to skip it.",
statusCode: HttpStatusCode.BadRequest,
subStatusCode: DataApiBuilderException.SubStatusCodes.ErrorInInitialization);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service.Tests/Configuration/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5611,7 +5611,7 @@ public async Task TestAutoentitiesAreGeneratedIntoEntities(bool useEntities, int
/// <returns></returns>
[TestCategory(TestCategory.MSSQL)]
[DataTestMethod]
[DataRow("publishers", "uniqueSingularPublisher", "uniquePluralPublishers", "/unique/publisher", "Entity with name 'publishers' already exists. Cannot create new entity from autoentities definition 'PublisherAutoEntity'.", DisplayName = "Autoentities fail due to entity name")]
[DataRow("publishers", "uniqueSingularPublisher", "uniquePluralPublishers", "/unique/publisher", "Entity 'publishers' conflicts with autoentity pattern 'PublisherAutoEntity'. Use --patterns.exclude to skip it.", DisplayName = "Autoentities fail due to entity name")]
[DataRow("UniquePublisher", "publishers", "uniquePluralPublishers", "/unique/publisher", "Entity publishers generates queries/mutation that already exist", DisplayName = "Autoentities fail due to graphql singular type")]
[DataRow("UniquePublisher", "uniqueSingularPublisher", "publishers", "/unique/publisher", "Entity publishers generates queries/mutation that already exist", DisplayName = "Autoentities fail due to graphql plural type")]
[DataRow("UniquePublisher", "uniqueSingularPublisher", "uniquePluralPublishers", "/publishers", "The rest path: publishers specified for entity: publishers is already used by another entity.", DisplayName = "Autoentities fail due to rest path")]
Expand Down