diff --git a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/dereferenced-with-tags-output.json b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/dereferenced-with-tags-output.json index 766e8ce6e8..9747894553 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/dereferenced-with-tags-output.json +++ b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/dereferenced-with-tags-output.json @@ -1,35 +1,35 @@ { - "_type": "export", + "__export_date": "2019-11-22T18:54:59.926Z", "__export_format": 4, - "__export_date": "2018-01-09T23:32:46.908Z", "__export_source": "insomnia.importers:v0.1.0", + "_type": "export", "resources": [ { - "_type": "workspace", "_id": "__WORKSPACE_ID__", - "parentId": null, + "_type": "workspace", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", "name": "Swagger Petstore 1.0.0", - "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." + "parentId": null }, { - "parentId": "__WORKSPACE_ID__", - "name": "Base environment", + "_id": "__ENV_1__", + "_type": "environment", "data": { "base_url": "{{ scheme }}://{{ host }}{{ base_path }}" }, - "_type": "environment", - "_id": "__ENV_1__" + "name": "Base environment", + "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__ENV_1__", - "name": "Swagger env", + "_id": "__ENV_2__", + "_type": "environment", "data": { "base_path": "/v2", - "scheme": "http", - "host": "petstore.swagger.io" + "host": "petstore.swagger.io", + "scheme": "http" }, - "_type": "environment", - "_id": "__ENV_2__" + "name": "Swagger env", + "parentId": "__ENV_1__" }, { "_id": "__GRP_1__", @@ -56,16 +56,37 @@ "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__GRP_1__", - "name": "Add a new pet to the store", - "description": "", - "url": "{{ base_url }}/pet", + "_id": "addPet", + "_type": "request", + "authentication": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "clientId": "{{ client_id }}", + "disabled": false, + "grantType": "authorization_code", + "scope": "write:pets read:pets", + "type": "oauth2" + }, "body": { "mimeType": "application/json", "text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}" }, + "description": "", + "headers": [ + { + "disabled": false, + "name": "Content-Type", + "value": "application/json" + } + ], "method": "POST", + "name": "Add a new pet to the store", "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet" + }, + { + "_id": "updatePet", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -74,27 +95,27 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "headers": [ - { - "name": "Content-Type", - "disabled": false, - "value": "application/json" - } - ], - "_type": "request", - "_id": "addPet" - }, - { - "parentId": "__GRP_1__", - "name": "Update an existing pet", - "description": "", - "url": "{{ base_url }}/pet", "body": { "mimeType": "application/json", "text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}" }, + "description": "", + "headers": [ + { + "disabled": false, + "name": "Content-Type", + "value": "application/json" + } + ], "method": "PUT", + "name": "Update an existing pet", "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet" + }, + { + "_id": "findPetsByStatus", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -103,31 +124,24 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "headers": [ - { - "name": "Content-Type", - "disabled": false, - "value": "application/json" - } - ], - "_type": "request", - "_id": "updatePet" - }, - { - "parentId": "__GRP_1__", - "name": "Finds Pets by status", - "description": "Multiple status values can be provided with comma separated strings", - "url": "{{ base_url }}/pet/findByStatus", "body": {}, + "description": "Multiple status values can be provided with comma separated strings", + "headers": [], "method": "GET", + "name": "Finds Pets by status", "parameters": [ { - "name": "status", "disabled": false, + "name": "status", "value": "available" } ], - "headers": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/findByStatus" + }, + { + "_id": "findPetsByTags", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -136,43 +150,27 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "_type": "request", - "_id": "findPetsByStatus" - }, - { - "parentId": "__GRP_1__", - "name": "Finds Pets by tags", - "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "url": "{{ base_url }}/pet/findByTags", "body": {}, + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "headers": [], "method": "GET", + "name": "Finds Pets by tags", "parameters": [ { - "name": "tags", "disabled": false, + "name": "tags", "value": "string" } ], - "headers": [], - "authentication": { - "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", - "clientId": "{{ client_id }}", - "disabled": false, - "grantType": "authorization_code", - "scope": "write:pets read:pets", - "type": "oauth2" - }, - "_type": "request", - "_id": "findPetsByTags" + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/findByTags" }, { - "parentId": "__GRP_1__", - "name": "Find pet by ID", - "description": "Returns a single pet", - "url": "{{ base_url }}/pet/{{ petId }}", + "_id": "getPetById", + "_type": "request", + "authentication": {}, "body": {}, - "method": "GET", - "parameters": [], + "description": "Returns a single pet", "headers": [ { "disabled": false, @@ -180,15 +178,23 @@ "value": "{{ api_key }}" } ], - "authentication": {}, - "_type": "request", - "_id": "getPetById" + "method": "GET", + "name": "Find pet by ID", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}" }, { - "parentId": "__GRP_1__", - "name": "Updates a pet in the store with form data", - "description": "", - "url": "{{ base_url }}/pet/{{ petId }}", + "_id": "updatePetWithForm", + "_type": "request", + "authentication": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "clientId": "{{ client_id }}", + "disabled": false, + "grantType": "authorization_code", + "scope": "write:pets read:pets", + "type": "oauth2" + }, "body": { "mimeType": "application/x-www-form-urlencoded", "params": [ @@ -204,41 +210,23 @@ } ] }, - "method": "POST", - "parameters": [], - "authentication": { - "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", - "clientId": "{{ client_id }}", - "disabled": false, - "grantType": "authorization_code", - "scope": "write:pets read:pets", - "type": "oauth2" - }, + "description": "", "headers": [ { - "name": "Content-Type", "disabled": false, + "name": "Content-Type", "value": "application/x-www-form-urlencoded" } ], - "_type": "request", - "_id": "updatePetWithForm" + "method": "POST", + "name": "Updates a pet in the store with form data", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}" }, { - "parentId": "__GRP_1__", - "name": "Deletes a pet", - "description": "", - "url": "{{ base_url }}/pet/{{ petId }}", - "body": {}, - "method": "DELETE", - "parameters": [], - "headers": [ - { - "name": "api_key", - "disabled": true, - "value": "string" - } - ], + "_id": "deletePet", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -247,14 +235,32 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "_type": "request", - "_id": "deletePet" + "body": {}, + "description": "", + "headers": [ + { + "disabled": true, + "name": "api_key", + "value": "string" + } + ], + "method": "DELETE", + "name": "Deletes a pet", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}" }, { - "parentId": "__GRP_1__", - "name": "uploads an image", - "description": "", - "url": "{{ base_url }}/pet/{{ petId }}/uploadImage", + "_id": "uploadFile", + "_type": "request", + "authentication": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "clientId": "{{ client_id }}", + "disabled": false, + "grantType": "authorization_code", + "scope": "write:pets read:pets", + "type": "oauth2" + }, "body": { "mimeType": "multipart/form-data", "params": [ @@ -270,34 +276,26 @@ } ] }, - "method": "POST", - "parameters": [], - "authentication": { - "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", - "clientId": "{{ client_id }}", - "disabled": false, - "grantType": "authorization_code", - "scope": "write:pets read:pets", - "type": "oauth2" - }, + "description": "", "headers": [ { - "name": "Content-Type", "disabled": false, + "name": "Content-Type", "value": "multipart/form-data" } ], - "_type": "request", - "_id": "uploadFile" + "method": "POST", + "name": "uploads an image", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}/uploadImage" }, { - "parentId": "__GRP_2__", - "name": "Returns pet inventories by status", - "description": "Returns a map of status codes to quantities", - "url": "{{ base_url }}/store/inventory", + "_id": "getInventory", + "_type": "request", + "authentication": {}, "body": {}, - "method": "GET", - "parameters": [], + "description": "Returns a map of status codes to quantities", "headers": [ { "disabled": false, @@ -305,163 +303,165 @@ "value": "{{ api_key }}" } ], - "authentication": {}, - "_type": "request", - "_id": "getInventory" + "method": "GET", + "name": "Returns pet inventories by status", + "parameters": [], + "parentId": "__GRP_2__", + "url": "{{ base_url }}/store/inventory" }, { - "parentId": "__GRP_2__", + "_id": "placeOrder", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "POST", "name": "Place an order for a pet", - "description": "", - "url": "{{ base_url }}/store/order", - "body": {}, - "method": "POST", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "placeOrder" + "parentId": "__GRP_2__", + "url": "{{ base_url }}/store/order" }, { - "parentId": "__GRP_2__", - "name": "Find purchase order by ID", + "_id": "getOrderById", + "_type": "request", + "authentication": {}, + "body": {}, "description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions", - "url": "{{ base_url }}/store/order/{{ orderId }}", - "body": {}, - "method": "GET", - "parameters": [], "headers": [], - "authentication": {}, - "_type": "request", - "_id": "getOrderById" - }, - { + "method": "GET", + "name": "Find purchase order by ID", + "parameters": [], "parentId": "__GRP_2__", - "name": "Delete purchase order by ID", + "url": "{{ base_url }}/store/order/{{ orderId }}" + }, + { + "_id": "deleteOrder", + "_type": "request", + "authentication": {}, + "body": {}, "description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors", - "url": "{{ base_url }}/store/order/{{ orderId }}", - "body": {}, + "headers": [], "method": "DELETE", + "name": "Delete purchase order by ID", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "deleteOrder" + "parentId": "__GRP_2__", + "url": "{{ base_url }}/store/order/{{ orderId }}" }, { - "parentId": "__GRP_3__", - "name": "Create user", + "_id": "createUser", + "_type": "request", + "authentication": {}, + "body": {}, "description": "This can only be done by the logged in user.", - "url": "{{ base_url }}/user", - "body": {}, - "method": "POST", - "parameters": [], "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createUser" + "method": "POST", + "name": "Create user", + "parameters": [], + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user" }, { - "parentId": "__GRP_3__", + "_id": "createUsersWithArrayInput", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "POST", "name": "Creates list of users with given input array", - "description": "", - "url": "{{ base_url }}/user/createWithArray", - "body": {}, - "method": "POST", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createUsersWithArrayInput" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/createWithArray" }, { - "parentId": "__GRP_3__", + "_id": "createUsersWithListInput", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "POST", "name": "Creates list of users with given input array", - "description": "", - "url": "{{ base_url }}/user/createWithList", - "body": {}, - "method": "POST", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createUsersWithListInput" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/createWithList" }, { - "parentId": "__GRP_3__", - "name": "Logs user into the system", - "description": "", - "url": "{{ base_url }}/user/login", + "_id": "loginUser", + "_type": "request", + "authentication": {}, "body": {}, + "description": "", + "headers": [], "method": "GET", + "name": "Logs user into the system", "parameters": [ { - "name": "username", "disabled": false, + "name": "username", "value": "string" }, { - "name": "password", "disabled": false, + "name": "password", "value": "string" } ], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "loginUser" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/login" }, { - "parentId": "__GRP_3__", + "_id": "logoutUser", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "GET", "name": "Logs out current logged in user session", - "description": "", - "url": "{{ base_url }}/user/logout", - "body": {}, - "method": "GET", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "logoutUser" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/logout" }, { - "parentId": "__GRP_3__", + "_id": "getUserByName", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "GET", "name": "Get user by user name", - "description": "", - "url": "{{ base_url }}/user/{{ username }}", - "body": {}, - "method": "GET", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "getUserByName" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/{{ username }}" }, { - "parentId": "__GRP_3__", - "name": "Updated user", - "description": "This can only be done by the logged in user.", - "url": "{{ base_url }}/user/{{ username }}", + "_id": "updateUser", + "_type": "request", + "authentication": {}, "body": {}, + "description": "This can only be done by the logged in user.", + "headers": [], "method": "PUT", + "name": "Updated user", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "updateUser" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/{{ username }}" }, { - "parentId": "__GRP_3__", - "name": "Delete user", - "description": "This can only be done by the logged in user.", - "url": "{{ base_url }}/user/{{ username }}", - "body": {}, - "method": "DELETE", - "parameters": [], - "headers": [], - "authentication": {}, + "_id": "deleteUser", "_type": "request", - "_id": "deleteUser" + "authentication": {}, + "body": {}, + "description": "This can only be done by the logged in user.", + "headers": [], + "method": "DELETE", + "name": "Delete user", + "parameters": [], + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/{{ username }}" } ] } diff --git a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-with-tags-output.json b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-with-tags-output.json index 7a3494fdad..3df6037191 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-with-tags-output.json +++ b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-with-tags-output.json @@ -1,35 +1,35 @@ { - "_type": "export", + "__export_date": "2019-11-22T18:56:19.505Z", "__export_format": 4, - "__export_date": "2018-01-09T23:32:54.091Z", "__export_source": "insomnia.importers:v0.1.0", + "_type": "export", "resources": [ { - "_type": "workspace", "_id": "__WORKSPACE_ID__", - "parentId": null, + "_type": "workspace", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", "name": "Swagger Petstore 1.0.0", - "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." + "parentId": null }, { - "parentId": "__WORKSPACE_ID__", - "name": "Base environment", + "_id": "__ENV_1__", + "_type": "environment", "data": { "base_url": "{{ scheme }}://{{ host }}{{ base_path }}" }, - "_type": "environment", - "_id": "__ENV_1__" + "name": "Base environment", + "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__ENV_1__", - "name": "Swagger env", + "_id": "__ENV_2__", + "_type": "environment", "data": { "base_path": "/v2", - "scheme": "http", - "host": "petstore.swagger.io" + "host": "petstore.swagger.io", + "scheme": "http" }, - "_type": "environment", - "_id": "__ENV_2__" + "name": "Swagger env", + "parentId": "__ENV_1__" }, { "_id": "__GRP_1__", @@ -56,16 +56,37 @@ "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__GRP_1__", - "name": "Add a new pet to the store", - "description": "", - "url": "{{ base_url }}/pet", + "_id": "addPet", + "_type": "request", + "authentication": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "clientId": "{{ client_id }}", + "disabled": false, + "grantType": "authorization_code", + "scope": "write:pets read:pets", + "type": "oauth2" + }, "body": { "mimeType": "application/json", "text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}" }, + "description": "", + "headers": [ + { + "disabled": false, + "name": "Content-Type", + "value": "application/json" + } + ], "method": "POST", + "name": "Add a new pet to the store", "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet" + }, + { + "_id": "updatePet", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -74,28 +95,27 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "headers": [ - { - "name": "Content-Type", - "disabled": false, - "value": "application/json" - } - ], - "_type": "request", - "_id": "addPet" - }, - { - "parentId": "__GRP_1__", - "name": "Update an existing pet", - "description": "", - "url": "{{ base_url }}/pet", "body": { "mimeType": "application/json", "text": "{\n \"id\": 0,\n \"category\": {\n \"id\": 0,\n \"name\": \"string\"\n },\n \"name\": \"doggie\",\n \"photoUrls\": [\n \"string\"\n ],\n \"tags\": [\n {\n \"id\": 0,\n \"name\": \"string\"\n }\n ],\n \"status\": \"string\"\n}" }, + "description": "", + "headers": [ + { + "disabled": false, + "name": "Content-Type", + "value": "application/json" + } + ], "method": "PUT", + "name": "Update an existing pet", "parameters": [], - + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet" + }, + { + "_id": "findPetsByStatus", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -104,31 +124,24 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "headers": [ - { - "name": "Content-Type", - "disabled": false, - "value": "application/json" - } - ], - "_type": "request", - "_id": "updatePet" - }, - { - "parentId": "__GRP_1__", - "name": "Finds Pets by status", - "description": "Multiple status values can be provided with comma separated strings", - "url": "{{ base_url }}/pet/findByStatus", "body": {}, + "description": "Multiple status values can be provided with comma separated strings", + "headers": [], "method": "GET", + "name": "Finds Pets by status", "parameters": [ { - "name": "status", "disabled": false, + "name": "status", "value": "available" } ], - "headers": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/findByStatus" + }, + { + "_id": "findPetsByTags", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -137,43 +150,27 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "_type": "request", - "_id": "findPetsByStatus" - }, - { - "parentId": "__GRP_1__", - "name": "Finds Pets by tags", - "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", - "url": "{{ base_url }}/pet/findByTags", "body": {}, + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "headers": [], "method": "GET", + "name": "Finds Pets by tags", "parameters": [ { - "name": "tags", "disabled": false, + "name": "tags", "value": "string" } ], - "headers": [], - "authentication": { - "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", - "clientId": "{{ client_id }}", - "disabled": false, - "grantType": "authorization_code", - "scope": "write:pets read:pets", - "type": "oauth2" - }, - "_type": "request", - "_id": "findPetsByTags" + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/findByTags" }, { - "parentId": "__GRP_1__", - "name": "Find pet by ID", - "description": "Returns a single pet", - "url": "{{ base_url }}/pet/{{ petId }}", + "_id": "getPetById", + "_type": "request", + "authentication": {}, "body": {}, - "method": "GET", - "parameters": [], + "description": "Returns a single pet", "headers": [ { "disabled": false, @@ -181,15 +178,23 @@ "value": "{{ api_key }}" } ], - "authentication": {}, - "_type": "request", - "_id": "getPetById" + "method": "GET", + "name": "Find pet by ID", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}" }, { - "parentId": "__GRP_1__", - "name": "Updates a pet in the store with form data", - "description": "", - "url": "{{ base_url }}/pet/{{ petId }}", + "_id": "updatePetWithForm", + "_type": "request", + "authentication": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "clientId": "{{ client_id }}", + "disabled": false, + "grantType": "authorization_code", + "scope": "write:pets read:pets", + "type": "oauth2" + }, "body": { "mimeType": "application/x-www-form-urlencoded", "params": [ @@ -205,41 +210,23 @@ } ] }, - "method": "POST", - "parameters": [], - "authentication": { - "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", - "clientId": "{{ client_id }}", - "disabled": false, - "grantType": "authorization_code", - "scope": "write:pets read:pets", - "type": "oauth2" - }, + "description": "", "headers": [ { - "name": "Content-Type", "disabled": false, + "name": "Content-Type", "value": "application/x-www-form-urlencoded" } ], - "_type": "request", - "_id": "updatePetWithForm" + "method": "POST", + "name": "Updates a pet in the store with form data", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}" }, { - "parentId": "__GRP_1__", - "name": "Deletes a pet", - "description": "", - "url": "{{ base_url }}/pet/{{ petId }}", - "body": {}, - "method": "DELETE", - "parameters": [], - "headers": [ - { - "name": "api_key", - "disabled": true, - "value": "string" - } - ], + "_id": "deletePet", + "_type": "request", "authentication": { "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", "clientId": "{{ client_id }}", @@ -248,14 +235,32 @@ "scope": "write:pets read:pets", "type": "oauth2" }, - "_type": "request", - "_id": "deletePet" + "body": {}, + "description": "", + "headers": [ + { + "disabled": true, + "name": "api_key", + "value": "string" + } + ], + "method": "DELETE", + "name": "Deletes a pet", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}" }, { - "parentId": "__GRP_1__", - "name": "uploads an image", - "description": "", - "url": "{{ base_url }}/pet/{{ petId }}/uploadImage", + "_id": "uploadFile", + "_type": "request", + "authentication": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "clientId": "{{ client_id }}", + "disabled": false, + "grantType": "authorization_code", + "scope": "write:pets read:pets", + "type": "oauth2" + }, "body": { "mimeType": "multipart/form-data", "params": [ @@ -271,34 +276,26 @@ } ] }, - "method": "POST", - "parameters": [], - "authentication": { - "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", - "clientId": "{{ client_id }}", - "disabled": false, - "grantType": "authorization_code", - "scope": "write:pets read:pets", - "type": "oauth2" - }, + "description": "", "headers": [ { - "name": "Content-Type", "disabled": false, + "name": "Content-Type", "value": "multipart/form-data" } ], - "_type": "request", - "_id": "uploadFile" + "method": "POST", + "name": "uploads an image", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pet/{{ petId }}/uploadImage" }, { - "parentId": "__GRP_2__", - "name": "Returns pet inventories by status", - "description": "Returns a map of status codes to quantities", - "url": "{{ base_url }}/store/inventory", + "_id": "getInventory", + "_type": "request", + "authentication": {}, "body": {}, - "method": "GET", - "parameters": [], + "description": "Returns a map of status codes to quantities", "headers": [ { "disabled": false, @@ -306,163 +303,165 @@ "value": "{{ api_key }}" } ], - "authentication": {}, - "_type": "request", - "_id": "getInventory" + "method": "GET", + "name": "Returns pet inventories by status", + "parameters": [], + "parentId": "__GRP_2__", + "url": "{{ base_url }}/store/inventory" }, { - "parentId": "__GRP_2__", + "_id": "placeOrder", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "POST", "name": "Place an order for a pet", - "description": "", - "url": "{{ base_url }}/store/order", - "body": {}, - "method": "POST", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "placeOrder" + "parentId": "__GRP_2__", + "url": "{{ base_url }}/store/order" }, { - "parentId": "__GRP_2__", - "name": "Find purchase order by ID", + "_id": "getOrderById", + "_type": "request", + "authentication": {}, + "body": {}, "description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions", - "url": "{{ base_url }}/store/order/{{ orderId }}", - "body": {}, - "method": "GET", - "parameters": [], "headers": [], - "authentication": {}, - "_type": "request", - "_id": "getOrderById" - }, - { + "method": "GET", + "name": "Find purchase order by ID", + "parameters": [], "parentId": "__GRP_2__", - "name": "Delete purchase order by ID", + "url": "{{ base_url }}/store/order/{{ orderId }}" + }, + { + "_id": "deleteOrder", + "_type": "request", + "authentication": {}, + "body": {}, "description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors", - "url": "{{ base_url }}/store/order/{{ orderId }}", - "body": {}, + "headers": [], "method": "DELETE", + "name": "Delete purchase order by ID", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "deleteOrder" + "parentId": "__GRP_2__", + "url": "{{ base_url }}/store/order/{{ orderId }}" }, { - "parentId": "__GRP_3__", - "name": "Create user", + "_id": "createUser", + "_type": "request", + "authentication": {}, + "body": {}, "description": "This can only be done by the logged in user.", - "url": "{{ base_url }}/user", - "body": {}, - "method": "POST", - "parameters": [], "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createUser" + "method": "POST", + "name": "Create user", + "parameters": [], + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user" }, { - "parentId": "__GRP_3__", + "_id": "createUsersWithArrayInput", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "POST", "name": "Creates list of users with given input array", - "description": "", - "url": "{{ base_url }}/user/createWithArray", - "body": {}, - "method": "POST", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createUsersWithArrayInput" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/createWithArray" }, { - "parentId": "__GRP_3__", + "_id": "createUsersWithListInput", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "POST", "name": "Creates list of users with given input array", - "description": "", - "url": "{{ base_url }}/user/createWithList", - "body": {}, - "method": "POST", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createUsersWithListInput" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/createWithList" }, { - "parentId": "__GRP_3__", - "name": "Logs user into the system", - "description": "", - "url": "{{ base_url }}/user/login", + "_id": "loginUser", + "_type": "request", + "authentication": {}, "body": {}, + "description": "", + "headers": [], "method": "GET", + "name": "Logs user into the system", "parameters": [ { - "name": "username", "disabled": false, + "name": "username", "value": "string" }, { - "name": "password", "disabled": false, + "name": "password", "value": "string" } ], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "loginUser" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/login" }, { - "parentId": "__GRP_3__", + "_id": "logoutUser", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "GET", "name": "Logs out current logged in user session", - "description": "", - "url": "{{ base_url }}/user/logout", - "body": {}, - "method": "GET", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "logoutUser" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/logout" }, { - "parentId": "__GRP_3__", + "_id": "getUserByName", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "GET", "name": "Get user by user name", - "description": "", - "url": "{{ base_url }}/user/{{ username }}", - "body": {}, - "method": "GET", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "getUserByName" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/{{ username }}" }, { - "parentId": "__GRP_3__", - "name": "Updated user", - "description": "This can only be done by the logged in user.", - "url": "{{ base_url }}/user/{{ username }}", + "_id": "updateUser", + "_type": "request", + "authentication": {}, "body": {}, + "description": "This can only be done by the logged in user.", + "headers": [], "method": "PUT", + "name": "Updated user", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "updateUser" + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/{{ username }}" }, { - "parentId": "__GRP_3__", - "name": "Delete user", - "description": "This can only be done by the logged in user.", - "url": "{{ base_url }}/user/{{ username }}", - "body": {}, - "method": "DELETE", - "parameters": [], - "headers": [], - "authentication": {}, + "_id": "deleteUser", "_type": "request", - "_id": "deleteUser" + "authentication": {}, + "body": {}, + "description": "This can only be done by the logged in user.", + "headers": [], + "method": "DELETE", + "name": "Delete user", + "parameters": [], + "parentId": "__GRP_3__", + "url": "{{ base_url }}/user/{{ username }}" } ] } diff --git a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-input.yml b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-input.yml index 11ca452359..5b0b7888e8 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-input.yml +++ b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-input.yml @@ -60,6 +60,7 @@ paths: /pets/{petId}: get: summary: Info for a specific pet + description: This is a longer description operationId: showPetById tags: - pets diff --git a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-output.json b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-output.json index e9af909533..05234bd4f4 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-output.json +++ b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-output.json @@ -1,35 +1,35 @@ { - "_type": "export", + "__export_date": "2019-11-22T18:54:59.959Z", "__export_format": 4, - "__export_date": "2018-01-09T23:33:12.799Z", "__export_source": "insomnia.importers:v0.1.0", + "_type": "export", "resources": [ { - "_type": "workspace", "_id": "__WORKSPACE_ID__", - "parentId": null, + "_type": "workspace", + "description": "", "name": "Swagger Petstore 1.0.0", - "description": "" + "parentId": null }, { - "parentId": "__WORKSPACE_ID__", - "name": "Base environment", + "_id": "__ENV_1__", + "_type": "environment", "data": { "base_url": "{{ scheme }}://{{ host }}{{ base_path }}" }, - "_type": "environment", - "_id": "__ENV_1__" + "name": "Base environment", + "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__ENV_1__", - "name": "Swagger env", + "_id": "__ENV_2__", + "_type": "environment", "data": { "base_path": "/v1", - "scheme": "http", - "host": "petstore.swagger.io" + "host": "petstore.swagger.io", + "scheme": "http" }, - "_type": "environment", - "_id": "__ENV_2__" + "name": "Swagger env", + "parentId": "__ENV_1__" }, { "_id": "__GRP_1__", @@ -40,33 +40,33 @@ "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__GRP_1__", - "name": "List all pets", - "url": "{{ base_url }}/pets", + "_id": "listPets", + "_type": "request", + "authentication": {}, "body": {}, + "description": "", + "headers": [], "method": "GET", + "name": "List all pets", "parameters": [ { - "name": "limit", "disabled": true, + "name": "limit", "value": "0" } ], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "listPets" + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets" }, { - "parentId": "__GRP_1__", - "name": "Create a pet", - "url": "{{ base_url }}/pets", + "_id": "createPets", + "_type": "request", + "authentication": {}, "body": { "mimeType": "application/json", "text": "{\n \"id\": 0,\n \"name\": \"string\",\n \"tag\": \"string\"\n}" }, - "method": "POST", - "parameters": [], + "description": "", "headers": [ { "disabled": false, @@ -74,26 +74,29 @@ "value": "application/json" } ], - "authentication": {}, - "_type": "request", - "_id": "createPets" - }, - { - "parentId": "__GRP_1__", - "name": "Info for a specific pet", - "url": "{{ base_url }}/pets/{{ petId }}", - "body": {}, - "method": "GET", + "method": "POST", + "name": "Create a pet", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "showPetById" + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets" }, { - "parentId": "__WORKSPACE_ID__", - "name": "Update specific pet", - "url": "{{ base_url }}/pets/{{ petId }}", + "_id": "showPetById", + "_type": "request", + "authentication": {}, + "body": {}, + "description": "This is a longer description", + "headers": [], + "method": "GET", + "name": "Info for a specific pet", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets/{{ petId }}" + }, + { + "_id": "updatePet", + "_type": "request", + "authentication": {}, "body": { "mimeType": "application/x-www-form-urlencoded", "params": [ @@ -104,8 +107,7 @@ } ] }, - "method": "POST", - "parameters": [], + "description": "", "headers": [ { "disabled": false, @@ -113,9 +115,11 @@ "value": "application/x-www-form-urlencoded" } ], - "authentication": {}, - "_type": "request", - "_id": "updatePet" + "method": "POST", + "name": "Update specific pet", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets/{{ petId }}" } ] } diff --git a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-with-tags-output.json b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-with-tags-output.json index 0df8ad80d0..56a1ffe47a 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-with-tags-output.json +++ b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/petstore-yml-with-tags-output.json @@ -1,35 +1,35 @@ { - "_type": "export", + "__export_date": "2019-11-22T18:56:29.797Z", "__export_format": 4, - "__export_date": "2018-01-09T23:33:12.799Z", "__export_source": "insomnia.importers:v0.1.0", + "_type": "export", "resources": [ { - "_type": "workspace", "_id": "__WORKSPACE_ID__", - "parentId": null, + "_type": "workspace", + "description": "", "name": "Swagger Petstore 1.0.0", - "description": "" + "parentId": null }, { - "parentId": "__WORKSPACE_ID__", - "name": "Base environment", + "_id": "__ENV_1__", + "_type": "environment", "data": { "base_url": "{{ scheme }}://{{ host }}{{ base_path }}" }, - "_type": "environment", - "_id": "__ENV_1__" + "name": "Base environment", + "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__ENV_1__", - "name": "Swagger env", + "_id": "__ENV_2__", + "_type": "environment", "data": { "base_path": "/v1", - "scheme": "http", - "host": "petstore.swagger.io" + "host": "petstore.swagger.io", + "scheme": "http" }, - "_type": "environment", - "_id": "__ENV_2__" + "name": "Swagger env", + "parentId": "__ENV_1__" }, { "_id": "__GRP_1__", @@ -40,46 +40,49 @@ "parentId": "__WORKSPACE_ID__" }, { - "parentId": "__GRP_1__", - "name": "List all pets", - "url": "{{ base_url }}/pets", + "_id": "listPets", + "_type": "request", + "authentication": {}, "body": {}, + "description": "", + "headers": [], "method": "GET", + "name": "List all pets", "parameters": [ { - "name": "limit", "disabled": true, + "name": "limit", "value": "0" } ], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "listPets" + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets" }, { - "parentId": "__GRP_1__", - "name": "Create a pet", - "url": "{{ base_url }}/pets", + "_id": "createPets", + "_type": "request", + "authentication": {}, "body": {}, + "description": "", + "headers": [], "method": "POST", + "name": "Create a pet", "parameters": [], - "headers": [], - "authentication": {}, - "_type": "request", - "_id": "createPets" + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets" }, { - "parentId": "__GRP_1__", - "name": "Info for a specific pet", - "url": "{{ base_url }}/pets/{{ petId }}", - "body": {}, - "method": "GET", - "parameters": [], - "headers": [], - "authentication": {}, + "_id": "showPetById", "_type": "request", - "_id": "showPetById" + "authentication": {}, + "body": {}, + "description": "", + "headers": [], + "method": "GET", + "name": "Info for a specific pet", + "parameters": [], + "parentId": "__GRP_1__", + "url": "{{ base_url }}/pets/{{ petId }}" } ] } diff --git a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/user-example-output.json b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/user-example-output.json index 0d662a6e64..60dcd24cd5 100644 --- a/packages/insomnia-importers/src/__tests__/fixtures/swagger2/user-example-output.json +++ b/packages/insomnia-importers/src/__tests__/fixtures/swagger2/user-example-output.json @@ -1,5 +1,5 @@ { - "__export_date": "2019-04-26T04:04:46.087Z", + "__export_date": "2019-11-22T18:56:44.435Z", "__export_format": 4, "__export_source": "insomnia.importers:v0.1.0", "_type": "export", @@ -44,6 +44,7 @@ "_type": "request", "authentication": {}, "body": {}, + "description": "", "headers": [], "method": "GET", "name": "Some list", diff --git a/packages/insomnia-importers/src/importers/swagger2.js b/packages/insomnia-importers/src/importers/swagger2.js index 4dda1d992b..21f0178b92 100644 --- a/packages/insomnia-importers/src/importers/swagger2.js +++ b/packages/insomnia-importers/src/importers/swagger2.js @@ -186,7 +186,7 @@ function importRequest(schema, endpointSchema, globalMimeTypes, id, parentId) { method: endpointSchema.method.toUpperCase(), url: '{{ base_url }}' + pathWithParamsAsVariables(endpointSchema.path), body: prepareBody(schema, endpointSchema, globalMimeTypes), - description: endpointSchema.description, + description: endpointSchema.description || '', headers: prepareHeaders(endpointSchema), parameters: prepareQueryParams(endpointSchema), };