我已经使用 Java 项目的 pom 文件中的以下工件安装了 swagger-ui:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<version>1.5.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我访问此 URL 时,我可以查看 RESTful 端点的 swagger ui
http://localhost:8081/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
Run Code Online (Sandbox Code Playgroud)
但不是这个链接
http://localhost:8081/swagger-ui/index.html
Run Code Online (Sandbox Code Playgroud)
为什么是这样?如何将其改回预期的 URL?
我是 dropwizard 的新手。我正在使用 dropwizard 的 0.8.5 版。我有一个 dropwizard REST 服务,它在调用成功时返回 JSON,在调用不成功时返回 HTTL,例如 HTTP 状态代码 500 或 404。
幸福之路
LOGGER.info("Cached userinfo for '{}'",username);
JSONObject json = new JSONObject();
json.put("ticketId",created.getTicketId());
json.put("token", token);
return Response.ok(json.toString()).build();
Run Code Online (Sandbox Code Playgroud)
不幸的道路
if (created.getTicketId() == null) {
LOGGER.error("Email not sent, ticket not created");
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).type(MediaType.APPLICATION_JSON).build();
}
Run Code Online (Sandbox Code Playgroud)
这是卷曲:
curl -H "Content-Type: application/json" -X POST -d '{"username":"WPf3s0G1M"}' http://localhost:7777/ids-rest-api/password/reset
Run Code Online (Sandbox Code Playgroud)
这是那个 curl 的回复,我想要 JSON 格式的回复:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 500 Request failed.</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /ids-rest-api/password/reset. Reason: …Run Code Online (Sandbox Code Playgroud)