use of org.eclipse.microprofile.openapi.models.PathItem in project wildfly-swarm by wildfly-swarm.
the class OpenApiAnnotationScanner method readCallbackOperations.
/**
* Reads the CallbackOperation annotations as a PathItem. The annotation value
* in this case is an array of CallbackOperation annotations.
* @param value
*/
private PathItem readCallbackOperations(AnnotationValue value) {
if (value == null) {
return null;
}
LOG.debug("Processing an array of @CallbackOperation annotations.");
AnnotationInstance[] nestedArray = value.asNestedArray();
PathItem pathItem = new PathItemImpl();
for (AnnotationInstance operationAnno : nestedArray) {
String method = JandexUtil.stringValue(operationAnno, OpenApiConstants.PROP_METHOD);
Operation operation = readCallbackOperation(operationAnno);
if (method == null) {
continue;
}
try {
PropertyDescriptor descriptor = PropertyUtils.getPropertyDescriptor(pathItem, method.toUpperCase());
Method mutator = PropertyUtils.getWriteMethod(descriptor);
mutator.invoke(pathItem, operation);
} catch (Exception e) {
LOG.error("Error reading a CallbackOperation annotation.", e);
}
}
return pathItem;
}
use of org.eclipse.microprofile.openapi.models.PathItem in project wildfly-swarm by wildfly-swarm.
the class FilterUtil method filterCallback.
/**
* Filters the given model.
* @param filter
* @param model
*/
private static void filterCallback(OASFilter filter, Callback model) {
if (model == null) {
return;
}
Collection<String> keys = new ArrayList<>(model.keySet());
for (String key : keys) {
PathItem childModel = model.get(key);
filterPathItem(filter, childModel);
if (filter.filterPathItem(childModel) == null) {
model.remove(key);
}
}
filterExtensions(filter, model.getExtensions());
}
use of org.eclipse.microprofile.openapi.models.PathItem in project wildfly-swarm by wildfly-swarm.
the class FilterUtil method filterPaths.
/**
* Filters the given model.
* @param filter
* @param model
*/
private static void filterPaths(OASFilter filter, Paths model) {
if (model == null) {
return;
}
Collection<String> keys = new ArrayList<>(model.keySet());
for (String key : keys) {
PathItem childModel = model.get(key);
filterPathItem(filter, childModel);
if (filter.filterPathItem(childModel) == null) {
model.remove(key);
}
}
filterExtensions(filter, model.getExtensions());
}
use of org.eclipse.microprofile.openapi.models.PathItem 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 org.eclipse.microprofile.openapi.models.PathItem 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);
}
Aggregations