swagger键用不同的参数复制并返回

vktxenjb  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(258)

我正在编辑我的swagger yalm,我试图声明两个具有相同路径和不同参数的端点并返回。但是编辑器显示错误:“key'get'是重复的”
我可以使用spring requestmapping这样做:

@RequestMapping(value="/hello" params= param1)
public ReturnType method(@RequestParam("param1") p) { ... }

@RequestMapping(value="/hello" params= param2)
public DifferentReturnType method2(@RequestParam("param2") p) { ... }

因此,要处理第一个请求url:http://etc.com/hello?param1=x 第二个呢http://etc.com/hello?param2=y.
@requestmapping docs的params部分:https://docs.spring.io/spring-framework/docs/4.0.5.release/javadoc-api/org/springframework/web/bind/annotation/requestmapping.html#params--
但我不能这样 swagger 地说:

/hello:
    get:
      tags:
        - tag
      summary: list of entity
      operationId: method
      produces:
        - application/json
      parameters:
        - name: param1
          in: query
          required: false
          type: string
      responses:
        '200':
          description: Success
          schema:
            $ref: '#/definitions/returnType'

    get:
      tags:
        - tag
      summary: list of entity2
      operationId: method2
      produces:
        - application/json
      parameters:
        - name: param2
          in: query
          required: false
          type: string
      responses:
        '200':
          description: Success
          schema:
            $ref: '#/definitions/differentReturnType'

有办法吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题