Skip to content

Commit

Permalink
Merge pull request #153 from hans-thomas/151-urls-for-try-it-feature
Browse files Browse the repository at this point in the history
Fix incorrect URLs generated for "Try it" feature
DenTray authored Jan 22, 2025
2 parents 5add876 + 4bc635f commit ea0c5b5
Showing 11 changed files with 12 additions and 18 deletions.
10 changes: 2 additions & 8 deletions src/Services/SwaggerService.php
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
use Illuminate\Http\Request;
use Illuminate\Http\Testing\File;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use ReflectionClass;
use RonasIT\AutoDoc\Exceptions\DocFileNotExistsException;
@@ -140,7 +141,7 @@ protected function generateEmptyData(): array
$data = [
'openapi' => self::OPEN_API_VERSION,
'servers' => [
['url' => $this->getAppUrl() . $this->config['basePath']],
['url' => URL::query($this->config['basePath'])],
],
'paths' => [],
'components' => [
@@ -158,13 +159,6 @@ protected function generateEmptyData(): array
return $data;
}

protected function getAppUrl(): string
{
$url = config('app.url');

return str_replace(['http://', 'https://', '/'], '', $url);
}

protected function generateSecurityDefinition(): ?array
{
if (empty($this->security)) {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": [],
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": [],
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": [],
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": [],
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": {
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"openapi": "3.1.0",
"servers": [
{
"url": "localhost/"
"url": "http://localhost"
}
],
"paths": {

0 comments on commit ea0c5b5

Please sign in to comment.