Search in sources :

Example 6 with PathItem

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

Example 7 with PathItem

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);
                }
            }
        }
    }
}
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 8 with PathItem

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

Example 9 with PathItem

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);
                        }
                    });
                }
            });
        });
    });
}
Also used : PathItem(org.eclipse.microprofile.openapi.models.PathItem) SchemaImpl(fish.payara.microprofile.openapi.impl.model.media.SchemaImpl) APIResponse(org.eclipse.microprofile.openapi.annotations.responses.APIResponse) Operation(org.eclipse.microprofile.openapi.annotations.Operation) OpenAPI(org.eclipse.microprofile.openapi.models.OpenAPI)

Example 10 with PathItem

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);
}
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

PathItem (org.eclipse.microprofile.openapi.models.PathItem)20 PathItemImpl (fish.payara.microprofile.openapi.impl.model.PathItemImpl)10 OperationImpl (fish.payara.microprofile.openapi.impl.model.OperationImpl)7 Operation (org.eclipse.microprofile.openapi.models.Operation)6 ServerImpl (fish.payara.microprofile.openapi.impl.model.servers.ServerImpl)3 HashSet (java.util.HashSet)3 Server (org.eclipse.microprofile.openapi.models.servers.Server)3 InfoImpl (fish.payara.microprofile.openapi.impl.model.info.InfoImpl)2 SchemaImpl (fish.payara.microprofile.openapi.impl.model.media.SchemaImpl)2 ArrayList (java.util.ArrayList)2 Paths (org.eclipse.microprofile.openapi.models.Paths)2 Callback (org.eclipse.microprofile.openapi.models.callbacks.Callback)2 MediaType (org.eclipse.microprofile.openapi.models.media.MediaType)2 Schema (org.eclipse.microprofile.openapi.models.media.Schema)2 Parameter (org.eclipse.microprofile.openapi.models.parameters.Parameter)2 RequestBody (org.eclipse.microprofile.openapi.models.parameters.RequestBody)2 APIResponse (org.eclipse.microprofile.openapi.models.responses.APIResponse)2 APIResponses (org.eclipse.microprofile.openapi.models.responses.APIResponses)2 SecurityRequirement (org.eclipse.microprofile.openapi.models.security.SecurityRequirement)2 Tag (org.eclipse.microprofile.openapi.models.tags.Tag)2