【发布时间】:2014-11-27 10:37:09
【问题描述】:
我正在尝试在模型描述中显示模型的枚举。 我的模型的模式在定义下定义并使用枚举作为操作属性,因为只允许这三种类型。 (见下面的代码)
我使用的是 swagger 2.0 版。在 1.2 版中,这似乎可行:http://petstore.swagger.wordnik.com/ 您可以在 store/order 下找到示例。 他们还使用枚举,它显示在模型视图中的属性后面。 新版本如何才能达到同样的效果?
感谢您的帮助!
"paths": {
"/event": {
"post": {
"tags": [
"event"
],
"summary": "Add an new Event.",
"description": "TEST",
"operationId": "addEvent",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "body",
"name": "data",
"description": "",
"required": true,
"schema": {
"$ref": "#/definitions/Event"
}
}
],
"responses": {
"405": {
"description": "Invalid input"
}
}
}
}
}
"definitions": {
"Event": {
"id": "eventModel",
"required": [
"action"
],
"properties": {
"action": {
"type": "string",
"default": "START",
"enum": [
"START",
"UPDATE",
"END"
],
"description": "blabla"
}
}
}
}
PS:我现在认识到的另一个错误是,显示的数组模型描述错过了右括号]。
【问题讨论】:
标签: enums swagger swagger-ui