Skip to content

Commit a3c192a

Browse files
authored
Merge pull request #11 from Kambarov/feat/scalar-several-documentations
display several documents based on the domain
2 parents e5e05f6 + b2cb6bc commit a3c192a

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

resources/views/scalar/index.blade.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@
1616

1717
<!-- Initialize the Scalar API Reference -->
1818
<script>
19-
Scalar.createApiReference('#app', {
20-
// The URL of the OpenAPI/Swagger document
21-
url: "{!! $documentationFile !!}",
22-
// Avoid CORS issues
23-
proxyUrl: 'https://proxy.scalar.com',
24-
})
19+
Scalar.createApiReference('#app', @json($files))
2520
</script>
2621
</body>
2722
</html>

src/Http/Controllers/ScalarController.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,25 @@ class ScalarController
1313
public function index()
1414
{
1515
$filename = config('api-documentation.ui.storage.filename', null);
16-
$oldFile = $filename ? asset($filename) : null;
16+
$oldFile[] = [
17+
'name' => $filename,
18+
'url' => $filename ? asset($filename) : null,
19+
'proxyUrl' => 'https://proxy.scalar.com'
20+
];
21+
22+
$files = [];
23+
foreach (config('api-documentation.ui.storage.files', []) as $key => $file) {
24+
if ($this->check($key)) {
25+
$files[] = [
26+
'title' => $file['filename'],
27+
'url' => asset($file['filename']),
28+
'proxyUrl' => 'https://proxy.scalar.com'
29+
];
30+
}
31+
}
1732

1833
return view('api-documentation::scalar.index', [
19-
'documentationFile' => $oldFile,
34+
'files' => !empty($files) ? $files : $oldFile,
2035
]);
2136
}
2237
}

0 commit comments

Comments
 (0)