Java Code Examples for org.eclipse.microprofile.openapi.models.Operation#getTags()

The following examples show how to use org.eclipse.microprofile.openapi.models.Operation#getTags() . 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: AirlinesOASFilter.java    From microprofile-open-api with Apache License 2.0 6 votes vote down vote up
@Override
public Operation filterOperation(Operation operation) {
    if("Get a booking with ID".equals(operation.getSummary())){
        operation.setSummary("filterOperation - Get a booking with ID");  
    } 
    else if("Update a booking with ID".equals(operation.getSummary())){
        operation.setSummary("filterOperation - Update a booking with ID");  
    }
    else if("Retrieve all available flights".equals(operation.getSummary())){
        operation.setOperationId("filterOperationGetFlights");
    }
    
    List<String> tags = operation.getTags();
    if (tags != null) {
        if (tags.contains("Bookings")) {
            tags = new ArrayList<>(tags);
            tags.set(tags.indexOf("Bookings"), "parent - Bookings");
            operation.setTags(tags);
        }
    }
    return operation;
}
 
Example 2
Source File: OpenApiSpecStyleValidator.java    From openapi-style-validator with Apache License 2.0 5 votes vote down vote up
private void validateOperations() {
    for (String key : openAPI.getPaths().getPathItems().keySet()) {
        PathItem path = openAPI.getPaths().getPathItems().get(key);
        for (PathItem.HttpMethod method : path.getOperations().keySet()) {
            Operation op = path.getOperations().get(method);
            if (parameters.isValidateOperationOperationId()) {
                if (op.getOperationId() == null || op.getOperationId().isEmpty()) {
                    errorAggregator.logMissingOrEmptyOperationAttribute(key, method, "operationId");
                }
            }

            if (parameters.isValidateOperationDescription()) {
                if (op.getDescription() == null || op.getDescription().isEmpty()) {
                    errorAggregator.logMissingOrEmptyOperationAttribute(key, method, "description");
                }
            }

            if (parameters.isValidateOperationSummary()) {
                if (op.getSummary() == null || op.getSummary().isEmpty()) {
                    errorAggregator.logMissingOrEmptyOperationAttribute(key, method, "summary");
                }
            }

            if (parameters.isValidateOperationTag()) {
                if (op.getTags() == null || op.getTags().isEmpty()) {
                    errorAggregator.logMissingOrEmptyOperationCollection(key, method, "tags");
                }
            }
        }
    }
}