use of org.wso2.carbon.apimgt.rest.api.publisher.v1.dto.AsyncAPISpecificationValidationResponseInfoDTO in project carbon-apimgt by wso2.
the class APIMappingUtil method getAsyncAPISpecificationValidationResponseFromModel.
public static AsyncAPISpecificationValidationResponseDTO getAsyncAPISpecificationValidationResponseFromModel(APIDefinitionValidationResponse model, boolean returnContent) throws APIManagementException {
AsyncAPISpecificationValidationResponseDTO responseDTO = new AsyncAPISpecificationValidationResponseDTO();
responseDTO.setIsValid(model.isValid());
if (model.isValid()) {
APIDefinitionValidationResponse.Info modelInfo = model.getInfo();
if (modelInfo != null) {
AsyncAPISpecificationValidationResponseInfoDTO infoDTO = new AsyncAPISpecificationValidationResponseInfoDTO();
infoDTO.setAsyncAPIVersion(modelInfo.getOpenAPIVersion());
infoDTO.setName(modelInfo.getName());
infoDTO.setVersion(modelInfo.getVersion());
infoDTO.setContext(modelInfo.getContext());
infoDTO.setDescription(modelInfo.getDescription());
infoDTO.setEndpoints(modelInfo.getEndpoints());
infoDTO.setProtocol(model.getProtocol());
Map<String, APIDefinition> apiDefinitionMap = APIUtil.getApiDefinitionParsersMap();
apiDefinitionMap.remove(APIConstants.WSO2_GATEWAY_ENVIRONMENT);
if (!apiDefinitionMap.isEmpty()) {
for (Map.Entry<String, APIDefinition> apiDefinitionEntry : apiDefinitionMap.entrySet()) {
APIDefinition apiParser = apiDefinitionEntry.getValue();
String gatewayVendor = apiParser.getVendorFromExtension(model.getContent());
if (gatewayVendor != null) {
infoDTO.setGatewayVendor(gatewayVendor);
break;
}
}
infoDTO.asyncTransportProtocols(AsyncApiParser.getTransportProtocolsForAsyncAPI(model.getContent()));
}
// Set default value
if (infoDTO.getGatewayVendor() == null) {
infoDTO.setGatewayVendor(APIConstants.WSO2_GATEWAY_ENVIRONMENT);
}
responseDTO.setInfo(infoDTO);
}
if (returnContent) {
responseDTO.setContent(model.getContent());
}
} else {
responseDTO.setErrors(getErrorListItemsDTOsFromErrorHandlers(model.getErrorItems()));
}
return responseDTO;
}
Aggregations