use of fish.payara.microprofile.openapi.impl.model.PathItemImpl in project Payara by payara.
the class ApplicationProcessor method visitDELETE.
@Override
public void visitDELETE(AnnotationModel delete, 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.setDELETE(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.DELETE);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
use of fish.payara.microprofile.openapi.impl.model.PathItemImpl in project Payara by payara.
the class ApplicationProcessor method visitPUT.
@Override
public void visitPUT(AnnotationModel put, 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.setPUT(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.PUT);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
use of fish.payara.microprofile.openapi.impl.model.PathItemImpl in project Payara by payara.
the class BaseProcessor method removeEmptyPaths.
private static void removeEmptyPaths(Paths paths) {
final PathItem emptyPath = new PathItemImpl();
HashSet<String> namesToRemove = new HashSet<>();
for (Entry<String, PathItem> pathItem : paths.getPathItems().entrySet()) {
final String pathName = pathItem.getKey();
if (emptyPath.equals(pathItem.getValue())) {
namesToRemove.add(pathName);
}
}
// remove all names
for (String name : namesToRemove) {
paths.removePathItem(name);
}
}
use of fish.payara.microprofile.openapi.impl.model.PathItemImpl in project Payara by payara.
the class CallbackImpl method merge.
public static void merge(Callback from, Callback to, boolean override, ApiContext context) {
if (from == null) {
return;
}
if (from.getRef() != null && !from.getRef().isEmpty()) {
applyReference(to, from.getRef());
return;
}
if (from instanceof CallbackImpl) {
CallbackImpl fromImpl = (CallbackImpl) from;
String urlExpression = fromImpl.getUrlExpression();
if (urlExpression != null && !urlExpression.isEmpty()) {
PathItem pathItem = to.getPathItems().getOrDefault(urlExpression, new PathItemImpl());
to.addPathItem(urlExpression, pathItem);
if (fromImpl.getOperations() != null) {
for (Operation callbackOperation : fromImpl.getOperations()) {
applyCallbackOperationAnnotation(pathItem, callbackOperation, override, context);
}
}
}
}
}
use of fish.payara.microprofile.openapi.impl.model.PathItemImpl in project Payara by payara.
the class ApplicationProcessor method visitOPTIONS.
@Override
public void visitOPTIONS(AnnotationModel options, 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.setOPTIONS(operation);
operation.setOperationId(element.getName());
operation.setMethod(HttpMethod.OPTIONS);
// Add the default request
insertDefaultRequestBody(context, operation, element);
// Add the default response
insertDefaultResponse(context, operation, element);
}
Aggregations