Browse Source

Fix baseUrl contain protocol as default

Reza Rachmanuddin 3 years ago
parent
commit
d5212cb1b3
2 changed files with 2 additions and 22 deletions
  1. 0 9
      config/scribe.php
  2. 2 13
      src/Writing/PostmanCollectionWriter.php

+ 0 - 9
config/scribe.php

@@ -280,15 +280,6 @@ INTRO
         'overrides' => [
         'overrides' => [
             // 'info.version' => '2.0.0',
             // 'info.version' => '2.0.0',
         ],
         ],
-
-        /*
-         * Generate baseUrl variable contain protocol (http/https).
-         *
-         * Example :
-         * `true` -> baseUrl = http://localhost
-         * `false` -> baseUrl = localhost
-         */
-        'is_base_url_contain_protocol' => false,
     ],
     ],
 
 
     /*
     /*

+ 2 - 13
src/Writing/PostmanCollectionWriter.php

@@ -34,10 +34,6 @@ class PostmanCollectionWriter
      */
      */
     public function generatePostmanCollection(array $groupedEndpoints): array
     public function generatePostmanCollection(array $groupedEndpoints): array
     {
     {
-        $baseUrl = !$this->config->get('postman.is_base_url_contain_protocol')
-            ? (parse_url($this->baseUrl, PHP_URL_HOST) ?: $this->baseUrl) // if there's no protocol, parse_url might fail
-            : $this->baseUrl;
-
         $collection = [
         $collection = [
             'variable' => [
             'variable' => [
                 [
                 [
@@ -45,7 +41,7 @@ class PostmanCollectionWriter
                     'key' => 'baseUrl',
                     'key' => 'baseUrl',
                     'type' => 'string',
                     'type' => 'string',
                     'name' => 'string',
                     'name' => 'string',
-                    'value' => $baseUrl,
+                    'value' => $this->baseUrl,
                 ],
                 ],
             ],
             ],
             'info' => [
             'info' => [
@@ -234,10 +230,6 @@ class PostmanCollectionWriter
             }, $endpointData->uri),
             }, $endpointData->uri),
         ];
         ];
 
 
-        if (!$this->config->get('postman.is_base_url_contain_protocol')) {
-            $base['protocol'] = Str::startsWith($this->baseUrl, 'https') ? 'https' : 'http';
-        }
-
         $query = [];
         $query = [];
         [$where, $authParam] = $this->getAuthParamToExclude();
         [$where, $authParam] = $this->getAuthParamToExclude();
         /**
         /**
@@ -280,10 +272,7 @@ class PostmanCollectionWriter
         $queryString = collect($base['query'] ?? [])->map(function ($queryParamData) {
         $queryString = collect($base['query'] ?? [])->map(function ($queryParamData) {
             return $queryParamData['key'] . '=' . $queryParamData['value'];
             return $queryParamData['key'] . '=' . $queryParamData['value'];
         })->implode('&');
         })->implode('&');
-        $baseHost = !$this->config->get('postman.is_base_url_contain_protocol')
-            ? sprintf('%s://%s', $base['protocol'], $base['host'])
-            : $base['host'];
-        $base['raw'] = sprintf('%s/%s%s', $baseHost, $base['path'], $queryString ? "?{$queryString}" : null);
+        $base['raw'] = sprintf('%s/%s%s', $base['host'], $base['path'], $queryString ? "?{$queryString}" : null);
 
 
         $urlParams = collect($endpointData->urlParameters);
         $urlParams = collect($endpointData->urlParameters);
         if ($urlParams->isEmpty()) {
         if ($urlParams->isEmpty()) {