use of org.springdoc.core.GroupedOpenApi in project snow-owl by b2ihealthcare.
the class BaseApiConfig method docs.
/**
* Expose this as @Bean annotated component in the implementation configuration class.
* @return a configured docket for this API module
*/
protected final GroupedOpenApi docs(final String apiBaseUrl, final String apiGroup, final String apiVersion, final String apiTitle, final String apiTermsOfServiceUrl, final String apiContact, final String apiLicense, final String apiLicenseUrl, final String apiDescription) {
return GroupedOpenApi.builder().group(apiGroup).pathsToMatch(apiBaseUrl.endsWith("/") ? apiBaseUrl + "**" : apiBaseUrl + "/**").packagesToScan(getApiBasePackages()).addOpenApiCustomiser(api -> {
Info apiInfo = api.getInfo();
apiInfo.setTitle(apiTitle);
apiInfo.setDescription(apiDescription);
apiInfo.setVersion(apiVersion);
apiInfo.setTermsOfService(apiTermsOfServiceUrl);
Contact contact = new Contact();
contact.setName("B2i Healthcare");
contact.setEmail(apiContact);
contact.setUrl(apiLicenseUrl);
apiInfo.setContact(contact);
License license = new License();
license.setName(apiLicense);
license.setUrl(apiLicenseUrl);
apiInfo.setLicense(license);
// configure global security
api.getComponents().addSecuritySchemes("basic", new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")).addSecuritySchemes("bearer", new SecurityScheme().type(SecurityScheme.Type.APIKEY).scheme("bearer").in(In.HEADER).bearerFormat("JWT"));
// disable servers prop
api.setServers(List.of());
}).addOperationCustomizer((operation, method) -> {
return operation.addSecurityItem(new SecurityRequirement().addList("basic").addList("bearer"));
}).build();
// .useDefaultResponseMessages(false)
// .alternateTypeRules(getAlternateTypeRules(resolver));
}
Aggregations