【发布时间】:2020-05-29 22:17:16
【问题描述】:
我是 loopback 4 的新手,我真的很难处理一些时间不是最新的文档。我成功添加了身份验证系统和登录用户的路线。我的问题出在“/explorer”网址上,我不知道如何在自定义路由的请求正文架构上添加示例值。
有我的路线:
@post('/users/login', {
responses: {
'200': {
description: 'Token',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
token: {
type: 'string'
}
}
}
}
}
}
}
})
async login(
@requestBody() credentials: Credentials,
): Promise<{token: string}> {
// make sure user exist,password should be valid
const user = await this.userService.verifyCredentials(credentials);
// console.log(user);
const userProfile = await this.userService.convertToUserProfile(user);
// console.log(userProfile);
const token = await this.jwtService.generateToken(userProfile);
return Promise.resolve({token: token})
}
我想补充一点:
{
"username": "string",
"password": "string"
}
我想有一种简单的方法可以做到这一点,但我真的找不到任何相关信息。
【问题讨论】:
标签: routes openapi strongloop loopback4