如何在 Swagger 2.0 中对多个参数进行分组? [英] How to group multiple parameters in Swagger 2.0?
本文介绍了如何在 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 或 OpenAPI 3.0 中是不可能的.我已经为此打开了一个功能请求,并建议在未来的版本中使用:
This is not possible with Swagger 2.0 or OpenAPI 3.0. I've opened a feature request for this and it is proposed for a future version:
https://github.com/OAI/OpenAPI-Specification/issues/445
这篇关于如何在 Swagger 2.0 中对多个参数进行分组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文