如何获得@ nest / swagger产生的示例?

时间:2019-04-23 09:18:29

标签: node.js swagger

我想获得localhost:3000/api产生的@nest/swagger上显示的示例值。

  • 控制器
@Post()
@ApiOperation({ title: 'Create One Tag' })
@ApiCreatedResponse({ description: 'Successfully created.'})
async create(@Body() tagDto: TagDto) {
    const result = await this.tagService.create(tagDto);
    return result;
}
  • SwaggerModule从控制器生成以下api
            "post": {
                "summary": "Create One Tag",
                "parameters": [
                    {
                        "name": "TagDto",
                        "required": true,
                        "in": "body",
                        "schema": {
                            "$ref": "#/definitions/TagDto"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Successfully created."
                    }
                },
                "tags": [
                    "Tags RESTful Service"
                ],
                "produces": [
                    "application/json"
                ],
                "consumes": [
                    "application/json"
                ]
            }
  • 网站上显示的示例值
{
  "name": "string",
  "type": "Sponsor",
  "org": 0
}

我希望SwaggerModule也可以在其中生成示例值,这可能吗?

0 个答案:

没有答案