Java Code Examples for org.eclipse.microprofile.openapi.models.PathItem#getGET()

The following examples show how to use org.eclipse.microprofile.openapi.models.PathItem#getGET() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterUtil.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Filters the given model.
 * 
 * @param filter
 * @param model
 */
private static void filterPathItem(OASFilter filter, PathItem model) {
    if (model != null) {
        model.setParameters(filterParameterList(filter, model.getParameters()));
        filterOperation(filter, model.getDELETE());
        if (model.getDELETE() != null) {
            model.setDELETE(filter.filterOperation(model.getDELETE()));
        }
        filterOperation(filter, model.getGET());
        if (model.getGET() != null) {
            model.setGET(filter.filterOperation(model.getGET()));
        }
        filterOperation(filter, model.getHEAD());
        if (model.getHEAD() != null) {
            model.setHEAD(filter.filterOperation(model.getHEAD()));
        }
        filterOperation(filter, model.getOPTIONS());
        if (model.getOPTIONS() != null) {
            model.setOPTIONS(filter.filterOperation(model.getOPTIONS()));
        }
        filterOperation(filter, model.getPATCH());
        if (model.getPATCH() != null) {
            model.setPATCH(filter.filterOperation(model.getPATCH()));
        }
        filterOperation(filter, model.getPOST());
        if (model.getPOST() != null) {
            model.setPOST(filter.filterOperation(model.getPOST()));
        }
        filterOperation(filter, model.getPUT());
        if (model.getPUT() != null) {
            model.setPUT(filter.filterOperation(model.getPUT()));
        }
        filterOperation(filter, model.getTRACE());
        if (model.getTRACE() != null) {
            model.setTRACE(filter.filterOperation(model.getTRACE()));
        }
        filterServers(filter, model.getServers());
    }
}
 
Example 2
Source File: AirlinesOASFilter.java    From microprofile-open-api with Apache License 2.0 5 votes vote down vote up
@Override
public PathItem filterPathItem(PathItem pathItem){
    if(pathItem.getGET() != null && "Retrieve all available flights".equals(pathItem.getGET().getSummary())){
        //Add new operation
        pathItem.PUT(OASFactory.createObject(Operation.class).
                summary("filterPathItem - added put operation")
                .responses(OASFactory.createObject(APIResponses.class).addAPIResponse("200", 
                        OASFactory.createObject(APIResponse.class).description("filterPathItem - successfully put airlines"))));
        
        //Spec states : All filterable descendant elements of a filtered element must be called before its ancestor
        //Override the operatioId value that was previously overridden by the filterOperation method
        pathItem.getGET().setOperationId("filterPathItemGetFlights");
    }
    
    if (pathItem.getPOST() != null && "createBooking".equals(pathItem.getPOST().getOperationId())) {
        Map<String, Callback> callbacks = pathItem.getPOST().getCallbacks();
        if (callbacks.containsKey("bookingCallback")) {
            Callback callback = callbacks.get("bookingCallback");
            if (callback.hasPathItem("http://localhost:9080/airlines/bookings")
                    && callback.getPathItem("http://localhost:9080/airlines/bookings").getGET() != null) {
                if ("child - Retrieve all bookings for current user".equals(callback.getPathItem("http://localhost:9080/airlines/bookings")
                        .getGET().getDescription())) {   
                    callback.getPathItem("http://localhost:9080/airlines/bookings").getGET()
                    .setDescription("parent - Retrieve all bookings for current user"); 
                }
            }
        }   
    }
    
    return pathItem;
}