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

查看:18
本文介绍了如何在 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天全站免登陆