Skip to content

Commit ea0c5b5

Browse files
authored
Merge pull request #153 from hans-thomas/151-urls-for-try-it-feature
Fix incorrect URLs generated for "Try it" feature
2 parents 5add876 + 4bc635f commit ea0c5b5

11 files changed

+12
-18
lines changed

src/Services/SwaggerService.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Http\Request;
77
use Illuminate\Http\Testing\File;
88
use Illuminate\Support\Arr;
9+
use Illuminate\Support\Facades\URL;
910
use Illuminate\Support\Str;
1011
use ReflectionClass;
1112
use RonasIT\AutoDoc\Exceptions\DocFileNotExistsException;
@@ -140,7 +141,7 @@ protected function generateEmptyData(): array
140141
$data = [
141142
'openapi' => self::OPEN_API_VERSION,
142143
'servers' => [
143-
['url' => $this->getAppUrl() . $this->config['basePath']],
144+
['url' => URL::query($this->config['basePath'])],
144145
],
145146
'paths' => [],
146147
'components' => [
@@ -158,13 +159,6 @@ protected function generateEmptyData(): array
158159
return $data;
159160
}
160161

161-
protected function getAppUrl(): string
162-
{
163-
$url = config('app.url');
164-
165-
return str_replace(['http://', 'https://', '/'], '', $url);
166-
}
167-
168162
protected function generateSecurityDefinition(): ?array
169163
{
170164
if (empty($this->security)) {

tests/fixtures/SwaggerServiceTest/tmp_data_get_route_parameters_description.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": {

tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_and_info.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": [],

tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_jwt.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": [],

tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_laravel.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": [],

tests/fixtures/SwaggerServiceTest/tmp_data_request_with_empty_data_query.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": [],

tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_closure_request.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": {

tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": {

tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_jwt_security.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": {

tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_laravel_security.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": {

tests/fixtures/SwaggerServiceTest/tmp_data_search_roles_request_query_security.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"openapi": "3.1.0",
33
"servers": [
44
{
5-
"url": "localhost/"
5+
"url": "http://localhost"
66
}
77
],
88
"paths": {

0 commit comments

Comments
 (0)