生成的Json不完整API不会出现。有人能查一下吗
使用此代码:生成的Json不完整API不会出现。有人能查一下吗,json,swagger,Json,Swagger,使用此代码: @Path("/dbresource") @Api(value = "Available_Connections", description = "List of available DB connections to generate the report", position = 1) public class DbConnectionResource { private static final Logger log = Logger .ge
@Path("/dbresource")
@Api(value = "Available_Connections", description = "List of available DB connections to generate the report", position = 1)
public class DbConnectionResource {
private static final Logger log = Logger
.getLogger(DbConnectionResource.class);
public ConnectionProperties m_objConnProperties = new ConnectionProperties();
private List<ConnectionProperties> m_listOfTempProperties = new ArrayList<ConnectionProperties>();
private List<String> m_dbResources = new ArrayList();
private JDBCConnectionFactory m_objConnFactory = new JDBCConnectionFactory();
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Available connection details.",
notes = "List all Possible connections with the default one",
position = 1,
httpMethod = "GET",
produces = "application/json"
)
@ApiResponses( value={
@ApiResponse(code = 200, message = "Successfully retrieved."),
@ApiResponse(code = 401, message = "Unable to generate Report due to incorrect mapping between DB and template")
})
private Response getAvailableDBResources() {
try {
JAXBContext jaxbContext = JAXBContext
.newInstance(JDBCConnectionFactory.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
m_objConnFactory = (JDBCConnectionFactory) jaxbUnmarshaller
.unmarshal(getClass().getClassLoader().getResourceAsStream(
"JdbcConnections.xml"));
m_listOfTempProperties = m_objConnFactory.getConnections()
.getConnection();
System.out.println(m_listOfTempProperties.size());
for (ConnectionProperties cpt : m_listOfTempProperties) {
m_dbResources.add(cpt.getConnectionname());
System.out.println("all conn"+cpt.getConnectionname());
}
} catch (Exception e) {
System.out.println("inside jaxb exp");
log.debug("inside exception jaxb " + e.getMessage(), e);
return Response.status(401).build();
}
Gson gson = new Gson();
gson.toJson(m_dbResources);
return Response.ok(gson).build();
}
}
“我的资源”的文档在哪里?您似乎正在使用生成swagger 1.2定义的较旧版本的swagger core。在这种情况下,输出实际上是正常的 您可以在
/api docs/available\u Connections
下找到资源文档。这就是斯威格1.2的结构
如果升级到最新的swagger core,您将在一个文件中获得swagger 2.0和整个定义。很抱歉,我无法参与您的问题,但我忍不住注意到浏览器选项卡中的“swagger”一词;怎么会?这个“招摇过市”是从哪里来的?!请提供更多关于您正在做什么、您希望看到什么以及您实际看到什么的结构化信息。我通过将私有方法转换为公共方法对其进行了更正。。无论如何,谢谢你的回复。。
{
"apiVersion" : "1.1",
"swaggerVersion" : "1.2",
"basePath" : "http://localhost:8090/report-service",
"resourcePath" : "/Avalable_Connections"
}