Program: 114787
Project: 114787
Buggy source:
/** 
 * This method generates swagger v2 doc using swagger 1.2 doc
 * @param tenant            Tenant
 * @param swagger12location the location of swagger 1.2 doc
 * @return JSON string of swagger v2 doc
 * @throws java.net.MalformedURLException
 * @throws org.json.simple.parser.ParseException
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException
 */
private String getSwagger2docUsingSwagger12RegistryResources(Tenant tenant,String swagger12location,API api) throws MalformedURLException, ParseException, RegistryException, UserStoreException {
  log.debug("String_Node_Str");
  JSONParser parser=new JSONParser();
  Object rawResource=registryService.getGovernanceRegistryResource(swagger12location);
  String swaggerRes=ResourceUtil.getResourceContent(rawResource);
  JSONObject swagger12doc=(JSONObject)parser.parse(swaggerRes);
  Object existSecDef=swagger12doc.get(Constants.SECURITY_DEFINITION__KEY);
  if (existSecDef == null) {
    JSONObject existScopes=new JSONObject();
    JSONObject xWso2Security=(JSONObject)swagger12doc.get(Constants.SWAGGER_X_WSO2_SECURITY);
    if (xWso2Security == null) {
      log.info("String_Node_Str" + swagger12location + "String_Node_Str");
    }
 else {
      JSONArray scopes=(JSONArray)((JSONObject)xWso2Security.get(Constants.SWAGGER_OBJECT_NAME_APIM)).get(Constants.SWAGGER_X_WSO2_SCOPES);
      for (int i=0; i < scopes.size(); i++) {
        JSONObject scope=(JSONObject)scopes.get(i);
        existScopes.put(scope.get(Constants.SECURITY_DEFINITION_SCOPE_NAME),scope.get(Constants.SECURITY_DEFINITION_SCOPE_KEY));
      }
    }
    JSONObject sec=generateSecurityDefinitionsObject(api.getId().getApiName(),existScopes);
    swagger12doc.put(Constants.SECURITY_DEFINITION__KEY,sec);
  }
 else {
    log.info("String_Node_Str" + swagger12location);
  }
  JSONObject paths=(JSONObject)swagger12doc.get(Constants.SWAGGER_PATHS);
  Set<Map.Entry> res=paths.entrySet();
  for (  Map.Entry e : res) {
    JSONObject methods=(JSONObject)e.getValue();
    Set<Map.Entry> mes=methods.entrySet();
    for (    Map.Entry m : mes) {
      JSONObject re=(JSONObject)m.getValue();
      JSONObject xWso2Security=(JSONObject)swagger12doc.get(Constants.SWAGGER_X_WSO2_SECURITY);
      JSONArray scopes=new JSONArray();
      if (xWso2Security != null) {
        scopes=(JSONArray)((JSONObject)xWso2Security.get(Constants.SWAGGER_OBJECT_NAME_APIM)).get(Constants.SWAGGER_X_WSO2_SCOPES);
      }
      JSONArray scopeList=new JSONArray();
      for (int i=0; i < scopes.size(); i++) {
        JSONObject scope=(JSONObject)scopes.get(i);
        scopeList.add(scope.get(Constants.SECURITY_DEFINITION_SCOPE_NAME));
      }
      JSONArray authScopeArray=new JSONArray();
      JSONObject authScopeObj=new JSONObject();
      authScopeObj.put(api.getId().getApiName() + Constants.SECURITY_DEFINITION_NAME_KEY_SUFFIX,scopeList);
      authScopeArray.add(authScopeObj);
      re.put(Constants.SWAGGER_PATH_SECURITY_KEY,authScopeArray);
      re.put(Constants.SWAGGER_PATH_PARAMETERS_KEY,new JSONArray());
    }
  }
  return swagger12doc.toJSONString();
}

Fixed version (ground truth):
/** 
 * This method generates swagger v2 doc using swagger 1.2 doc
 * @param tenant            Tenant
 * @param swagger12location the location of swagger 1.2 doc
 * @return JSON string of swagger v2 doc
 * @throws java.net.MalformedURLException
 * @throws org.json.simple.parser.ParseException
 * @throws org.wso2.carbon.registry.core.exceptions.RegistryException
 */
