Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to create OpenAPI document only if rest is enabled #1872

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 14 additions & 11 deletions src/Service/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -610,18 +610,21 @@ private async Task<bool> PerformOnConfigChangeAsync(IApplicationBuilder app)

runtimeConfigValidator.ValidateStoredProceduresInConfig(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
if (runtimeConfig.IsRestEnabled)
{
IOpenApiDocumentor openApiDocumentor = app.ApplicationServices.GetRequiredService<IOpenApiDocumentor>();
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<IOpenApiDocumentor>();
openApiDocumentor.CreateDocument();
}
catch (DataApiBuilderException dabException)
{
_logger.LogWarning(exception: dabException, message: "OpenAPI Documentor initialization failed.");
}
}

_logger.LogInformation("Successfully completed runtime initialization.");
Expand Down