如何使用Swagger express在我的Swagger UI中添加数组和示例?
总而言之,我基本上是在这个“教程”的基础上制作一个大摇大摆的Ui: 不幸的是,它根本没有描述如何为主体添加示例以及如何添加数组 我现在拥有的文档代码是:如何使用Swagger express在我的Swagger UI中添加数组和示例?,express,swagger,swagger-ui,Express,Swagger,Swagger Ui,总而言之,我基本上是在这个“教程”的基础上制作一个大摇大摆的Ui: 不幸的是,它根本没有描述如何为主体添加示例以及如何添加数组 我现在拥有的文档代码是: /** * @swagger * path: /animal/dogs * operations: * - httpMethod: POST * summary: Add several dogs to the animal shelter * notes: Returns results of the post *
/**
* @swagger
* path: /animal/dogs
* operations:
* - httpMethod: POST
* summary: Add several dogs to the animal shelter
* notes: Returns results of the post
* responseClass: Shelter
* nickname : shelterPostWithDogs
* consumes:
* - application/json
* parameters:
* - name: body
* schema: true
* description: Dogs object that needs to be added
* paramType: body
* required: true
* dataType: Dog
*/
我在下面有:
/**
* @swagger
* models:
* Dog:
* id: Dog
* properties:
* dog_id:
* required: true
* type: int
* Shelter:
* id: Shelter
* properties:
* shelter_id:
* type: int
* location:
* type: string
*/
不幸的是,有了这个,我的模型中就有了这个:
Dog {
dog_id (int)
}
我想要的是:
Dog {
[
{ dog_id(int)}
]
}
我必须改变什么才能得到这个结果
奖励:如何向模型中添加示例?我想要类似于这个的东西:
不幸的是,我不知道如何在swagger express中执行此操作我对swagger express也很陌生,但我建议您在模型定义中必须使用类型作为“数组”:
Dog:
id: Dog
properties:
dog_id:
required: true
type: **array**
希望这对你有帮助
谢谢