【发布时间】:2018-04-28 07:16:28
【问题描述】:
我想定义请求和响应模型。我将无服务器框架与 AWS 一起使用,我看到的所有内容都建议使用 serverless-aws-documentation
自述文件说我需要在custom.documentation.models.MODELNAME 中有这一行
schema: ${file(models/error.json)}
但他们没有models/error.json 的示例文件可用作基线。
在实际示例中serverless.yml 他们有这样的定义:
-
name: DoSomethingRequest
contentType: "application/json"
schema:
type: array
items:
type: string
这没有为我正在尝试做的事情提供足够的细节。
我的目标是为字符串对象数组、消息和状态码定义一个模式。但是,消息和状态代码是可选的。这些也可能是其他模型的一部分,如果可能的话,我不想对每个模型重复它们的定义。
我目前的尝试是:
-
name: ReturnArrayResponse
contentType: "application/json"
schema:
type: array
itemsArray:
type: string
message:
type: string
statusCode:
type: number
我认为这会做我想做的事,但我怎么能有 message 和 statusCode 是可选的,并在我的其他模型中重复这两个项目?
我对可以放入 serverless.yml 文件中的 yml 解决方案或可以引用的 json 文件感到满意。
【问题讨论】:
标签: amazon-web-services aws-api-gateway serverless-framework serverless-plugins