我有一个无服务器文档插件在YAML中编写的AWS无服务器API定义。
它是这样表达的:
startCreatingItem:
handler: index.startCreatingItem
description: Request a new item
events:
- http:
path: items
method: post
cors: true
private: true
reqValidatorName: 'xMyRequestValidator'
documentation: ${file(./documentation/items/startCreatingItem.yml)}
summary: "Request a new item"
description: "Item information creation"
tags:
-Items
requestBody:
description: Item to be generated
requestModels:
"application/json": "ItemInfo"
methodResponses:
-
statusCode: "200"
description: "Item creation added"
responseModels:
"application/json": "ItemInfo"
{
"type": "object",
"description": "Model representing the item information",
"required": [ "results" ],
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The item identifier"
},
"results": {
"type": "array",
"description": "A list of result identifier to include in the item",
"items": {
"type": "string",
"format": "uuid"
}
},
}
}
我想为对象ItemInfo添加一个请求模型示例,因此它出现在Swagger页面中(开发人员可以在此页面中直接尝试一些操作)。 例如,我在serverless.yml文件中想到了这样的东西:
startCreatingItem:
handler: index.startCreatingItem
description: Request a new item
events:
- http:
path: items
method: post
cors: true
private: true
reqValidatorName: 'xMyRequestValidator'
documentation: ${file(./documentation/items/startCreatingItem.yml)}
example : {
results: [
006897b5-e3fc-4358-8c27-cd54dfd53d49,
769e1c03-9136-465b-93ad-90d889245557
]
}
(但这似乎显然不起作用)。
如果您有任何疑问或意见,我们将很乐意为您解答:) 预先感谢您的帮助!