我们正在记录应用程序中的所有 API,为此我们正在使用swagger UI
这是它的示例代码
exports.people = {
'spec':
{
path : "/people",
method: "POST",
summary : "Create new person",
notes : "Create new person",
nickname : "people",
parameters : [param.query("email", "email", "string", true),
param.query("firstName", "firstName", "string", true),
param.query("lastName", "lastName", "string", true)]
},
'action': function(req, res)
{
-----code----
}
}
它将请求 URL 生成为
http://localhost:8080/rest/api/people
所以它正在为人们生成路径,/people
但我们必须将其更改为“/create_people”,所以我们如何实现这个功能。
我们通过更改这里的“路径”来尝试这spec
是代码
exports.people = {
'spec':
{
path : "/create_people",
.....// rest of code
它正在工作,但它创建了不同的重定向网址,如下所示
http://localhost:8080/rest/api/create_people
这是错误的,我们只需要更改 API 名称而不是请求 URL。
这是图示。
我们正在使用swagger-ui和node.js