fastify - 不支持 Fastify 所需的路由参数
问题描述
我有一条这样的路线:
// collection GET
fastify.route({
method: 'GET',
url: `${constants.EXTERNAL_PATH}/:serviceName/:collectionName/account/:accountId`,
schema: {
description: 'Get all documents from the specified table for the specified service database and account.',
summary: 'Get all documents from the specified table.',
tags: ['persistence'],
headers: {
$ref: 'authorization-user#'
},
params:{
type: 'object',
properties: {
serviceName: { type: 'string' },
collectionName: { type: 'string' },
accountId: { type: 'string' }
},
required: ['serviceName', 'collectionName', 'accountId'],
},
response: {
200: {
properties: {
'documents': {
description: 'All the retrieved documents from the specified table for the specified service database and account.',
type: 'array',
items: {
$ref: 'persistence-response-doc#',
}
},
},
},
'4xx': {
$ref: 'error-response#',
description: 'Error response'
}
}
},
handler: async (request, reply) => {
// Logic goes here //
}
});
现在我的期望是:
这应该有效:
http://localhost:9011/persistence/external/myservice/mycollection/account/my_actn_id
As it has the service as myservice, collection as mycollection and accountId as my_actn_id
但是,这应该会因路由错误而失败(例如,当我缺少必需的 :accountId时):
http://localhost:9011/persistence/external/myservice/mycollection/account/ <== should fail
然而,两者都通过了,返回相同的收集结果。
我在这里想念什么?
谢谢, 普拉迪普
解决方案
推荐阅读
- clickhouse - 如何在 ClickHouse 中获取 FLAG 的值
- winapi - EnumProcessModules 返回 0 错误 299
- powershell - Find-Package 没有 -ScriptSourceLocation 参数
- azure - 使用 CopyIndex() 在 Azure ARM 模板中创建输出
- java - Bukkit/Spigot。当我输入命令时,它只返回命令
- c# - 如何在c#中测试字符串数组中的每个值?
- netsuite - 客户端脚本 - 字段更改事件 - 正文字段复选框 - 设置子列表值仅更改一行
- c - 如何使用微控制器检测键盘矩阵中开关的释放?
- bootstrap-4 - 引导列表-组-项目显示
- csv - 从 .csv 创建 .jsonl 文件