我正在使用在线Swagger Editor为我的API创建一个Swagger规范 .
我的API有一个GET请求 endpoints ,我使用以下YAML代码来描述输入参数:
paths:
/fooBar:
get:
tags:
- foobar
summary: ''
description: ''
operationId: foobar
consumes:
- application/x-www-form-urlencoded
produces:
- application/json
parameters:
- name: address
in: query
description: Address to be foobared
required: true
type: string
example: 123, FakeStreet
- name: city
in: query
description: City of the Address
required: true
type: string
example: New York
如果我输入 example
标签,我会收到一条错误消息:
不是<#/ definitions / parameter>,<#/ definitions / jsonReference>中的一个
如何在Swagger中编写GET参数时设置示例?
1 回答
OpenAPI / Swagger 2.0没有非身体参数的
example
关键字 . 您可以在参数description
中指定示例 . 一些工具,如Swagger UI v2,v3.12和Dredd也支持x-example
扩展属性用于此目的:OpenAPI 3.0本身支持参数示例: