[Feature] [SwaggerV2] Import Documentation and Authentification (#1724)

* [Feature] [SwaggerV2] Import Documentation and Authentification
Partially implements #1698
Fixes #1007

* Update fixtures to reflect swagger2 importer changes
This commit is contained in:
Matthias Ramsauer
2019-11-22 19:06:15 +01:00
committed by Gregory Schier
parent 83be4a9714
commit 65cd4b0146
5 changed files with 475 additions and 35 deletions

View File

@@ -34,6 +34,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Add a new pet to the store",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -41,6 +42,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -55,6 +64,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Update an existing pet",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -62,6 +72,14 @@
},
"method": "PUT",
"parameters": [],
"authentication": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"clientId": "{{ client_id }}",
"disabled": false,
"grantType": "authorization_code",
"scope": "write:pets read:pets",
"type": "oauth2"
},
"headers": [
{
"name": "Content-Type",
@@ -69,13 +87,13 @@
"value": "application/json"
}
],
"authentication": {},
"_type": "request",
"_id": "updatePet"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Finds Pets by status",
"description": "Multiple status values can be provided with comma separated strings",
"url": "{{ base_url }}/pet/findByStatus",
"body": {},
"method": "GET",
@@ -87,13 +105,21 @@
}
],
"headers": [],
"authentication": {},
"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": "findPetsByStatus"
},
{
"parentId": "__WORKSPACE_ID__",
"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": {},
"method": "GET",
@@ -105,18 +131,32 @@
}
],
"headers": [],
"authentication": {},
"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": "__WORKSPACE_ID__",
"name": "Find pet by ID",
"description": "Returns a single pet",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getPetById"
@@ -124,6 +164,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Updates a pet in the store with form data",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {
"mimeType": "application/x-www-form-urlencoded",
@@ -142,6 +183,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -149,13 +198,13 @@
"value": "application/x-www-form-urlencoded"
}
],
"authentication": {},
"_type": "request",
"_id": "updatePetWithForm"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Deletes a pet",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "DELETE",
@@ -167,13 +216,21 @@
"value": "string"
}
],
"authentication": {},
"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": "deletePet"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "uploads an image",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}/uploadImage",
"body": {
"mimeType": "multipart/form-data",
@@ -192,6 +249,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -199,18 +264,24 @@
"value": "multipart/form-data"
}
],
"authentication": {},
"_type": "request",
"_id": "uploadFile"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"url": "{{ base_url }}/store/inventory",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getInventory"
@@ -218,6 +289,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Place an order for a pet",
"description": "",
"url": "{{ base_url }}/store/order",
"body": {},
"method": "POST",
@@ -230,6 +302,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Find purchase order by ID",
"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",
@@ -242,6 +315,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Delete purchase order by ID",
"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": {},
"method": "DELETE",
@@ -254,6 +328,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Create user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user",
"body": {},
"method": "POST",
@@ -266,6 +341,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithArray",
"body": {},
"method": "POST",
@@ -278,6 +354,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithList",
"body": {},
"method": "POST",
@@ -290,6 +367,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Logs user into the system",
"description": "",
"url": "{{ base_url }}/user/login",
"body": {},
"method": "GET",
@@ -313,6 +391,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Logs out current logged in user session",
"description": "",
"url": "{{ base_url }}/user/logout",
"body": {},
"method": "GET",
@@ -325,6 +404,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Get user by user name",
"description": "",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "GET",
@@ -337,6 +417,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Updated user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "PUT",
@@ -349,6 +430,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Delete user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "DELETE",

View File

