Repository: knuckleswtf/scribe (php)

Issue:
Include raw in request.url?
Hi,

I'm using Insomnia, and when I import _collection.json_ the urls to the endpoints are empty.

Importing to Postman, exporting from there and importing again to Insomnia makes be believe that this could be fixed by adding _raw_ to the export:
```
"item": [
{
  "name": "/myendpoint",
  "request": {
    "url": {
      **"raw": "https://example.com/myendpoint",**
      "protocol": "https",
      "host": "example.com",
      "path": "/myendpoint",
      "query": []
    },
}
]
```

Should this be added, to conform to the way Postman exports its endpoints?

Pull request description:
Resolves #40 - Include raw in requests.url
Fixes import to Insomnia

Fixes #40 

> **Please read the [contribution guidelines](https://scribe.readthedocs.io/en/latest/contributing.html), especially the section on making a pull request, before creating a PR.** Otherwise, your PR may be turned down.


Patch:
diff --git a/src/Writing/PostmanCollectionWriter.php b/src/Writing/PostmanCollectionWriter.php
index f34fb714..bc82b796 100644
--- a/src/Writing/PostmanCollectionWriter.php
+++ b/src/Writing/PostmanCollectionWriter.php
@@ -183,6 +183,14 @@ class PostmanCollectionWriter
             })->values()->toArray(),
         ];
 
+        // Create raw url-parameter (Insomnia uses this on import)
+        $query = collect($base['query'] ?? [])->map(function ($queryParamData) {
+            return $queryParamData['key'].'='.$queryParamData['value'];
+        })->implode('&');
+        $base['raw'] = sprintf('%s://%s/%s%s',
+            $base['protocol'], $base['host'], $base['path'], $query ? '?'.$query : null
+        );
+
         // If there aren't any url parameters described then return what we've got
         /** @var $urlParams Collection */
         if ($urlParams->isEmpty()) {


Test patch:
diff --git a/tests/Fixtures/collection.json b/tests/Fixtures/collection.json
index 4e0043bd..66e4ed9f 100644
--- a/tests/Fixtures/collection.json
+++ b/tests/Fixtures/collection.json
@@ -18,7 +18,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withDescription",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withDescription"
                         },
                         "method": "GET",
                         "header": [
@@ -59,7 +60,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withResponseTag",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withResponseTag"
                         },
                         "method": "GET",
                         "header": [
@@ -100,7 +102,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withBodyParameters",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withBodyParameters"
                         },
                         "method": "POST",
                         "header": [
@@ -172,7 +175,8 @@
                                     "description": "Used for testing that URL parameters will be URL-encoded where needed.",
                                     "disabled": false
                                 }
-                            ]
+                            ],
+                            "raw": "http://localhost/api/withQueryParameters?location_id=consequatur&user_id=me&page=4&filters=consequatur&url_encoded=%2B+%5B%5D%26%3D"
                         },
                         "method": "GET",
                         "header": [
@@ -213,7 +217,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withAuthTag",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withAuthTag"
                         },
                         "method": "GET",
                         "header": [
@@ -254,7 +259,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withEloquentApiResource",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withEloquentApiResource"
                         },
                         "method": "GET",
                         "header": [
@@ -295,7 +301,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withMultipleResponseTagsAndStatusCode",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withMultipleResponseTagsAndStatusCode"
                         },
                         "method": "POST",
                         "header": [
@@ -342,7 +349,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withEloquentApiResourceCollectionClass",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withEloquentApiResourceCollectionClass"
                         },
                         "method": "GET",
                         "header": [
@@ -404,7 +412,8 @@
                                     "value": "consequatur",
                                     "description": ""
                                 }
