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

The following examples show how to use org.eclipse.microprofile.openapi.models.Operation#setSummary() . 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: OperationReader.java    From smallrye-open-api with Apache License 2.0 6 votes vote down vote up
/**
 * Reads a {@link Operation} OpenAPI node.
 * 
 * @param node json object
 * @return Operation model
 */
public static Operation readOperation(final JsonNode node) {
    if (node == null || !node.isObject()) {
        return null;
    }
    IoLogging.log.singleJsonObject("Operation");
    Operation model = new OperationImpl();
    model.setTags(JsonUtil.readStringArray(node.get(OperationConstant.PROP_TAGS)).orElse(null));
    model.setSummary(JsonUtil.stringProperty(node, OperationConstant.PROP_SUMMARY));
    model.setDescription(JsonUtil.stringProperty(node, OperationConstant.PROP_DESCRIPTION));
    model.setExternalDocs(ExternalDocsReader.readExternalDocs(node.get(ExternalDocsConstant.PROP_EXTERNAL_DOCS)));
    model.setOperationId(JsonUtil.stringProperty(node, OperationConstant.PROP_OPERATION_ID));
    model.setParameters(ParameterReader.readParameterList(node.get(OperationConstant.PROP_PARAMETERS)).orElse(null));
    model.setRequestBody(RequestBodyReader.readRequestBody(node.get(OperationConstant.PROP_REQUEST_BODY)));
    model.setResponses(ResponseReader.readResponses(node.get(OperationConstant.PROP_RESPONSES)));
    model.setCallbacks(CallbackReader.readCallbacks(node.get(OperationConstant.PROP_CALLBACKS)));
    model.setDeprecated(JsonUtil.booleanProperty(node, OperationConstant.PROP_DEPRECATED).orElse(null));
    model.setSecurity(
            SecurityRequirementReader.readSecurityRequirements(node.get(OperationConstant.PROP_SECURITY)).orElse(null));
    model.setServers(ServerReader.readServers(node.get(OperationConstant.PROP_SERVERS)).orElse(null));
    ExtensionReader.readExtensions(node, model);
    return model;
}
 
Example 2
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 3
Source File: OperationReader.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * Reads a single Operation annotation.
 * 
 * @param context the scanning context
 * @param annotationInstance {@literal @}CallbackOperation annotation
 * @return Operation model
 */
public static Operation readOperation(final AnnotationScannerContext context,
        final AnnotationInstance annotationInstance) {
    if (annotationInstance == null) {
        return null;
    }
    IoLogging.log.singleAnnotation("@Operation");
    Operation operation = new OperationImpl();
    operation.setSummary(JandexUtil.stringValue(annotationInstance, OperationConstant.PROP_SUMMARY));
    operation.setDescription(JandexUtil.stringValue(annotationInstance, OperationConstant.PROP_DESCRIPTION));
    operation.setExternalDocs(
            ExternalDocsReader.readExternalDocs(annotationInstance.value(ExternalDocsConstant.PROP_EXTERNAL_DOCS)));
    operation.setParameters(ParameterReader.readParametersList(context,
            annotationInstance.value(OperationConstant.PROP_PARAMETERS)).orElse(null));
    operation.setRequestBody(RequestBodyReader.readRequestBody(context,
            annotationInstance.value(OperationConstant.PROP_REQUEST_BODY)));
    operation.setResponses(ResponseReader.readResponses(context,
            annotationInstance.value(OperationConstant.PROP_RESPONSES)));
    operation.setSecurity(SecurityRequirementReader
            .readSecurityRequirements(annotationInstance.value(OperationConstant.PROP_SECURITY)).orElse(null));
    operation.setExtensions(
            ExtensionReader.readExtensions(context,
                    annotationInstance.value(OperationConstant.PROP_EXTENSIONS)));

    // Below is only used in Jax-rs ??
    // Operation Id ??
    operation.setOperationId(JandexUtil.stringValue(annotationInstance, OperationConstant.PROP_OPERATION_ID));
    // Deprecated ??
    operation.setDeprecated(JandexUtil.booleanValue(annotationInstance, OperationConstant.PROP_DEPRECATED).orElse(null));

    // Below is not used ?
    // Tags ?
    // Callbacks
    // Servers
    return operation;
}