Search in sources :

Example 1 with PathItemImpl

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);
}
Also used : PathItem(org.eclipse.microprofile.openapi.models.PathItem) OperationImpl(fish.payara.microprofile.openapi.impl.model.OperationImpl) PathItemImpl(fish.payara.microprofile.openapi.impl.model.PathItemImpl)

Example 2 with PathItemImpl

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);
}
Also used : PathItem(org.eclipse.microprofile.openapi.models.PathItem) OperationImpl(fish.payara.microprofile.openapi.impl.model.OperationImpl) PathItemImpl(fish.payara.microprofile.openapi.impl.model.PathItemImpl)

Example 3 with PathItemImpl

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);
    }
}
Also used : PathItem(org.eclipse.microprofile.openapi.models.PathItem) PathItemImpl(fish.payara.microprofile.openapi.impl.model.PathItemImpl) HashSet(java.util.HashSet)

Example 4 with PathItemImpl

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);
                }
            }
        }
    }
}
Also used : PathItem(org.eclipse.microprofile.openapi.models.PathItem) Operation(org.eclipse.microprofile.openapi.models.Operation) ModelUtils.getOrCreateOperation(fish.payara.microprofile.openapi.impl.model.util.ModelUtils.getOrCreateOperation) PathItemImpl(fish.payara.microprofile.openapi.impl.model.PathItemImpl)

Example 5 with PathItemImpl

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);
}
Also used : PathItem(org.eclipse.microprofile.openapi.models.PathItem) OperationImpl(fish.payara.microprofile.openapi.impl.model.OperationImpl) PathItemImpl(fish.payara.microprofile.openapi.impl.model.PathItemImpl)

Aggregations

PathItemImpl (fish.payara.microprofile.openapi.impl.model.PathItemImpl)10 PathItem (org.eclipse.microprofile.openapi.models.PathItem)10 OperationImpl (fish.payara.microprofile.openapi.impl.model.OperationImpl)7 HashSet (java.util.HashSet)2 Operation (org.eclipse.microprofile.openapi.models.Operation)2 InfoImpl (fish.payara.microprofile.openapi.impl.model.info.InfoImpl)1 ServerImpl (fish.payara.microprofile.openapi.impl.model.servers.ServerImpl)1 ModelUtils.getOrCreateOperation (fish.payara.microprofile.openapi.impl.model.util.ModelUtils.getOrCreateOperation)1 URL (java.net.URL)1 Set (java.util.Set)1