Search in sources :

Example 6 with OperationImpl

use of fish.payara.microprofile.openapi.impl.model.OperationImpl 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);
}
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 7 with OperationImpl

use of fish.payara.microprofile.openapi.impl.model.OperationImpl 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);
}
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 8 with OperationImpl

use of fish.payara.microprofile.openapi.impl.model.OperationImpl in project Payara by payara.

the class CallbackImpl method applyCallbackOperationAnnotation.

private static void applyCallbackOperationAnnotation(PathItem pathItem, Operation callbackOperation, boolean override, ApiContext context) {
    if (callbackOperation instanceof OperationImpl) {
        OperationImpl callbackOperationImpl = (OperationImpl) callbackOperation;
        if (callbackOperationImpl.getMethod() != null) {
            HttpMethod method = getHttpMethod(callbackOperationImpl.getMethod());
            if (method != null) {
                Operation operation = getOrCreateOperation(pathItem, method);
                OperationImpl.merge(callbackOperation, operation, override, context);
            }
        }
    }
}
Also used : OperationImpl(fish.payara.microprofile.openapi.impl.model.OperationImpl) Operation(org.eclipse.microprofile.openapi.models.Operation) ModelUtils.getOrCreateOperation(fish.payara.microprofile.openapi.impl.model.util.ModelUtils.getOrCreateOperation) HttpMethod(org.eclipse.microprofile.openapi.models.PathItem.HttpMethod) ModelUtils.getHttpMethod(fish.payara.microprofile.openapi.impl.model.util.ModelUtils.getHttpMethod)

Example 9 with OperationImpl

use of fish.payara.microprofile.openapi.impl.model.OperationImpl 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);
}
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

OperationImpl (fish.payara.microprofile.openapi.impl.model.OperationImpl)9 PathItemImpl (fish.payara.microprofile.openapi.impl.model.PathItemImpl)7 PathItem (org.eclipse.microprofile.openapi.models.PathItem)7 APIResponseImpl (fish.payara.microprofile.openapi.impl.model.responses.APIResponseImpl)1 ModelUtils.getHttpMethod (fish.payara.microprofile.openapi.impl.model.util.ModelUtils.getHttpMethod)1 ModelUtils.getOrCreateOperation (fish.payara.microprofile.openapi.impl.model.util.ModelUtils.getOrCreateOperation)1 Status (javax.ws.rs.core.Response.Status)1 Operation (org.eclipse.microprofile.openapi.models.Operation)1 HttpMethod (org.eclipse.microprofile.openapi.models.PathItem.HttpMethod)1 APIResponse (org.eclipse.microprofile.openapi.models.responses.APIResponse)1 APIResponses (org.eclipse.microprofile.openapi.models.responses.APIResponses)1 MethodModel (org.glassfish.hk2.classmodel.reflect.MethodModel)1