use of io.swagger.v3.core.model.ApiDescription in project swagger-core by swagger-api.
the class SpecFilter method filterResponse.
protected ApiResponse filterResponse(OpenAPISpecFilter filter, Operation operation, ApiResponse response, String resourcePath, String key, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) {
if (response != null) {
ApiDescription description = new ApiDescription(resourcePath, key);
Optional<ApiResponse> filteredResponse = filter.filterResponse(response, operation, description, params, cookies, headers);
if (filteredResponse.isPresent()) {
return filteredResponse.get();
}
}
return null;
}
use of io.swagger.v3.core.model.ApiDescription in project swagger-core by swagger-api.
the class SpecFilter method filterRequestBody.
protected RequestBody filterRequestBody(OpenAPISpecFilter filter, Operation operation, RequestBody requestBody, String resourcePath, String key, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) {
if (requestBody != null) {
ApiDescription description = new ApiDescription(resourcePath, key);
Optional<RequestBody> filteredRequestBody = filter.filterRequestBody(requestBody, operation, description, params, cookies, headers);
if (filteredRequestBody.isPresent()) {
return filteredRequestBody.get();
}
}
return null;
}
use of io.swagger.v3.core.model.ApiDescription in project swagger-core by swagger-api.
the class SpecFilter method filterParameter.
protected Parameter filterParameter(OpenAPISpecFilter filter, Operation operation, Parameter parameter, String resourcePath, String key, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) {
if (parameter != null) {
ApiDescription description = new ApiDescription(resourcePath, key);
Optional<Parameter> filteredParameter = filter.filterParameter(parameter, operation, description, params, cookies, headers);
if (filteredParameter.isPresent()) {
return filteredParameter.get();
}
}
return null;
}
use of io.swagger.v3.core.model.ApiDescription 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));
}
use of io.swagger.v3.core.model.ApiDescription in project swagger-core by swagger-api.
the class SpecFilter method filterOperation.
protected Operation filterOperation(OpenAPISpecFilter filter, Operation operation, String resourcePath, String key, Map<String, List<String>> params, Map<String, String> cookies, Map<String, List<String>> headers) {
if (operation != null) {
ApiDescription description = new ApiDescription(resourcePath, key);
Optional<Operation> filteredOperation = filter.filterOperation(operation, description, params, cookies, headers);
if (filteredOperation.isPresent()) {
List<Parameter> filteredParameters = new ArrayList<>();
Operation filteredOperationGet = filteredOperation.get();
Operation clone = new Operation();
clone.setCallbacks(filteredOperationGet.getCallbacks());
clone.setDeprecated(filteredOperationGet.getDeprecated());
clone.setDescription(filteredOperationGet.getDescription());
clone.setExtensions(filteredOperationGet.getExtensions());
clone.setExternalDocs(filteredOperationGet.getExternalDocs());
clone.setOperationId(filteredOperationGet.getOperationId());
clone.setSecurity(filteredOperationGet.getSecurity());
clone.setServers(filteredOperationGet.getServers());
clone.setSummary(filteredOperationGet.getSummary());
clone.setTags(filteredOperationGet.getTags());
List<Parameter> parameters = filteredOperationGet.getParameters();
if (parameters != null) {
for (Parameter parameter : parameters) {
Parameter filteredParameter = filterParameter(filter, operation, parameter, resourcePath, key, params, cookies, headers);
if (filteredParameter != null) {
filteredParameters.add(filteredParameter);
}
}
clone.setParameters(filteredParameters);
}
RequestBody requestBody = filteredOperation.get().getRequestBody();
if (requestBody != null) {
RequestBody filteredRequestBody = filterRequestBody(filter, operation, requestBody, resourcePath, key, params, cookies, headers);
clone.setRequestBody(filteredRequestBody);
}
ApiResponses responses = filteredOperation.get().getResponses();
ApiResponses clonedResponses = responses;
if (responses != null) {
responses.forEach((responseKey, response) -> {
ApiResponse filteredResponse = filterResponse(filter, operation, response, resourcePath, key, params, cookies, headers);
if (filteredResponse != null) {
clonedResponses.addApiResponse(responseKey, filteredResponse);
}
});
clone.setResponses(clonedResponses);
}
return clone;
}
}
return null;
}
Aggregations