If I use the url in my browser - http://vdijava:8080/AwgFacilityApi/facility/getByCode?codes=00
I get the following expected response -
[{"code":"00","address":{"street":"5000 KANSAS AVE
","city":"KANSAS CITY ","stateAbbreviation":"KS","state":"KANSAS
","zipCode":"66106","zipPlusCode":"1135"},"name":"KANSAS CITY
","oneLetterCode":"K","twoLetterCode":"KC","divisionNumberCode":"00","vmFlag":false,"corporateName":"ASSOCIATED
WHOLESALE GROCERS, INC. ","retailVmFlag":false,"militaryFlag":false}]
But if I use -
http://vdijava:8080/AwgFacilityApi/facility/getByCode?codes=00,01
I get no response because the value received in the FacilityApiServiceImpl get
a List<String> codes of ["00,01"] instead of ["00", "01"].
I have attached the yaml and the FacilityApiServiceImpl class.
What am I doing wrong in the yaml?
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
swagger.yaml
Description: Binary data
package io.swagger.api.impl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.StringUtils;
import io.swagger.api.FacilityApiService;
import io.swagger.api.NotFoundException;
import io.swagger.model.Facilities;
public class FacilityApiServiceImpl extends FacilityApiService {
@Override
public Response getFacilityByCode(List<String> codes) throws NotFoundException {
System.out.println("Searching for: " + codes + " size=" + codes.size());
String user = "dvantage";
String password = "dvantage";
String database = "awgt1";
String schema = "db2pdba";
String host = "trhdb2";
int port = 60000;
String url = "jdbc:db2://" + host + ":" + port + "/" + database + ":currentSchema=" + schema.toUpperCase() + ";";
Connection connection = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Facilities list = null;
try {
Class.forName("com.ibm.db2.jcc.DB2Driver");
connection = DriverManager.getConnection(url, user, password);
String sql = "select fclty_cd"
+ ", fclty_ltr1_cd"
+ ", fclty_ltr2_cd"
+ ", fclty_nm"
+ ", dw_fclty_ltr2_cd"
+ ", fclty_strt_ad"
+ ", fclty_city_ad"
+ ", fclty_stt_cd"
+ ", fclty_stt_ds"
+ ", fclty_zip_cd"
+ ", fclty_zip_plus_cd"
+ ", dvsn_nmbr_cd"
+ ", vm_fl"
+ ", crprt_nm"
+ ", rtl_vm_fl"
+ ", fclty_mil_fl"
+ " from aim_fclty"
+ " where fclty_cd in (" + StringUtils.join(Collections.nCopies(codes.size(), "?"), ", ") + ")";
System.out.println(sql);
stmt = connection.prepareStatement(sql);
int index = 1;
for (String code : codes) {
System.out.println("Setting parm " + index + " to " + code);
stmt.setString(index++, code);
}
rs = stmt.executeQuery();
list = FacilityTranslator.getFacilites(rs);
} catch (java.sql.SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
return Response.ok().entity(list).build();
}
}
