最近我写了RESTful API中有用SpringMVC和招摇的UI(V2)。今天,我只注意到按钮导入的postman.And我点击它,我在上面刚才看到的评论 “导入邮差收集,环境,数据转储,curl命令,或肾错构瘤/ WADL /扬鞭(V1/V2)/ Runscope文件。” 如何招摇的API导出到邮递员
起初我gooled,但没有答案满足我的情况。
所以我的问题是如何创建邮递员需要的文件。顺便说一下,我不熟悉招摇。
最近我写了RESTful API中有用SpringMVC和招摇的UI(V2)。今天,我只注意到按钮导入的postman.And我点击它,我在上面刚才看到的评论 “导入邮差收集,环境,数据转储,curl命令,或肾错构瘤/ WADL /扬鞭(V1/V2)/ Runscope文件。” 如何招摇的API导出到邮递员
起初我gooled,但没有答案满足我的情况。
所以我的问题是如何创建邮递员需要的文件。顺便说一下,我不熟悉招摇。
我使用PHP并使用Swagger 2.0来记录API。 Swagger文档是即时创建的(至少这是我在PHP中使用的)。该文档以JSON格式生成。
样品文件
{
"swagger": "2.0",
"info": {
"title": "Company Admin Panel",
"description": "Converting the Magento code into core PHP and RESTful APIs for increasing the performance of the website.",
"contact": {
"email": "[email protected]"
},
"version": "1.0.0"
},
"host": "localhost/cv_admin/api",
"schemes": [
"http"
],
"paths": {
"/getCustomerByEmail.php": {
"post": {
"summary": "List the details of customer by the email.",
"consumes": [
"string",
"application/json",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "email",
"in": "body",
"description": "Customer email to ge the data",
"required": true,
"schema": {
"properties": {
"id": {
"properties": {
"abc": {
"properties": {
"inner_abc": {
"type": "number",
"default": 1,
"example": 123
}
},
"type": "object"
},
"xyz": {
"type": "string",
"default": "xyz default value",
"example": "xyz example value"
}
},
"type": "object"
}
}
}
}
],
"responses": {
"200": {
"description": "Details of the customer"
},
"400": {
"description": "Email required"
},
"404": {
"description": "Customer does not exist"
},
"default": {
"description": "an \"unexpected\" error"
}
}
}
},
"/getCustomerById.php": {
"get": {
"summary": "List the details of customer by the ID",
"parameters": [
{
"name": "id",
"in": "query",
"description": "Customer ID to get the data",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "Details of the customer"
},
"400": {
"description": "ID required"
},
"404": {
"description": "Customer does not exist"
},
"default": {
"description": "an \"unexpected\" error"
}
}
}
},
"/getShipmentById.php": {
"get": {
"summary": "List the details of shipment by the ID",
"parameters": [
{
"name": "id",
"in": "query",
"description": "Shipment ID to get the data",
"required": true,
"type": "integer"
}
],
"responses": {
"200": {
"description": "Details of the shipment"
},
"404": {
"description": "Shipment does not exist"
},
"400": {
"description": "ID required"
},
"default": {
"description": "an \"unexpected\" error"
}
}
}
}
},
"definitions": {
}
}
这可以导入到邮差如下。
您还可以使用 '导入来源链接'。这里粘贴从Swagger或任何其他API文档工具生成API的JSON格式的URL。
这是我的文档(JSON)生成文件。它在PHP中。我不知道JAVA和Swagger。
<?php
require("vendor/autoload.php");
$swagger = \Swagger\scan('path_of_the_directory_to_scan');
header('Content-Type: application/json');
echo $swagger;
你也可以在线获取一些示例swagger文件来验证这一点(如果你在swagger doc中有错误)。
来显示您在此答案中描述的邮递员中导入的JSON我如何导出swagger.yaml?我在SpringMvc中使用swagger-ui。 –
你想从哪里出口?你是否已经在使用Swagger来创作你的YAML? –
谢谢,但现在的问题是我怎么能从swagger-ui中导出文件?而且链接是无用的。 –
@DemonColdmist我已经添加了代码来生成API。基本上,它扫描整个目录,检查注释并生成JSON/YAML输出。对不起,但我没有用JAVA的Swagger。 – JDpawar
谢谢,如果它可以在PHP中导出,那么Java也是如此。我将把它翻译成Java。 –