use of org.eclipse.microprofile.openapi.models.PathItem 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 org.eclipse.microprofile.openapi.models.PathItem 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 org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class PathItemImpl method createInstance.
public static PathItem createInstance(AnnotationModel annotation, ApiContext context) {
PathItem from = new PathItemImpl();
extractAnnotations(annotation, context, "servers", ServerImpl::createInstance, from::addServer);
return from;
}
use of org.eclipse.microprofile.openapi.models.PathItem in project Payara by payara.
the class OpenApiWalker method addSchemasToPaths.
private void addSchemasToPaths() {
OpenAPI api = context.getApi();
api.getPaths().getPathItems().forEach((String s, PathItem t) -> {
t.getOperations().forEach((PathItem.HttpMethod u, org.eclipse.microprofile.openapi.models.Operation v) -> {
v.getResponses().getAPIResponses().forEach((String w, org.eclipse.microprofile.openapi.models.responses.APIResponse x) -> {
if (x.getContent() != null) {
x.getContent().getMediaTypes().forEach((y, z) -> {
SchemaImpl.merge(z.getSchema(), z.getSchema(), true, context);
if (z.getSchema() instanceof SchemaImpl) {
SchemaImpl schema = (SchemaImpl) z.getSchema();
schema.setImplementation(null);
}
});
}
});
});
});
}
use of org.eclipse.microprofile.openapi.models.PathItem 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