I'm new with loopback 4 and I really have difficulty with the documentation that is some time not up to date. I succeed to add an authentification system and a route to log in to the users. My problem is on the "/explorer" URL, I don't know how can I add example value on the request body schema of a custom route.
There is my route:
@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})
}
And I wish to add:
{
"username": "string",
"password": "string"
}
I suppose that there is a simple way to do it but I really can't find anything about it.