first of all i am using a bit modified version of the standard html/js code offered from swagger-ui.
Changes are rather simple, instead of using only a single SwaggerUI element like:
window.swaggerUi = new SwaggerUi({
....
window.swaggerUi.load();
we iterate over them and create lots of swaggerUI elements:
function addSwaggerUI(url, dom_id, host){
window[dom_id] = new SwaggerUi({
....
window[domId].load();
this is our iteration:
var services = [{SERVICE_SPECS}];
var doc_container = document.getElementById('service-doc-container');
var index = 0;
services.forEach(function(serviceSpec) {
var swaggerNode = document.createElement('div');
swaggerNode.id = "swagger-ui-container-" + index;
swaggerNode.className = "swagger-ui-wrap";
var messageNode = document.createElement('div');
messageNode.id = "message-bar-" + index;
messageNode.className = "swagger-ui-wrap";
doc_container.appendChild(swaggerNode);
doc_container.appendChild(messageNode);
log("adding service documentation for " + serviceSpec);
addServiceDocumentation(serviceSpec, swaggerNode.id, "{SERVICE_HOST}");
index++;
});
This worked quiet well until we started using securityDefinitions oAuth:
"securityDefinitions": {
"OauthSecurity": {
"type": "oauth2",
"authorizationUrl": "http://localhost/oauth/dialog",
"flow": "implicit",
"scopes":{
"write:sessions":"kill sessions",
"read:sessions":"get sessions"
}
}
Now i get on each swaggerUI this error:
index.js:24 Uncaught TypeError: Cannot read property 'api' of undefined
Original swaggercode:https://github.com/swagger-api/swagger-ui/tree/master/dist see index.html
Can someone help to fix this?
(Alternative solution: Anyone know of another way to add multiple web apis from different json files on one html page? )
UPDATE: So i looked at the generated page from swagger.petstore.io and found something called 'authorzie-wrapper'it is possible that this element is missing at my code.