创建一个Swagger 2.0,为主体或查询参数提供硬编码值?

lvmkulzt  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(71)
/test:
    post:
      consumes:
        - "application/json"
      parameters:
        - in: "body"
          name: "TestEntity"
          schema:
            $ref: "#/definitions/TestEntity"
      produces:
        - "application/json"
      responses:
        200:
          description: "200 response"
          schema:
            $ref: "#/definitions/TestEntity"
  /user/login:
    get:
      produces:
      - "application/json"
      parameters:
      - name: "username"
        in: "query"
        default: 'John Smith'
        required: true
        type: "string"

definitions:
 TestEntity:
    properties:
      address:
        type: string
        default: '1 street'
    required:
      - address

字符串
嗨,我已经得到了这个Swagger 2.0配置的路径和TestEntity的定义。
地址/用户名属性的值可以显式硬编码吗?除非使用default选项
我的意思是用户不能指定这个值,它应该由Swagger自己设置。

iszxjhcz

iszxjhcz1#

地址/用户名属性的值可以显式硬编码吗?
不,你不能硬编码swagger中定义的模式的值。你的选择是:

是否可以通过使用默认选项对标头的值进行硬编码?
是的,这样做是可以的。例如,

/user/login:
    get:
      parameters:
      - name: MyHeader
        in: header
        type: string
        default: 'some value'

字符串

相关问题