@@ -58,6 +58,7 @@
{
"parentId": "__GRP_1__",
"name": "Add a new pet to the store",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -65,6 +66,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -72,13 +81,13 @@
"value": "application/json"
}
],
"authentication": {},
"_type": "request",
"_id": "addPet"
},
{
"parentId": "__GRP_1__",
"name": "Update an existing pet",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -86,6 +95,14 @@
},
"method": "PUT",
"parameters": [],
"authentication": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"clientId": "{{ client_id }}",
"disabled": false,
"grantType": "authorization_code",
"scope": "write:pets read:pets",
"type": "oauth2"
},
"headers": [
{
"name": "Content-Type",
@@ -93,13 +110,13 @@
"value": "application/json"
}
],
"authentication": {},
"_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": {},
"method": "GET",
@@ -111,13 +128,21 @@
}
],
"headers": [],
"authentication": {},
"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": "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": {},
"method": "GET",
@@ -129,18 +154,32 @@
}
],
"headers": [],
"authentication": {},
"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__",
"name": "Find pet by ID",
"description": "Returns a single pet",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getPetById"
@@ -148,6 +187,7 @@
{
"parentId": "__GRP_1__",
"name": "Updates a pet in the store with form data",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {
"mimeType": "application/x-www-form-urlencoded",
@@ -166,6 +206,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -173,13 +221,13 @@
"value": "application/x-www-form-urlencoded"
}
],
"authentication": {},
"_type": "request",
"_id": "updatePetWithForm"
},
{
"parentId": "__GRP_1__",
"name": "Deletes a pet",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "DELETE",
@@ -191,13 +239,21 @@
"value": "string"
}
],
"authentication": {},
"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": "deletePet"
},
{
"parentId": "__GRP_1__",
"name": "uploads an image",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}/uploadImage",
"body": {
"mimeType": "multipart/form-data",
@@ -216,6 +272,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -223,18 +287,24 @@
"value": "multipart/form-data"
}
],
"authentication": {},
"_type": "request",
"_id": "uploadFile"
},
{
"parentId": "__GRP_2__",
"name": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"url": "{{ base_url }}/store/inventory",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getInventory"
@@ -242,6 +312,7 @@
{
"parentId": "__GRP_2__",
"name": "Place an order for a pet",
"description": "",
"url": "{{ base_url }}/store/order",
"body": {},
"method": "POST",
@@ -254,6 +325,7 @@
{
"parentId": "__GRP_2__",
"name": "Find purchase order by ID",
"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",
@@ -266,6 +338,7 @@
{
"parentId": "__GRP_2__",
"name": "Delete purchase order by ID",
"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": {},
"method": "DELETE",
@@ -278,6 +351,7 @@
{
"parentId": "__GRP_3__",
"name": "Create user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user",
"body": {},
"method": "POST",
@@ -290,6 +364,7 @@
{
"parentId": "__GRP_3__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithArray",
"body": {},
"method": "POST",
@@ -302,6 +377,7 @@
{
"parentId": "__GRP_3__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithList",
"body": {},
"method": "POST",
@@ -314,6 +390,7 @@
{
"parentId": "__GRP_3__",
"name": "Logs user into the system",
"description": "",
"url": "{{ base_url }}/user/login",
"body": {},
"method": "GET",
@@ -337,6 +414,7 @@
{
"parentId": "__GRP_3__",
"name": "Logs out current logged in user session",
"description": "",
"url": "{{ base_url }}/user/logout",
"body": {},
"method": "GET",
@@ -349,6 +427,7 @@
{
"parentId": "__GRP_3__",
"name": "Get user by user name",
"description": "",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "GET",
@@ -361,6 +440,7 @@
{
"parentId": "__GRP_3__",
"name": "Updated user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "PUT",
@@ -373,6 +453,7 @@
{
"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",

View File

@@ -34,6 +34,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Add a new pet to the store",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -41,6 +42,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -48,13 +57,13 @@
"value": "application/json"
}
],
"authentication": {},
"_type": "request",
"_id": "addPet"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Update an existing pet",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -62,6 +71,14 @@
},
"method": "PUT",
"parameters": [],
"authentication": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"clientId": "{{ client_id }}",
"disabled": false,
"grantType": "authorization_code",
"scope": "write:pets read:pets",
"type": "oauth2"
},
"headers": [
{
"name": "Content-Type",
@@ -69,13 +86,13 @@
"value": "application/json"
}
],
"authentication": {},
"_type": "request",
"_id": "updatePet"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Finds Pets by status",
"description": "Multiple status values can be provided with comma separated strings",
"url": "{{ base_url }}/pet/findByStatus",
"body": {},
"method": "GET",
@@ -87,13 +104,21 @@
}
],
"headers": [],
"authentication": {},
"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": "findPetsByStatus"
},
{
"parentId": "__WORKSPACE_ID__",
"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": {},
"method": "GET",
@@ -105,18 +130,32 @@
}
],
"headers": [],
"authentication": {},
"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": "__WORKSPACE_ID__",
"name": "Find pet by ID",
"description": "Returns a single pet",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getPetById"
@@ -124,6 +163,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Updates a pet in the store with form data",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {
"mimeType": "application/x-www-form-urlencoded",
@@ -142,6 +182,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -149,13 +197,13 @@
"value": "application/x-www-form-urlencoded"
}
],
"authentication": {},
"_type": "request",
"_id": "updatePetWithForm"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Deletes a pet",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "DELETE",
@@ -167,13 +215,21 @@
"value": "string"
}
],
"authentication": {},
"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": "deletePet"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "uploads an image",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}/uploadImage",
"body": {
"mimeType": "multipart/form-data",
@@ -192,6 +248,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -199,18 +263,24 @@
"value": "multipart/form-data"
}
],
"authentication": {},
"_type": "request",
"_id": "uploadFile"
},
{
"parentId": "__WORKSPACE_ID__",
"name": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"url": "{{ base_url }}/store/inventory",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getInventory"
@@ -218,6 +288,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Place an order for a pet",
"description": "",
"url": "{{ base_url }}/store/order",
"body": {},
"method": "POST",
@@ -230,6 +301,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Find purchase order by ID",
"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",
@@ -242,6 +314,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Delete purchase order by ID",
"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": {},
"method": "DELETE",
@@ -254,6 +327,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Create user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user",
"body": {},
"method": "POST",
@@ -266,6 +340,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithArray",
"body": {},
"method": "POST",
@@ -278,6 +353,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithList",
"body": {},
"method": "POST",
@@ -290,6 +366,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Logs user into the system",
"description": "",
"url": "{{ base_url }}/user/login",
"body": {},
"method": "GET",
@@ -313,6 +390,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Logs out current logged in user session",
"description": "",
"url": "{{ base_url }}/user/logout",
"body": {},
"method": "GET",
@@ -325,6 +403,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Get user by user name",
"description": "",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "GET",
@@ -337,6 +416,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Updated user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "PUT",
@@ -349,6 +429,7 @@
{
"parentId": "__WORKSPACE_ID__",
"name": "Delete user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "DELETE",

View File

@@ -58,6 +58,7 @@
{
"parentId": "__GRP_1__",
"name": "Add a new pet to the store",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -65,6 +66,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -72,13 +81,13 @@
"value": "application/json"
}
],
"authentication": {},
"_type": "request",
"_id": "addPet"
},
{
"parentId": "__GRP_1__",
"name": "Update an existing pet",
"description": "",
"url": "{{ base_url }}/pet",
"body": {
"mimeType": "application/json",
@@ -86,6 +95,15 @@
},
"method": "PUT",
"parameters": [],
"authentication": {
"authorizationUrl": "http://petstore.swagger.io/oauth/dialog",
"clientId": "{{ client_id }}",
"disabled": false,
"grantType": "authorization_code",
"scope": "write:pets read:pets",
"type": "oauth2"
},
"headers": [
{
"name": "Content-Type",
@@ -93,13 +111,13 @@
"value": "application/json"
}
],
"authentication": {},
"_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": {},
"method": "GET",
@@ -111,13 +129,21 @@
}
],
"headers": [],
"authentication": {},
"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": "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": {},
"method": "GET",
@@ -129,18 +155,32 @@
}
],
"headers": [],
"authentication": {},
"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__",
"name": "Find pet by ID",
"description": "Returns a single pet",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getPetById"
@@ -148,6 +188,7 @@
{
"parentId": "__GRP_1__",
"name": "Updates a pet in the store with form data",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {
"mimeType": "application/x-www-form-urlencoded",
@@ -166,6 +207,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -173,13 +222,13 @@
"value": "application/x-www-form-urlencoded"
}
],
"authentication": {},
"_type": "request",
"_id": "updatePetWithForm"
},
{
"parentId": "__GRP_1__",
"name": "Deletes a pet",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}",
"body": {},
"method": "DELETE",
@@ -191,13 +240,21 @@
"value": "string"
}
],
"authentication": {},
"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": "deletePet"
},
{
"parentId": "__GRP_1__",
"name": "uploads an image",
"description": "",
"url": "{{ base_url }}/pet/{{ petId }}/uploadImage",
"body": {
"mimeType": "multipart/form-data",
@@ -216,6 +273,14 @@
},
"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"
},
"headers": [
{
"name": "Content-Type",
@@ -223,18 +288,24 @@
"value": "multipart/form-data"
}
],
"authentication": {},
"_type": "request",
"_id": "uploadFile"
},
{
"parentId": "__GRP_2__",
"name": "Returns pet inventories by status",
"description": "Returns a map of status codes to quantities",
"url": "{{ base_url }}/store/inventory",
"body": {},
"method": "GET",
"parameters": [],
"headers": [],
"headers": [
{
"disabled": false,
"name": "api_key",
"value": "{{ api_key }}"
}
],
"authentication": {},
"_type": "request",
"_id": "getInventory"
@@ -242,6 +313,7 @@
{
"parentId": "__GRP_2__",
"name": "Place an order for a pet",
"description": "",
"url": "{{ base_url }}/store/order",
"body": {},
"method": "POST",
@@ -254,6 +326,7 @@
{
"parentId": "__GRP_2__",
"name": "Find purchase order by ID",
"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",
@@ -266,6 +339,7 @@
{
"parentId": "__GRP_2__",
"name": "Delete purchase order by ID",
"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": {},
"method": "DELETE",
@@ -278,6 +352,7 @@
{
"parentId": "__GRP_3__",
"name": "Create user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user",
"body": {},
"method": "POST",
@@ -290,6 +365,7 @@
{
"parentId": "__GRP_3__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithArray",
"body": {},
"method": "POST",
@@ -302,6 +378,7 @@
{
"parentId": "__GRP_3__",
"name": "Creates list of users with given input array",
"description": "",
"url": "{{ base_url }}/user/createWithList",
"body": {},
"method": "POST",
@@ -314,6 +391,7 @@
{
"parentId": "__GRP_3__",
"name": "Logs user into the system",
"description": "",
"url": "{{ base_url }}/user/login",
"body": {},
"method": "GET",
@@ -337,6 +415,7 @@
{
"parentId": "__GRP_3__",
"name": "Logs out current logged in user session",
"description": "",
"url": "{{ base_url }}/user/logout",
"body": {},
"method": "GET",
@@ -349,6 +428,7 @@
{
"parentId": "__GRP_3__",
"name": "Get user by user name",
"description": "",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "GET",
@@ -361,6 +441,7 @@
{
"parentId": "__GRP_3__",
"name": "Updated user",
"description": "This can only be done by the logged in user.",
"url": "{{ base_url }}/user/{{ username }}",
"body": {},
"method": "PUT",
@@ -373,6 +454,7 @@
{
"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",

View File

@@ -159,6 +159,7 @@ function importFolderItem(item, parentId) {
* @param {string} parentId - id of parent category
* @returns {Object}
*/
function importRequest(schema, endpointSchema, globalMimeTypes, id, parentId) {
const name = endpointSchema.summary || `${endpointSchema.method} ${endpointSchema.path}`;
const request = {
@@ -169,9 +170,11 @@ 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,
headers: prepareHeaders(endpointSchema),
parameters: prepareQueryParams(endpointSchema),
};
if (request.body.mimeType && !request.headers.find(header => header.name === 'Content-Type')) {
request.headers = [
{
@@ -180,6 +183,117 @@ function importRequest(schema, endpointSchema, globalMimeTypes, id, parentId) {
value: request.body.mimeType,
},
].concat(request.headers);
body: prepareBody(endpointSchema, globalMimeTypes),
description: endpointSchema.description,
headers: prepareHeaders(endpointSchema),
parameters: prepareQueryParams(endpointSchema),
};
return setupAuthentication(securityDefinitions, endpointSchema, request);
}
/**
* Populate Insomnia request with authentication
*
*
* @param {Object} securityDefinitions - swagger 2.0 security definitions
* @param {Object} endpointSchema - swagger 2.0 endpoint schema
* @param {Object} request - insomnia request object
* @returns {Object}
*/
function setupAuthentication(securityDefinitions, endpointSchema, request) {
if (!securityDefinitions) {
return request;
}
if (endpointSchema.security && endpointSchema.security.length > 0) {
const usedDefinitions = endpointSchema.security.reduce(
(collect, obj) => collect.concat(...Object.keys(obj)),
[],
);
const scopes = endpointSchema.security.reduce((scopes, security) => {
for (const defname in security) {
if (security[defname].length === 0) {
continue;
}
return scopes.concat(security[defname]);
}
return scopes;
}, []);
for (const usedDefinition of usedDefinitions) {
const definition = securityDefinitions[usedDefinition];
if (definition.type === 'basic') {
request.authentication = {
type: 'basic',
disabled: false,
password: '{{ password }}',
username: '{{ username }}',
};
}
if (definition.type === 'apiKey') {
if (definition.in === 'header') {
request.headers.push({
name: definition.name,
disabled: false,
value: `{{ api_key }}`,
});
}
if (definition.in === 'query') {
request.parameters.push({
name: definition.name,
disabled: false,
value: '{{ api_key }}',
});
}
}
if (definition.type === 'oauth2') {
if (definition.flow === 'implicit') {
request.authentication = {
type: 'oauth2',
grantType: 'authorization_code',
disabled: false,
authorizationUrl: definition.authorizationUrl,
clientId: '{{ client_id }}',
scope: scopes.join(' '),
};
}
if (definition.flow === 'password') {
request.authentication = {
type: 'oauth2',
grantType: 'password',
disabled: false,
accessTokenUrl: definition.tokenUrl,
username: '{{ username }}',
password: '{{ password }}',
clientId: '{{ client_id }}',
clientSecret: '{{ client_secret }}',
scope: scopes.join(' '),
};
}
if (definition.flow === 'application') {
request.authentication = {
type: 'oauth2',
grantType: 'client_credentials',
disabled: false,
accessTokenUrl: definition.tokenUrl,
clientId: '{{ client_id }}',
clientSecret: '{{ client_secret }}',
scope: scopes.join(' '),
};
}
if (definition.flow === 'accessCode') {
request.authentication = {
type: 'oauth2',
grantType: 'authorization_code',
disabled: false,
accessTokenUrl: definition.tokenUrl,
authorizationUrl: definition.authorizationUrl,
clientId: '{{ client_id }}',
clientSecret: '{{ client_secret }}',
scope: scopes.join(' '),
};
}
}
}
}
return request;
}