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