use of org.springdoc.core.customizers.ActuatorOperationCustomizer in project jhipster-bom by jhipster.
the class JHipsterSpringDocGroupsConfiguration method openAPIDefaultGroupedOpenAPI.
/**
* OpenApi default group configuration.
*
* @return the GroupedOpenApi configuration
*/
@Bean
@ConditionalOnMissingBean(name = "openAPIDefaultGroupedOpenAPI")
public GroupedOpenApi openAPIDefaultGroupedOpenAPI(List<OpenApiCustomiser> openApiCustomisers, List<OperationCustomizer> operationCustomizers, @Qualifier("apiFirstGroupedOpenAPI") Optional<GroupedOpenApi> apiFirstGroupedOpenAPI, SpringDocConfigProperties springDocConfigProperties) {
log.debug("Initializing JHipster OpenApi default group");
Builder builder = GroupedOpenApi.builder().group(DEFAULT_GROUP_NAME).pathsToMatch(properties.getDefaultIncludePattern());
openApiCustomisers.stream().filter(customiser -> !(customiser instanceof ActuatorOpenApiCustomizer)).forEach(builder::addOpenApiCustomiser);
operationCustomizers.stream().filter(customiser -> !(customiser instanceof ActuatorOperationCustomizer)).forEach(builder::addOperationCustomizer);
apiFirstGroupedOpenAPI.ifPresent(apiFirst -> {
if (apiFirst.getPackagesToScan() != null) {
apiFirst.getPackagesToScan().stream().forEach(builder::packagesToExclude);
}
});
return builder.build();
}
use of org.springdoc.core.customizers.ActuatorOperationCustomizer in project springdoc-openapi by springdoc.
the class SpringdocActuatorBeanFactoryConfigurer method postProcessBeanFactory.
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
final BindResult<WebEndpointProperties> result = Binder.get(environment).bind(MANAGEMENT_ENDPOINTS_WEB, WebEndpointProperties.class);
if (result.isBound()) {
WebEndpointProperties webEndpointProperties = result.get();
List<GroupedOpenApi> newGroups = new ArrayList<>();
ActuatorOpenApiCustomizer actuatorOpenApiCustomiser = new ActuatorOpenApiCustomizer(webEndpointProperties);
beanFactory.registerSingleton("actuatorOpenApiCustomiser", actuatorOpenApiCustomiser);
ActuatorOperationCustomizer actuatorCustomizer = new ActuatorOperationCustomizer();
beanFactory.registerSingleton("actuatorCustomizer", actuatorCustomizer);
GroupedOpenApi actuatorGroup = GroupedOpenApi.builder().group(ACTUATOR_DEFAULT_GROUP).pathsToMatch(webEndpointProperties.getBasePath() + ALL_PATTERN).pathsToExclude(webEndpointProperties.getBasePath() + HEALTH_PATTERN).addOperationCustomizer(actuatorCustomizer).addOpenApiCustomiser(actuatorOpenApiCustomiser).build();
// Add the actuator group
newGroups.add(actuatorGroup);
if (CollectionUtils.isEmpty(groupedOpenApis)) {
GroupedOpenApi defaultGroup = GroupedOpenApi.builder().group(DEFAULT_GROUP_NAME).pathsToMatch(ALL_PATTERN).pathsToExclude(webEndpointProperties.getBasePath() + ALL_PATTERN).build();
// Register the default group
newGroups.add(defaultGroup);
}
newGroups.forEach(elt -> beanFactory.registerSingleton(elt.getGroup(), elt));
}
initBeanFactoryPostProcessor(beanFactory);
}
Aggregations