I'm trying to create a SwaggerUI page in my dev environment, and I'm trying
to override the HOST and SCHEME of the API described in my JSON spec.
The SwaggerUI init code is very simple, and I tried to crush the values in
the onComplete() callback in this way:
var swaggerUi = new SwaggerUi({
url: './cbrain-4.5.0-swagger.json',
dom_id: 'swagger-ui-container',
defaultModelRendering: 'schema',
onComplete: function(swaggerApi, swaggerUi) {
// Overide the built-in CBRAIN service config to use the current
page's.
var host = window.location.host; // can include
the port number
var scheme = window.location.protocol.replace(/:/,""); // "http" or
"https"
swaggerApi.scheme = scheme;
swaggerApi.host = host;
swaggerApi.swaggerObject.schemes = [ scheme ];
swaggerApi.swaggerObject.host = host;
}
});
swaggerUi.load();
As you can see, I found 4 properties in both the swaggerAPI and internal
swaggerObject where I can change the values; it works in that the values
*are* changed, but it seems it makes no difference because the UI has
already been built at this point and all the "Try it out!" dialogs are all
configured to use the old HOST and SCHEME that were defined in the JSON.
My question is, how can I initialize a swaggerUI with a URL for a JSON
spec, yet get the UI built with a different HOST and SCHEME ? Is there some
kind of callback I can provide such that the values of the JSON object be
updated BEFORE the UI is built?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.