From 5de5260a4bc0b4d0b4061afb87f1adc5cbd958f7 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Sat, 2 Mar 2024 12:08:31 -0800 Subject: [PATCH 1/3] Condition openapi doc creations behind non-cosmosDB database types. --- src/Service/Startup.cs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Service/Startup.cs b/src/Service/Startup.cs index 5a83ce3e7b..e9b780223a 100644 --- a/src/Service/Startup.cs +++ b/src/Service/Startup.cs @@ -624,18 +624,23 @@ private async Task PerformOnConfigChangeAsync(IApplicationBuilder app) runtimeConfigValidator.ValidateRelationshipsInConfig(runtimeConfig, sqlMetadataProviderFactory!); } - // Attempt to create OpenAPI document. - // Errors must not crash nor halt the intialization of the engine - // because OpenAPI document creation is not required for the engine to operate. - // Errors will be logged. - try + // OpenAPI document creation is only attempted for REST supporting database types. + // CosmosDB is not supported for OpenAPI document creation. + if (!runtimeConfig.CosmosDataSourceUsed) { - IOpenApiDocumentor openApiDocumentor = app.ApplicationServices.GetRequiredService(); - openApiDocumentor.CreateDocument(); - } - catch (DataApiBuilderException dabException) - { - _logger.LogError(exception: dabException, message: "OpenAPI Documentor initialization failed."); + // Attempt to create OpenAPI document. + // Errors must not crash nor halt the intialization of the engine + // because OpenAPI document creation is not required for the engine to operate. + // Errors will be logged. + try + { + IOpenApiDocumentor openApiDocumentor = app.ApplicationServices.GetRequiredService(); + openApiDocumentor.CreateDocument(); + } + catch (DataApiBuilderException dabException) + { + _logger.LogError(exception: dabException, message: "OpenAPI Documentor initialization failed."); + } } _logger.LogInformation("Successfully completed runtime initialization."); From ebe7a78a10cef39210e8ae2fe74e61956b2bb639 Mon Sep 17 00:00:00 2001 From: Sean Leonard Date: Mon, 4 Mar 2024 16:58:19 -0800 Subject: [PATCH 2/3] update openapi init failure to warning and modify message to indicate the error has no impact on dab engine startup. --- src/Service/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/Startup.cs b/src/Service/Startup.cs index e9b780223a..a6f895a999 100644 --- a/src/Service/Startup.cs +++ b/src/Service/Startup.cs @@ -639,7 +639,7 @@ private async Task PerformOnConfigChangeAsync(IApplicationBuilder app) } catch (DataApiBuilderException dabException) { - _logger.LogError(exception: dabException, message: "OpenAPI Documentor initialization failed."); + _logger.LogWarning(exception: dabException, message: "OpenAPI Documentor initialization failed. This will not affect DAB engine startup."); } } From ff8d46f15f68935a8125f9e5011bba63770a94a7 Mon Sep 17 00:00:00 2001 From: Aniruddh Munde Date: Sun, 10 Mar 2024 15:12:36 -0700 Subject: [PATCH 3/3] Update src/Service/Startup.cs --- src/Service/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/Startup.cs b/src/Service/Startup.cs index a6f895a999..476fcd9736 100644 --- a/src/Service/Startup.cs +++ b/src/Service/Startup.cs @@ -639,7 +639,7 @@ private async Task PerformOnConfigChangeAsync(IApplicationBuilder app) } catch (DataApiBuilderException dabException) { - _logger.LogWarning(exception: dabException, message: "OpenAPI Documentor initialization failed. This will not affect DAB engine startup."); + _logger.LogWarning(exception: dabException, message: "OpenAPI Documentor initialization failed. This will not affect dab startup."); } }