java - how to export swagger apis into postman -


recently wrote restful apis springmvc , swagger-ui(v2).today, noticed button import above postman.and clicked it, saw comment "import postman collection, environment, data dump, curl command, or raml/wadl/swagger(v1/v2)/runscope file." enter image description here

at first had gooled, no answers satisfied situation.

so question how create file postman needed.by way,i not familiar swagger.

i work on php , have used swagger 2.0 document apis. swagger document created on fly (at least use in php). document generated in json format.

sample document

{     "swagger": "2.0",     "info": {     "title": "company admin panel",         "description": "converting magento code core php , restful apis increasing performance of website.",         "contact": {         "email": "jaydeep1012@gmail.com"         },         "version": "1.0.0"     },     "host": "localhost/cv_admin/api",     "schemes": [     "http" ],     "paths": {     "/getcustomerbyemail.php": {         "post": {             "summary": "list details of customer email.",                 "consumes": [                 "string",                 "application/json",                 "application/x-www-form-urlencoded"             ],                 "produces": [                 "application/json"             ],                 "parameters": [                     {                         "name": "email",                         "in": "body",                         "description": "customer email ge 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 customer"                     },                     "400": {                     "description": "email required"                     },                     "404": {                     "description": "customer not exist"                     },                     "default": {                     "description": "an \"unexpected\" error"                     }                 }             }         },         "/getcustomerbyid.php": {         "get": {             "summary": "list details of customer id",                 "parameters": [                     {                         "name": "id",                         "in": "query",                         "description": "customer id data",                         "required": true,                         "type": "integer"                     }                 ],                 "responses": {                 "200": {                     "description": "details of customer"                     },                     "400": {                     "description": "id required"                     },                     "404": {                     "description": "customer not exist"                     },                     "default": {                     "description": "an \"unexpected\" error"                     }                 }             }         },         "/getshipmentbyid.php": {         "get": {             "summary": "list details of shipment id",                 "parameters": [                     {                         "name": "id",                         "in": "query",                         "description": "shipment id data",                         "required": true,                         "type": "integer"                     }                 ],                 "responses": {                 "200": {                     "description": "details of shipment"                     },                     "404": {                     "description": "shipment not exist"                     },                     "400": {                     "description": "id required"                     },                     "default": {                     "description": "an \"unexpected\" error"                     }                 }             }         }     },     "definitions": {      } } 

this can imported postman follow.

  1. click on 'import' button in top left corner of postman ui.
  2. you see multiple options import api doc. click on 'paste raw text'.
  3. paste json format in text area , click import.
  4. you see apis 'postman collection' , can use postman.

importing json postman

imported apis

you can use 'import link'. here paste url generates json format of apis swagger or other api document tool.

this document (json) generation file. it's in php. have no idea of java along swagger.

<?php require("vendor/autoload.php"); $swagger = \swagger\scan('path_of_the_directory_to_scan'); header('content-type: application/json'); echo $swagger; 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -