Skip to content

Add pre-loading setting to load OpenAPI early #854

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

Merged
merged 1 commit into from
Sep 6, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonView;
Expand Down Expand Up @@ -200,6 +201,10 @@ protected AbstractOpenApiResource(String groupName, ObjectFactory<OpenAPIBuilder
operationCustomizers.get().removeIf(Objects::isNull);
this.operationCustomizers = operationCustomizers;
this.actuatorProvider = actuatorProvider;
if (springDocConfigProperties.isPreLoadingEnabled()) {
Executors.newSingleThreadExecutor()
.execute(this::getOpenApi);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ public class SpringDocConfigProperties {
*/
private boolean showLoginEndpoint;

/**
* Allow for pre-loading OpenAPI
*/
private boolean preLoadingEnabled = false;

/**
* Is use fqn boolean.
*
Expand Down Expand Up @@ -472,6 +477,14 @@ public void setWriterWithDefaultPrettyPrinter(boolean writerWithDefaultPrettyPri
this.writerWithDefaultPrettyPrinter = writerWithDefaultPrettyPrinter;
}

public void setPreLoadingEnabled(boolean preLoadingEnabled) {
this.preLoadingEnabled = preLoadingEnabled;
}

public boolean isPreLoadingEnabled() {
return preLoadingEnabled;
}

/**
* The type Model converters.
*/
Expand Down