python-3.x - 寻找通用 Swagger 解析器实用程序以在 python 中自动化
问题描述
python中是否有任何解析器可以自动解析像swagger编辑器中的swagger签名文件?
我的招摇文件:
{
"swagger": "2.0",
"info": {
"title": "Forum API",
"version": "7.0",
"description": "Description"
},
"schemes": [
"http",
"https"
],
"paths": {
"/auth/login": {
"post": {
"tags": [
"Authentication Service"
],
"summary": "Authenticates the logged in user",
"description": "",
"operationId": "login_1",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "UserLoginCredential model JSON",
"required": true,
"schema": {
"$ref": "#/definitions/getItemKey"
}
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/getItemKey"
}
}
}
}
},
"/auth/logout": {
"post": {
"tags": [
"Authentication Service"
],
"summary": "Ends the logged in user session",
"description": "",
"operationId": "logout_1",
"parameters": [],
"responses": {
"200": {
"description": "Logged Out"
},
"403": {
"description": "Forbidden"
}
}
}
},
"/do/some/work": {
"post": {
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/createUpdate_dscr_ctl_ind"
},
"examples": {
"application/json": { "ID": "20200214182800",
"Date": "Fri, 14 Feb 2020 18:28:05 GMT",
"dscr_ctl_ind": [
[ "dummy1", { "POSTED": true } ],
[ "dummy2", { "POSTED": true } ]
]
}
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/error-403-response"
},
"examples": {
"application/json": {
"errorType": "Authorization",
"errorMessage": "Invalid Access"
}
}
},
"400": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/error-response"
},
"examples": {
"application/json": {
"error":{
"code": "400",
"reason": "Syntax Error",
"message": "The HTTP request is corrupted or improperly formatted."
}
}
}
}
},
"summary": "createUpdate dataScreeningControl",
"operationId": "dataScreeningControl_1",
"description": "createUpdate ScreeningControl",
"tags": [
"dataScreeningControl"
],
"parameters": [
{
"in": "body",
"name": "body",
"required": true,
"schema": {
"$ref": "#/definitions/getItemKey"
}
}
]
}
},
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
},
"definitions": {
"SecurityPolicy": {
"type": "object",
"required": [
"policyId"
],
"properties": {
"daysForDeleting": {
"type": "integer",
"format": "int64",
"description": "Days for deleting"
},
"minimumPasswordLength": {
"type": "integer",
"format": "int64",
"description": "Minimum password length"
},
"passwordRules": {
"type": "string",
"description": "password Rules"
},
"minimumUpperCaseLength": {
"type": "integer",
"format": "int64",
"description": "Minimum upper case length"
},
"minimumLowerCaseLength": {
"type": "integer",
"format": "int64",
"description": "Minimum lower case length"
},
"daysPasswordUsageDisallowed": {
"type": "integer",
"format": "int64",
"description": "Days password usage disallowed"
},
"recyclingPolicy": {
"type": "integer",
"format": "int64",
"description": "Recycling policy",
"enum": [
1,
2,
3
]
}
}
},
"userRolePolicy": {
"type": "object",
"required": [
"policyId"
],
"UserObject": {
"type": "object",
"properties": {
"sessionId": {
"type": "string",
"description": "Unique Session Identifier"
},
"orgAccountId": {
"type": "integer",
"format": "int64",
"description": "Organization Account Identifier"
},
"accountId": {
"type": "integer",
"format": "int64",
"description": "Account number of user"
}
},
"description": "Logged in user Details"
},
"UserLoginCredential": {
"type": "object",
"required": [
"password",
"userName"
],
"properties": {
"userName": {
"type": "string",
"description": "Name of the user"
},
"password": {
"type": "string",
"description": "Password associated with the User"
}
},
"description": "UserLoginCredential Details"
},
"required": [
"ATTRIBUTES",
"npa"
]
},
"getItemKey": {
"type": "object",
"title": "getItemKey config",
"description": "getItemKey Config",
"properties": {
"ID": {
"type": "string",
"example": "20200214182800"
},
"Date": {
"type": "string",
"example": "Fri, 14 Feb 2020 18:28:05 GMT"
}
}
},
"getQuery_line": {
"type": "object",
"title": "getQuery Line Number Config",
"description": "getQuery Number Config",
"properties": {
"ID": {
"type": "string",
"example": "20200214182800"
},
"Date": {
"type": "string",
"example": "Fri, 14 Feb 2020 18:28:05 GMT"
},
"line": {
"type": "array",
"items":
{
"type": "string"
},
example:
[ "7815551212", "7815551111", "7815551225" ]
}
}
},
"error-403-response": {
"type": "object",
"title": "Error Response Details",
"description": "Error Response Details",
"properties": {
"errorType": {
"type": "string",
"description": "Text that explains the reason for error."
},
"errorMessage": {
"type": "string",
"description": "Text that provide more details and corrective actions related to the error"
}
},
"required": [
"errorType",
"errorMessage"
]
}
},
"tags": [
{
"name": "dataAuthentication"
},
{
"name": "dataScreeningProfile"
},
{
"name": "thresholdThr_Itvs"
},
{
"name": "calledNumberBlock"
}
],
"host": "www.telus.com"
}
我想自动化上面的招摇文件以将整个文档解析为某个文件然后使用它
解决方案
推荐阅读
- delphi - DELPHI 10.3社区版在哪里可以添加常用库路径
- javascript - (react+dva+antd) extract-text-webpack-plugin 出错
- java - 使用 jsonpath 保留部分 JSON
- d3.js - 交叉过滤器维度不呈现计数
- c# - 如何在 botframework v4 中重新提示?
- php - 当我使用这个 php 时,结果显示所有表而不是 table1.id = table2.id 的特定条件
- python - 仅在 python 中的 pafy 和 vlc 音频
- kernel - 即使重新安装后,旧内核也会在 jupyter 中重新出现
- amazon-ec2 - 在亚马逊 ec2 实例中启动后更改 ip 的方法
- java - 如何正确加密合并的pdf文档