private String getSwagger2docUsingSwagger12RegistryResources(Tenant tenant,String swagger12location,API api) throws MalformedURLException, ParseException, RegistryException, UserStoreException {
  log.debug("String_Node_Str");
  JSONParser parser=new JSONParser();
  Object rawResource=registryService.getGovernanceRegistryResource(swagger12location);
  if (rawResource == null) {
    return "String_Node_Str";
  }
  String swaggerRes=ResourceUtil.getResourceContent(rawResource);
  JSONObject swagger12doc=(JSONObject)parser.parse(swaggerRes);
  Object existSecDef=swagger12doc.get(Constants.SECURITY_DEFINITION__KEY);
  if (existSecDef == null) {
    JSONObject existScopes=new JSONObject();
    JSONObject xWso2Security=(JSONObject)swagger12doc.get(Constants.SWAGGER_X_WSO2_SECURITY);
    if (xWso2Security == null) {
      log.info("String_Node_Str" + swagger12location + "String_Node_Str");
    }
 else {
      JSONArray scopes=(JSONArray)((JSONObject)xWso2Security.get(Constants.SWAGGER_OBJECT_NAME_APIM)).get(Constants.SWAGGER_X_WSO2_SCOPES);
      for (int i=0; i < scopes.size(); i++) {
        JSONObject scope=(JSONObject)scopes.get(i);
        existScopes.put(scope.get(Constants.SECURITY_DEFINITION_SCOPE_NAME),scope.get(Constants.SECURITY_DEFINITION_SCOPE_KEY));
      }
    }
    JSONObject sec=generateSecurityDefinitionsObject(api.getId().getApiName(),existScopes);
    swagger12doc.put(Constants.SECURITY_DEFINITION__KEY,sec);
  }
 else {
    log.info("String_Node_Str" + swagger12location);
  }
  JSONObject paths=(JSONObject)swagger12doc.get(Constants.SWAGGER_PATHS);
  Set<Map.Entry> res=paths.entrySet();
  for (  Map.Entry e : res) {
    JSONObject methods=(JSONObject)e.getValue();
    Set<Map.Entry> mes=methods.entrySet();
    for (    Map.Entry m : mes) {
      JSONObject re=(JSONObject)m.getValue();
      JSONObject xWso2Security=(JSONObject)swagger12doc.get(Constants.SWAGGER_X_WSO2_SECURITY);
      JSONArray scopes=new JSONArray();
      if (xWso2Security != null) {
        scopes=(JSONArray)((JSONObject)xWso2Security.get(Constants.SWAGGER_OBJECT_NAME_APIM)).get(Constants.SWAGGER_X_WSO2_SCOPES);
      }
      JSONArray scopeList=new JSONArray();
      for (int i=0; i < scopes.size(); i++) {
        JSONObject scope=(JSONObject)scopes.get(i);
        scopeList.add(scope.get(Constants.SECURITY_DEFINITION_SCOPE_NAME));
      }
      JSONArray authScopeArray=new JSONArray();
      JSONObject authScopeObj=new JSONObject();
      authScopeObj.put(api.getId().getApiName() + Constants.SECURITY_DEFINITION_NAME_KEY_SUFFIX,scopeList);
      authScopeArray.add(authScopeObj);
      re.put(Constants.SWAGGER_PATH_SECURITY_KEY,authScopeArray);
      Object produceObj=re.get(Constants.SWAGGER_PRODUCES);
      if (produceObj != null && !(produceObj instanceof JSONArray)) {
        JSONArray prodArr=new JSONArray();
        prodArr.add((String)produceObj);
        re.put(Constants.SWAGGER_PRODUCES,prodArr);
      }
      JSONObject responses=(JSONObject)re.get(Constants.SWAGGER_RESPONSES);
      JSONObject response;
      Iterator itr=responses.keySet().iterator();
      while (itr.hasNext()) {
        String key=(String)itr.next();
        response=(JSONObject)responses.get(key);
        boolean isExist=response.containsKey(Constants.SWAGGER_DESCRIPTION);
        if (!isExist) {
          response.put(Constants.SWAGGER_DESCRIPTION,"String_Node_Str");
        }
      }
    }
  }
  return swagger12doc.toJSONString();
}