Skip to content
Draft
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
13 changes: 12 additions & 1 deletion src/Cli.Tests/EndToEndTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,11 @@ public void TestBaseRouteIsConfigurableForSWA(string authProvider, bool isExcept
[DataRow(ApiType.GraphQL, true, false, true, false, DisplayName = "Validate that GraphQL endpoint is disabled when enabled option is omitted and disabled option is included in the init command.")]
[DataRow(ApiType.GraphQL, true, true, false, false, DisplayName = "Validate that GraphQL endpoint is disabled when enabled option is set to false and disabled option is included in the init command.")]
[DataRow(ApiType.GraphQL, true, true, true, true, true, DisplayName = "Validate that config generation fails when enabled and disabled options provide conflicting values for GraphQL endpoint.")]
[DataRow(ApiType.MCP, false, false, true, true, DisplayName = "Validate that MCP endpoint is enabled when both enabled and disabled options are omitted from the init command.")]
[DataRow(ApiType.MCP, false, true, true, true, DisplayName = "Validate that MCP endpoint is enabled when enabled option is set to true and disabled option is omitted from the init command.")]
[DataRow(ApiType.MCP, true, false, true, false, DisplayName = "Validate that MCP endpoint is disabled when enabled option is omitted and disabled option is included in the init command.")]
[DataRow(ApiType.MCP, true, true, false, false, DisplayName = "Validate that MCP endpoint is disabled when enabled option is set to false and disabled option is included in the init command.")]
[DataRow(ApiType.MCP, true, true, true, true, true, DisplayName = "Validate that config generation fails when enabled and disabled options provide conflicting values for MCP endpoint.")]
public void TestEnabledDisabledFlagsForApis(
ApiType apiType,
bool includeDisabledFlag,
Expand Down Expand Up @@ -1278,12 +1283,18 @@ public void TestEnabledDisabledFlagsForApis(
Assert.IsNotNull(runtimeConfig.Runtime.Rest);
Assert.AreEqual(expectedEnabledFlagValueInConfig, runtimeConfig.Runtime.Rest.Enabled);
}
else
else if (apiType is ApiType.GraphQL)
{
Assert.IsNotNull(runtimeConfig.Runtime);
Assert.IsNotNull(runtimeConfig.Runtime.GraphQL);
Assert.AreEqual(expectedEnabledFlagValueInConfig, runtimeConfig.Runtime.GraphQL.Enabled);
}
else
{
Assert.IsNotNull(runtimeConfig.Runtime);
Assert.IsNotNull(runtimeConfig.Runtime.Mcp);
Assert.AreEqual(expectedEnabledFlagValueInConfig, runtimeConfig.Runtime.Mcp.Enabled);
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Cli/Commands/InitOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ public InitOptions(
[Option("runtime.base-route", Default = null, Required = false, HelpText = "Specifies the base route for API requests.")]
public string? RuntimeBaseRoute { get; }

[Option("rest.disabled", Default = false, Required = false, HelpText = "Disables REST endpoint for all entities.")]
[Option("rest.disabled", Default = false, Required = false, Hidden = true, HelpText = "[Deprecated] Use --rest.enabled false instead. Disables REST endpoint for all entities.")]
public bool RestDisabled { get; }

[Option("graphql.path", Default = GraphQLRuntimeOptions.DEFAULT_PATH, Required = false, HelpText = "Specify the GraphQL endpoint's default prefix.")]
public string GraphQLPath { get; }

[Option("graphql.disabled", Default = false, Required = false, HelpText = "Disables GraphQL endpoint for all entities.")]
[Option("graphql.disabled", Default = false, Required = false, Hidden = true, HelpText = "[Deprecated] Use --graphql.enabled false instead. Disables GraphQL endpoint for all entities.")]
public bool GraphQLDisabled { get; }

[Option("mcp.path", Default = McpRuntimeOptions.DEFAULT_PATH, Required = false, HelpText = "Specify the MCP endpoint's default prefix.")]
public string McpPath { get; }

[Option("mcp.disabled", Default = false, Required = false, HelpText = "Disables MCP endpoint for all entities.")]
[Option("mcp.disabled", Default = false, Required = false, Hidden = true, HelpText = "[Deprecated] Use --mcp.enabled false instead. Disables MCP endpoint for all entities.")]
public bool McpDisabled { get; }

[Option("rest.enabled", Required = false, HelpText = "(Default: true) Enables REST endpoint for all entities. Supported values: true, false.")]
Expand Down
30 changes: 13 additions & 17 deletions src/Cli/ConfigGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,28 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
// If --rest.disabled flag is included in the init command, we log a warning to not use this flag as it will be deprecated in future versions of DAB.
if (options.RestDisabled is true)
{
_logger.LogWarning("The option --rest.disabled will be deprecated and support for the option will be removed in future versions of Data API builder." +
" We recommend that you use the --rest.enabled option instead.");
_logger.LogWarning("The option --rest.disabled is deprecated and support for the option will be removed in future versions of Data API builder." +
" Use the --rest.enabled option instead.");
}

// If --graphql.disabled flag is included in the init command, we log a warning to not use this flag as it will be deprecated in future versions of DAB.
if (options.GraphQLDisabled is true)
{
_logger.LogWarning("The option --graphql.disabled will be deprecated and support for the option will be removed in future versions of Data API builder." +
" We recommend that you use the --graphql.enabled option instead.");
_logger.LogWarning("The option --graphql.disabled is deprecated and support for the option will be removed in future versions of Data API builder." +
" Use the --graphql.enabled option instead.");
}

// If --mcp.disabled flag is included in the init command, we log a warning to not use this flag as it will be deprecated in future versions of DAB.
if (options.McpDisabled is true)
{
_logger.LogWarning("The option --mcp.disabled is deprecated and support for the option will be removed in future versions of Data API builder." +
" Use the --mcp.enabled option instead.");
}

bool restEnabled, graphQLEnabled, mcpEnabled;
if (!TryDetermineIfApiIsEnabled(options.RestDisabled, options.RestEnabled, ApiType.REST, out restEnabled) ||
!TryDetermineIfApiIsEnabled(options.GraphQLDisabled, options.GraphQLEnabled, ApiType.GraphQL, out graphQLEnabled) ||
!TryDetermineIfMcpIsEnabled(options.McpEnabled, out mcpEnabled))
!TryDetermineIfApiIsEnabled(options.McpDisabled, options.McpEnabled, ApiType.MCP, out mcpEnabled))
{
return false;
}
Expand Down Expand Up @@ -236,7 +243,7 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
}
}

if (options.RestDisabled && options.GraphQLDisabled)
if (!restEnabled && !graphQLEnabled)
{
_logger.LogError("Both Rest and GraphQL cannot be disabled together.");
return false;
Expand Down Expand Up @@ -333,17 +340,6 @@ private static bool TryDetermineIfApiIsEnabled(bool apiDisabledOptionValue, CliB
return true;
}

/// <summary>
/// Helper method to determine if the mcp api is enabled or not based on the enabled/disabled options in the dab init command.
/// </summary>
/// <param name="mcpEnabledOptionValue">True, if MCP is enabled</param>
/// <param name="isMcpEnabled">Out param isMcpEnabled</param>
/// <returns>True if MCP is enabled</returns>
private static bool TryDetermineIfMcpIsEnabled(CliBool mcpEnabledOptionValue, out bool isMcpEnabled)
{
return TryDetermineIfApiIsEnabled(false, mcpEnabledOptionValue, ApiType.MCP, out isMcpEnabled);
}

/// <summary>
/// Helper method to determine if the multiple create operation is enabled or not based on the inputs from dab init command.
/// </summary>
Expand Down
Loading