问题描述
问题如下:
我旨在使用Serverless框架和open API API插件插件来记录AWS无服务器API。
我面临的问题是在 serverless.ts 文件上创建的 Serverless 配置没有文档字段,它只有以下定义:
interface Http {
path: string;
method: string;
cors?: boolean | HttpCors;
private?: boolean;
async?: boolean;
authorizer?: HttpAuthorizer;
request?: HttpRequestValidation;
}
重现此问题的步骤:
-
使用 Typescript 模板创建无服务器项目:
$ sls create -t aws-nodejs-typescript --path testName -n appName
-
添加openapi插件
plugins: ['serverless-webpack','serverless-openapi-documentation'],
-
使用以下命令替换 serverless.ts 上的功能部分:
functions: { hello: { handler: 'handler.hello',events: [ { http: { method: 'get',path: 'hello',documentation: { summary: "Create something" },} } ] } }
在 documentation 行上的错误如下:
输入'{http:{method:string;路径:字符串; };文档:{摘要:字符串; }; }”不可分配给“事件”类型。 对象文字只能指定已知的属性,而'文档'在'事件'类型中不存在。
但是,如果我们不使用打字稿模板(即:aws-nodejs-typescript),而使用yml模板(即:aws-python),则可以添加文档密钥,并且开放的API插件可以正常工作。
这是否意味着Open API插件尚不支持Typescript?还是我缺少任何配置?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)