【发布时间】:2021-03-10 18:32:46
【问题描述】:
我目前正在使用 Swagger 解析器并制作一个应用程序来解析 swagger 文件并通过发送 HTTP 请求来尝试给定的端点,并将状态代码与 swagger 文件进行比较。
而且我在找到对端点进行排序的适当算法时遇到了问题。例如,我想确保创建对象的 POST 请求在需要来自先前 POST 请求的 id 参数的端点之前得到处理。
swagger-file 下面的顺序是正确的,但它会是未排序的文件,然后我需要某种算法..
"paths": {
"/pets": {
"post": {
"summary": "Create a pet",
"operationId": "createPets",
"tags": [
"pets"
],
"responses": {
"201": {
"description": "Null response"
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
},
"/pets/{petId}": {
"get": {
"summary": "Info for a specific pet",
"operationId": "showPetById",
"tags": [
"pets"
],
"parameters": [
{
"name": "petId",
"in": "path",
"required": true,
"description": "The id of the pet to retrieve",
"type": "string"
}
],
"responses": {
"200": {
"description": "Expected response to a valid request",
"schema": {
"$ref": "#/definitions/Pets"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/Error"
}
}
}
}
}
}
所以我很乐意为算法或如何排序的信息提供指导。
非常感谢您的关注和参与。
【问题讨论】:
标签: swagger openapi swagger-2.0