-                            ]
+                            ],
+                            "raw": "http://localhost/api/echoesUrlParameters/{param}-{param2}/:param3?something=consequatur"
                         },
                         "method": "GET",
                         "header": [
diff --git a/tests/Fixtures/collection_custom_url.json b/tests/Fixtures/collection_custom_url.json
index 69446e22..46791a40 100644
--- a/tests/Fixtures/collection_custom_url.json
+++ b/tests/Fixtures/collection_custom_url.json
@@ -18,7 +18,8 @@
                             "protocol": "http",
                             "host": "yourapp.app",
                             "path": "api/test",
-                            "query": []
+                            "query": [],
+                            "raw": "http://yourapp.app/api/test"
                         },
                         "method": "GET",
                         "header": [
@@ -51,7 +52,8 @@
                             "protocol": "http",
                             "host": "yourapp.app",
                             "path": "api/responseTag",
-                            "query": []
+                            "query": [],
+                            "raw": "http://yourapp.app/api/responseTag"
                         },
                         "method": "POST",
                         "header": [
diff --git a/tests/Fixtures/collection_with_body_parameters.json b/tests/Fixtures/collection_with_body_parameters.json
index d4b1158f..875a9abe 100644
--- a/tests/Fixtures/collection_with_body_parameters.json
+++ b/tests/Fixtures/collection_with_body_parameters.json
@@ -18,7 +18,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withBodyParameters",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withBodyParameters"
                         },
                         "method": "GET",
                         "header": [
diff --git a/tests/Fixtures/collection_with_custom_headers.json b/tests/Fixtures/collection_with_custom_headers.json
index 8c770147..20d736d6 100644
--- a/tests/Fixtures/collection_with_custom_headers.json
+++ b/tests/Fixtures/collection_with_custom_headers.json
@@ -18,7 +18,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api/headers",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/headers"
                         },
                         "method": "GET",
                         "header": [
diff --git a/tests/Fixtures/collection_with_form_data_parameters.json b/tests/Fixtures/collection_with_form_data_parameters.json
index e5595a01..bd91d9c6 100644
--- a/tests/Fixtures/collection_with_form_data_parameters.json
+++ b/tests/Fixtures/collection_with_form_data_parameters.json
@@ -18,7 +18,8 @@
                             "protocol": "http",
                             "host": "localhost",
                             "path": "api\/withFormDataParams",
-                            "query": []
+                            "query": [],
+                            "raw": "http://localhost/api/withFormDataParams"
                         },
                         "method": "GET",
                         "header": [
diff --git a/tests/Fixtures/collection_with_query_parameters.json b/tests/Fixtures/collection_with_query_parameters.json
index 2510e5e1..2698da7d 100644
--- a/tests/Fixtures/collection_with_query_parameters.json
+++ b/tests/Fixtures/collection_with_query_parameters.json
@@ -49,7 +49,8 @@
                                     "description": "Used for testing that URL parameters will be URL-encoded where needed.",
                                     "disabled": false
                                 }
-                            ]
+                            ],
+                            "raw": "http://localhost/api/withQueryParameters?location_id=consequatur&user_id=me&page=4&filters=consequatur&url_encoded=%2B+%5B%5D%26%3D"
                         },
                         "method": "GET",
                         "header": [
diff --git a/tests/Fixtures/collection_with_secure_url.json b/tests/Fixtures/collection_with_secure_url.json
index 4b79cef5..82844a0b 100644
--- a/tests/Fixtures/collection_with_secure_url.json
+++ b/tests/Fixtures/collection_with_secure_url.json
@@ -18,7 +18,8 @@
                             "protocol": "https",
                             "host": "yourapp.app",
                             "path": "api/test",
-                            "query": []
+                            "query": [],
+                            "raw": "https://yourapp.app/api/test"
                         },
                         "method": "GET",
                         "header": [
@@ -51,7 +52,8 @@
                             "protocol": "https",
                             "host": "yourapp.app",
                             "path": "api/responseTag",
-                            "query": []
+                            "query": [],
+                            "raw": "https://yourapp.app/api/responseTag"
                         },
                         "method": "POST",
                         "header": [