如何在Swagger 2.0中对多个参数进行分组? [英] How to group multiple parameters in Swagger 2.0?

查看:1955
本文介绍了如何在Swagger 2.0中对多个参数进行分组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以对多个参数进行分组以在多个路径中引用它们?

Is it possible to group multiple parameters to reference them in multiple routes?

例如,我有每条路线需要的参数组合.它们被定义为全局参数.如何将它们分组?

For example I have a combination of parameters which I need in every route. They are defined as global parameters. How can I group them?

我考虑这样的定义:

parameters:
  MetaDataParameters:
    # Meta Data Properties
    - name: id
      in: query
      description: Entry identification number
      required: false
      type: integer

    - name: time_start
      in: query
      description: Start time of flare
      required: false
      type: string

    - name: nar
      in: query
      description: Active region number
      required: false
      type: string

然后引用我的路线中的整个小组:

And then reference the whole group in my route:

/test/:
  get:
    tags:
      - TEST
    operationId: routes.test
    parameters:
      - $ref: "#/parameters/MetaDataParameters"
    responses:
        200:
          description: OK

Swagger 2.0有可能吗?

Is this possible with Swagger 2.0?

推荐答案

目前Swagger(2.0版)无法做到这一点.我已经为此打开了功能请求,并建议将其用于下一个版本:

This is not possible with Swagger at the moment (version 2.0). I've opened a feature request for this and it is proposed for the next version:

https://github.com/swagger-api/swagger-spec/issues/445

这篇关于如何在Swagger 2.0中对多个参数进行分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