i have a request:
@Get('getClients1')
async getClients1(@Req() req:Request) {
const s=req.query.s;
const builder = await this.service.queryBuilder('user');
if (s) {
builder.where(
'user.name LIKE :s OR user.surname LIKE :s',
{ s: `%${s}%` },
);
}
const clients = await builder.getMany();
return {
data: users,
};
he works. I'm trying to run it through a swager, it doesn't work.
I add:
@ApiParam({
name: 'search',
required: false,
description: 'Строка для поиска по текстовым полям модели по ilike %search% \n (name,surname,patronymic,typeEducation)',
type: String
})
and @param
@Get('getClients1')
async getClients1(@Param('search') s: string)
but nothing comes. [enter image description here][1]
why is the parameter not passed? and how can this be fixed? [1]: https://i.stack.imgur.com/AEzCd.png
You need to use @ApiQuery()
not @ApiParam()
. It's the difference of a query parameter ( someUrl/?q=some+search+thing
) vs a url parameter ( someUrl/url/parameters
). Also, use @Query()
instead of @Param()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.