如何在OpenAPI(Swagger)中为同一路径定义不同的查询参数? [英] How to define different query parameters for same path in OpenAPI (Swagger)?

查看:507
本文介绍了如何在OpenAPI(Swagger)中为同一路径定义不同的查询参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Swagger Codegen启动REST服务.对于不同的参数,我需要有不同的响应.

I am starting a REST service, using Swagger Codegen. I need to have different responses for different parameters.

示例:<baseURL>/path可以使用?filter1=?filter2=,并且这些参数应该产生不同的响应消息.

Example: <baseURL>/path can use ?filter1= or ?filter2=, and these parameters should produce different response messages.

我希望我的OpenAPI YAML文件分别记录这两个查询参数.这可能吗?

I want my OpenAPI YAML file to document these two query params separately. Is this possible?

推荐答案

2.0规范也不支持3.0规范.

It is not supported in the 2.0 spec, and not in 3.0 either.

以下是OpenAPI规范存储库中的相应建议:
通过允许路径中的查询参数来容纳旧版API
路径规范中的查询字符串

Here are the corresponding proposals in the OpenAPI Specification repository:
Accommodate legacy APIs by allowing query parameters in the path
Querystring in Path Specification

这篇关于如何在OpenAPI(Swagger)中为同一路径定义不同的查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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