Search in sources :

Example 1 with APIResponsesImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.responses.APIResponsesImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiParser method readAPIResponses.

/**
 * Reads a {@link APIResponses} OpenAPI node.
 * @param node
 */
private APIResponses readAPIResponses(JsonNode node) {
    if (node == null || !node.isObject()) {
        return null;
    }
    APIResponsesImpl model = new APIResponsesImpl();
    model.setDefaultValue(readAPIResponse(node.get(OpenApiConstants.PROP_DEFAULT)));
    for (Iterator<String> fieldNames = node.fieldNames(); fieldNames.hasNext(); ) {
        String fieldName = fieldNames.next();
        if (OpenApiConstants.PROP_DEFAULT.equals(fieldName)) {
            continue;
        }
        model.addApiResponse(fieldName, readAPIResponse(node.get(fieldName)));
    }
    return model;
}
Also used : APIResponsesImpl(org.wildfly.swarm.microprofile.openapi.api.models.responses.APIResponsesImpl)

Example 2 with APIResponsesImpl

use of org.wildfly.swarm.microprofile.openapi.api.models.responses.APIResponsesImpl in project wildfly-swarm by wildfly-swarm.

the class OpenApiAnnotationScanner method readCallbackOperationResponses.

/**
 * Reads an array of APIResponse annotations into an {@link APIResponses} model.
 * @param value
 */
private APIResponses readCallbackOperationResponses(AnnotationValue value) {
    if (value == null) {
        return null;
    }
    LOG.debug("Processing a list of @APIResponse annotations into an APIResponses model.");
    APIResponses responses = new APIResponsesImpl();
    AnnotationInstance[] nestedArray = value.asNestedArray();
    for (AnnotationInstance nested : nestedArray) {
        String responseCode = JandexUtil.stringValue(nested, OpenApiConstants.PROP_RESPONSE_CODE);
        if (responseCode != null) {
            responses.put(responseCode, readResponse(nested));
        }
    }
    return responses;
}
Also used : APIResponsesImpl(org.wildfly.swarm.microprofile.openapi.api.models.responses.APIResponsesImpl) APIResponses(org.eclipse.microprofile.openapi.models.responses.APIResponses) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Aggregations

APIResponsesImpl (org.wildfly.swarm.microprofile.openapi.api.models.responses.APIResponsesImpl)2 APIResponses (org.eclipse.microprofile.openapi.models.responses.APIResponses)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1