openapi - OpenAPI 规范 - 如何指定接受一系列值的输入参数
问题描述
使用 OpenAPI 3.0.3,我正在定义一个接受两个输入查询参数的 API 规范。
- name: land_area_llimit
in: query
description: Lower limit for land area comparison
required: false
schema:
type: integer
- name: land_area_ulimit
in: query
description: Upper limit for land area comparison
required: false
schema:
type: integer
理想情况下,我想将两者结合起来,并且只有一个参数,它接受一个范围,比如:
[a,b] where a > 0 and b > a > 0
。说,类似:
- name: land_area
in: query
description: lower and upper bounds for land area comparison
required: false
schema:
type: range
## With some way to specify that this parameter accepts a lower bound and an upper bound.
我知道minimum
and maximum
。这将预设范围。我正在寻找作为输入提供的范围。这可以实现吗?
解决方案
我最终使用了一种object
输入类型:
- name: land_area
in: query
description: Land area ranges for comparison (in sqft). lower_bound < upper_bound. Return 400 otherwise.
required: false
schema:
type: object
properties:
land_area_lower_bound:
type: integer
land_area_upper_bound:
type: integer
签入 Swagger UI,请求 URL 将解析为:
http://<url>/<api>?land_area_lower_bound=1234&land_area_upper_bound=3456
推荐阅读
- ios - 此应用程序包含一个应用程序扩展,其包标识符与另一个应用程序的包标识符冲突
- javascript - Sequelize sum, count, group by 或者我应该使用 sequelize.query 选项吗?
- php - CI 3.0.1 到 CI 3.1.9 升级时出错?
- shell - 如何在linux中查找文件B中的某些特定行并将其合并到另一个文件A,条件是文件B中的行可以增加或减少
- php - nodeList 的 print_r 不起作用
- gtk - GtkTreeIter 指针失败
- android - 即使设置正确的意图过滤器,也会出现“未找到默认活动”
- c# - LINQ IN where 查询
- angular - 为什么 RXJS angular behaviorSubject 发出多个值
- angular - 更新到 Angular 6 [WDS] 加载后在 IE 上断开连接