use of org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class ApplicationProcessor method mapException.
/**
* When an exception mapper is encountered, register the mapped response and
* find any operations already parsed that this exception mapper is applicable
* to
*/
private void mapException(ApiContext context, String exceptionType, APIResponseImpl exceptionResponse) {
// Don't allow null responses
if (exceptionResponse.getDescription() == null || exceptionResponse.getDescription().isEmpty()) {
exceptionResponse.setDescription(ModelUtils.getSimpleName(exceptionType));
}
context.addMappedExceptionResponse(exceptionType, exceptionResponse);
final String exceptionStatus = exceptionResponse.getResponseCode();
if (exceptionStatus != null) {
for (PathItem path : context.getApi().getPaths().getPathItems().values()) {
for (Operation operation : path.getOperations().values()) {
if (((OperationImpl) operation).getExceptionTypes().contains(exceptionType)) {
operation.getResponses().addAPIResponse(exceptionStatus, exceptionResponse);
}
}
}
} else {
LOGGER.fine("Failed to add mapped response as no response code was provided");
}
}
use of org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class ApplicationProcessor method visitGET.
// JAX-RS method handlers
@Override
public void visitGET(AnnotationModel get, MethodModel element, ApiContext context) {
if (context.getPath() == null) {
return;
}
// Get or create the path item
PathItem pathItem = context.getApi().getPaths().getPathItems().getOrDefault(context.getPath(), new PathItemImpl());
context.getApi().getPaths().addPathItem(context.getPath(), pathItem);
OperationImpl operation = new OperationImpl();
pathItem.setGET(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.GET);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
use of org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class ApplicationProcessor method visitPATCH.
@Override
public void visitPATCH(AnnotationModel patch, MethodModel element, ApiContext context) {
if (context.getPath() == null) {
return;
}
// Get or create the path item
PathItem pathItem = context.getApi().getPaths().getPathItems().getOrDefault(context.getPath(), new PathItemImpl());
context.getApi().getPaths().addPathItem(context.getPath(), pathItem);
OperationImpl operation = new OperationImpl();
pathItem.setPATCH(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.PATCH);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
use of org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class ApplicationProcessor method visitHEAD.
@Override
public void visitHEAD(AnnotationModel head, MethodModel element, ApiContext context) {
if (context.getPath() == null) {
return;
}
// Get or create the path item
PathItem pathItem = context.getApi().getPaths().getPathItems().getOrDefault(context.getPath(), new PathItemImpl());
context.getApi().getPaths().addPathItem(context.getPath(), pathItem);
OperationImpl operation = new OperationImpl();
pathItem.setHEAD(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.HEAD);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
use of org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class ApplicationProcessor method visitPOST.
@Override
public void visitPOST(AnnotationModel post, MethodModel element, ApiContext context) {
if (context.getPath() == null) {
return;
}
// Get or create the path item
PathItem pathItem = context.getApi().getPaths().getPathItems().getOrDefault(context.getPath(), new PathItemImpl());
context.getApi().getPaths().addPathItem(context.getPath(), pathItem);
OperationImpl operation = new OperationImpl();
pathItem.setPOST(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.POST);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
Aggregations