Skip to content

Commit ae31b48

Browse files
committed
feat: added swagger index
1 parent aa549d1 commit ae31b48

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>{{config('l5-swagger.documentations.'.$documentation.'.api.title')}}</title>
6+
<link rel="stylesheet" type="text/css" href="{{ l5_swagger_asset($documentation, 'swagger-ui.css') }}">
7+
<link rel="icon" type="image/png" href="{{ l5_swagger_asset($documentation, 'favicon-32x32.png') }}" sizes="32x32"/>
8+
<link rel="icon" type="image/png" href="{{ l5_swagger_asset($documentation, 'favicon-16x16.png') }}" sizes="16x16"/>
9+
<style>
10+
html
11+
{
12+
box-sizing: border-box;
13+
overflow: -moz-scrollbars-vertical;
14+
overflow-y: scroll;
15+
}
16+
*,
17+
*:before,
18+
*:after
19+
{
20+
box-sizing: inherit;
21+
}
22+
23+
body {
24+
margin:0;
25+
background: #fafafa;
26+
}
27+
</style>
28+
</head>
29+
30+
<body>
31+
<div id="swagger-ui"></div>
32+
33+
<script src="{{ l5_swagger_asset($documentation, 'swagger-ui-bundle.js') }}"></script>
34+
<script src="{{ l5_swagger_asset($documentation, 'swagger-ui-standalone-preset.js') }}"></script>
35+
<script>
36+
window.onload = function() {
37+
// Build a system
38+
const ui = SwaggerUIBundle({
39+
dom_id: '#swagger-ui',
40+
url: "{!! $urlToDocs !!}",
41+
operationsSorter: {!! isset($operationsSorter) ? '"' . $operationsSorter . '"' : 'null' !!},
42+
configUrl: {!! isset($configUrl) ? '"' . $configUrl . '"' : 'null' !!},
43+
validatorUrl: {!! isset($validatorUrl) ? '"' . $validatorUrl . '"' : 'null' !!},
44+
oauth2RedirectUrl: "{{ route('l5-swagger.'.$documentation.'.oauth2_callback', [], $useAbsolutePath) }}",
45+
46+
requestInterceptor: function(request) {
47+
request.headers['X-CSRF-TOKEN'] = '{{ csrf_token() }}';
48+
return request;
49+
},
50+
51+
presets: [
52+
SwaggerUIBundle.presets.apis,
53+
SwaggerUIStandalonePreset
54+
],
55+
56+
plugins: [
57+
SwaggerUIBundle.plugins.DownloadUrl
58+
],
59+
60+
layout: "StandaloneLayout",
61+
docExpansion : "{!! config('l5-swagger.defaults.ui.display.doc_expansion', 'none') !!}",
62+
deepLinking: true,
63+
filter: {!! config('l5-swagger.defaults.ui.display.filter') ? 'true' : 'false' !!},
64+
persistAuthorization: "{!! config('l5-swagger.defaults.ui.authorization.persist_authorization') ? 'true' : 'false' !!}",
65+
66+
})
67+
68+
window.ui = ui
69+
70+
@if(in_array('oauth2', array_column(config('l5-swagger.defaults.securityDefinitions.securitySchemes'), 'type')))
71+
ui.initOAuth({
72+
usePkceWithAuthorizationCodeGrant: "{!! (bool)config('l5-swagger.defaults.ui.authorization.oauth2.use_pkce_with_authorization_code_grant') !!}"
73+
})
74+
@endif
75+
}
76+
</script>
77+
</body>
78+
</html>

0 commit comments

Comments
 (0)