swagger - OpenAPI 规范中数组和对象查询参数的 URL 示例?
问题描述
在 OpenAPI 规范中使用数组和对象查询参数时,我对 URL 的最终结果的外观感到困惑。我阅读了以下文档,但并没有让我完全理解:https ://swagger.io/docs/specification/describing-parameters/#query-parameters
基于(特别)以下查询参数的 URL 的两个示例是什么?
示例 1 - 数组
{
"/pet/findByStatus": {
"get": {
"parameters": [{
"in": "query",
"name": "test",
"description": "Pet object that needs to be added to the store",
"schema": {
"type": "array",
"items": {
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": ["available", "pending", "sold"]
}
}
}
}
}]
}
}
示例 2 - 对象
{
"/pet/findByStatus": {
"get": {
"parameters": [{
"in": "query",
"name": "test",
"description": "Pet object that needs to be added to the store",
"schema": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"name": {
"type": "string",
"example": "doggie"
},
"photoUrls": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
},
"status": {
"type": "string",
"description": "pet status in the store",
"enum": ["available", "pending", "sold"]
}
}
}
}]
}
}
谢谢!
解决方案
推荐阅读
- r - 使用 stat = 'identity' 为 gg barplot 添加计数标签
- java - 无法安装 Android Studio Wear Os 应用程序 INSTALL_PARSE_FAILED_NO_CERTIFICATES
- javascript - 构建数据结构拯救学生
- mysql - 以 json 格式计算 varchar 列中的字符
- reactjs - 设置反应状态的不同方式
- python - 通过 Django 中的模型
- java - 链表作业问题
- oracle - ALTER SESSION SET NLS_TERRITORY = "英国" 不起作用
- python - 如何计算行数以及如何从行中提取数字然后计算数字的平均值
- json - 从 DjangoRestFramework 中的 API 端点动态请求数据