forked from seokho-son/cb-mapui
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>CB-Tumblebug API Dashboard</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
flex-direction: column; | ||
height: 100vh; | ||
width: 100vw; | ||
overflow: hidden; | ||
} | ||
|
||
#swagger-container { | ||
width: 100%; /* Swagger UI takes the full width */ | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
#swagger-header { | ||
height: 50px; /* Header height */ | ||
background-color: #262626; | ||
color: #fcfcfc; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 20px; | ||
font-weight: bold; | ||
} | ||
#swagger-ui-container { | ||
height: calc(100% - 50px); /* Adjust height based on header */ | ||
overflow-y: scroll; | ||
} | ||
</style> | ||
|
||
<!-- Load Swagger UI styles --> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.17.14/swagger-ui.css"> | ||
</head> | ||
<body> | ||
<div id="swagger-header">CB-Tumblebug API Dashboard</div> | ||
<div id="swagger-container"> | ||
<div id="swagger-ui-container"></div> | ||
</div> | ||
|
||
<!-- Load the latest Swagger UI scripts --> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.17.14/swagger-ui-bundle.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/5.17.14/swagger-ui-standalone-preset.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/js-yaml@3.14.0/dist/js-yaml.min.js"></script> | ||
|
||
<script> | ||
// Basic authentication details | ||
const username = 'default'; | ||
const password = 'default'; | ||
const credentials = btoa(username + ':' + password); | ||
const authHeader = 'Basic ' + credentials; | ||
|
||
console.log('Starting to fetch YAML'); | ||
|
||
// Fetch the YAML file with authentication | ||
fetch('http://localhost:1323/tumblebug/api/doc.yaml', { | ||
headers: { | ||
'Authorization': authHeader | ||
} | ||
}) | ||
.then(response => { | ||
console.log('Fetch response:', response); | ||
if (!response.ok) { | ||
throw new Error('Authentication failed: ' + response.statusText); | ||
} | ||
return response.text(); | ||
}) | ||
.then(yamlText => { | ||
console.log('YAML fetched successfully'); | ||
const spec = jsyaml.load(yamlText); | ||
|
||
console.log('YAML parsed successfully'); | ||
|
||
// Initialize Swagger UI | ||
const ui = SwaggerUIBundle({ | ||
url: 'http://localhost:1323/tumblebug/api/doc.yaml', | ||
dom_id: '#swagger-ui-container', | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
docExpansion: "list", | ||
layout: "BaseLayout", | ||
deepLinking: true, // Enable deep linking | ||
tagsSorter: "alpha", | ||
operationsSorter: "alpha", | ||
requestInterceptor: (request) => { | ||
request.headers['Authorization'] = authHeader; | ||
return request; | ||
}, | ||
validatorUrl: null, | ||
onComplete: () => { | ||
console.log('Swagger UI loaded'); | ||
} | ||
}); | ||
|
||
console.log('Swagger UI initialized'); | ||
}) | ||
.catch(error => { | ||
console.error('Failed to load API specification:', error); | ||
alert('Failed to load API specification: ' + error.message); | ||
}); | ||
</script> | ||
</body> | ||
</html> |