use of org.springdoc.core.customizers.OpenApiCustomiser in project Projeto-Integrador by ProjetoAmbar.
the class SwaggerConfig method customerGlobalHeaderOpenApiCustomiser.
@Bean
public OpenApiCustomiser customerGlobalHeaderOpenApiCustomiser() {
return openApi -> {
openApi.getPaths().values().forEach(pathItem -> pathItem.readOperations().forEach(operation -> {
ApiResponses apiResponses = operation.getResponses();
apiResponses.addApiResponse("200", createApiResponse("Sucesso!"));
apiResponses.addApiResponse("201", createApiResponse("Objeto Persistido!"));
apiResponses.addApiResponse("204", createApiResponse("Objeto Excluído!"));
apiResponses.addApiResponse("400", createApiResponse("Erro na Requisição!"));
apiResponses.addApiResponse("401", createApiResponse("Acesso Não Autorizado!"));
apiResponses.addApiResponse("404", createApiResponse("Objeto Não Encontrado!"));
apiResponses.addApiResponse("500", createApiResponse("Erro na Aplicação!"));
}));
};
}
use of org.springdoc.core.customizers.OpenApiCustomiser in project springdoc-openapi by springdoc.
the class SpringDocTestApp method serverOpenApiCustomiser1.
public OpenApiCustomiser serverOpenApiCustomiser1() {
Server server = new Server().url("http://toto.v1.com").description("myserver1");
List<Server> servers = new ArrayList<>();
servers.add(server);
return openApi -> openApi.setServers(servers);
}
use of org.springdoc.core.customizers.OpenApiCustomiser in project springdoc-openapi by springdoc.
the class AbstractOpenApiResourceTest method preLoadingModeShouldNotOverwriteServers.
@Test
void preLoadingModeShouldNotOverwriteServers() throws InterruptedException {
when(openAPIService.updateServers(any())).thenCallRealMethod();
when(openAPIService.getCachedOpenAPI(any())).thenCallRealMethod();
doAnswer(new CallsRealMethods()).when(openAPIService).setServersPresent(true);
doAnswer(new CallsRealMethods()).when(openAPIService).setServerBaseUrl(any());
doAnswer(new CallsRealMethods()).when(openAPIService).setCachedOpenAPI(any(), any());
String customUrl = "https://custom.com";
String generatedUrl = "https://generated.com";
OpenApiCustomiser openApiCustomiser = openApi -> openApi.setServers(singletonList(new Server().url(customUrl)));
SpringDocConfigProperties properties = new SpringDocConfigProperties();
properties.setPreLoadingEnabled(true);
resource = new EmptyPathsOpenApiResource(GROUP_NAME, openAPIBuilderObjectFactory, requestBuilder, responseBuilder, operationParser, Optional.empty(), Optional.of(singletonList(openApiCustomiser)), Optional.empty(), properties, springDocProviders);
// wait for executor to be done
Thread.sleep(1_000);
// emulate generating base url
openAPIService.setServerBaseUrl(generatedUrl);
openAPIService.updateServers(openAPI);
Locale locale = Locale.US;
OpenAPI after = resource.getOpenApi(locale);
assertThat(after.getServers().get(0).getUrl(), is(customUrl));
}
use of org.springdoc.core.customizers.OpenApiCustomiser 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.OpenApiCustomiser in project DiversiFica by teey-tech.
the class SwaggerConfig method customerGlobalHeaderOpenApiCustomiser.
@Bean
public OpenApiCustomiser customerGlobalHeaderOpenApiCustomiser() {
return openApi -> {
openApi.getPaths().values().forEach(pathItem -> pathItem.readOperations().forEach(operation -> {
ApiResponses apiResponses = operation.getResponses();
apiResponses.addApiResponse("200", createApiResponse("Sucesso!"));
apiResponses.addApiResponse("201", createApiResponse("Objeto Persistido!"));
apiResponses.addApiResponse("204", createApiResponse("Objeto Excluído!"));
apiResponses.addApiResponse("400", createApiResponse("Erro na Requisição!"));
apiResponses.addApiResponse("401", createApiResponse("Acesso Não Autorizado!"));
apiResponses.addApiResponse("404", createApiResponse("Objeto Não Encontrado!"));
apiResponses.addApiResponse("500", createApiResponse("Erro na Aplicação!"));
}));
};
}
Aggregations