Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(host, args = {}) {
this.host = host || location.host;
this.environment = Utils.getCurrentEnvironment();
const authorizations = {
OAuth2Security: {
token: { access_token: AuthManager.getUser() ? AuthManager.getUser().getPartialToken() : '' },
},
};
SwaggerClient.http.withCredentials = true;
const promisedResolve = SwaggerClient.resolve({ url: Utils.getSwaggerURL(), requestInterceptor: (request) => { request.headers.Accept = 'text/yaml'; } });
APIClient.spec = promisedResolve;
this._client = promisedResolve.then((resolved) => {
const argsv = Object.assign(
args,
{
spec: this._fixSpec(resolved.spec),
authorizations,
requestInterceptor: this._getRequestInterceptor(),
responseInterceptor: this._getResponseInterceptor(),
},
);
SwaggerClient.http.withCredentials = true;
return new SwaggerClient(argsv);
} );
this._client.catch(AuthManager.unauthorizedErrorHandler);
this.mutex = new Mutex();
static getScopeForResource(resourcePath, resourceMethod) {
if (!APIClient.spec) {
SwaggerClient.http.withCredentials = true;
APIClient.spec = SwaggerClient.resolve({url: Utils.getSwaggerURL()});
}
return APIClient.spec.then(
resolved => {
return resolved.spec.paths[resourcePath] && resolved.spec.paths[resourcePath][resourceMethod] && resolved.spec.paths[resourcePath][resourceMethod].security[0].OAuth2Security[0];
}
)
}
constructor(environment, args = {}) {
this.environment = environment || Utils.getCurrentEnvironment();
SwaggerClient.http.withCredentials = true;
const promisedResolve = SwaggerClient.resolve({
url: Utils.getSwaggerURL(),
requestInterceptor: (request) => {
request.headers.Accept = 'text/yaml';
},
});
APIClient.spec = promisedResolve;
this._client = promisedResolve.then((resolved) => {
const argsv = Object.assign(args, {
spec: this._fixSpec(resolved.spec),
requestInterceptor: this._getRequestInterceptor(),
responseInterceptor: this._getResponseInterceptor(),
});
SwaggerClient.http.withCredentials = true;
return new SwaggerClient(argsv);
});
this._client.catch(AuthManager.unauthorizedErrorHandler);
static getScopeForResource(resourcePath, resourceMethod) {
if (!APIClient.spec) {
SwaggerClient.http.withCredentials = true;
APIClient.spec = SwaggerClient.resolve({ url: Utils.getSwaggerURL() });
}
return APIClient.spec.then((resolved) => {
return (
resolved.spec.paths[resourcePath]
&& resolved.spec.paths[resourcePath][resourceMethod]
&& resolved.spec.paths[resourcePath][resourceMethod].security[0].OAuth2Security[0]
);
});
}
constructor(host, args = {}) {
this.host = host || location.host;
const authorizations = {
OAuth2Security: {
token: { access_token: AuthManager.getUser() ? AuthManager.getUser().getPartialToken() : '' },
},
};
SwaggerClient.http.withCredentials = true;
const promisedResolve = SwaggerClient.resolve({ url: Utils.getSwaggerURL() });
APIClient.spec = promisedResolve;
this._client = promisedResolve.then((resolved) => {
const argsv = Object.assign(args, {
spec: this._fixSpec(resolved.spec),
authorizations,
requestInterceptor: this._getRequestInterceptor(),
responseInterceptor: this._getResponseInterceptor(),
});
SwaggerClient.http.withCredentials = true;
return new SwaggerClient(argsv);
});
this._client.catch(AuthManager.unauthorizedErrorHandler);
}
constructor(host, args = {}) {
this.host = host || location.host;
const authorizations = {
OAuth2Security: {
token: {access_token: AuthManager.getUser().getPartialToken()}
}
};
SwaggerClient.http.withCredentials = true;
let promisedResolve = SwaggerClient.resolve({url: Utils.getSwaggerURL()});
APIClient.spec = promisedResolve;
this._client = promisedResolve.then(
resolved => {
const argsv = Object.assign(args,
{
spec: this._fixSpec(resolved.spec),
authorizations: authorizations,
requestInterceptor: this._getRequestInterceptor(),
responseInterceptor: this._getResponseInterceptor()
});
SwaggerClient.http.withCredentials = true;
return new SwaggerClient(argsv);
}
);
this._client.catch(AuthManager.unauthorizedErrorHandler);
}
function resolveAndUpdateSpec(rawSpec) {
return Swagger.resolve({ spec: rawSpec }).then(({ spec, errors }) => {
const value = spec;
delete value.$$normalized;
operationsDispatcher({ action: 'init', data: value.paths });
setOpenAPISpec(value);
setSpecErrors(errors);
});
}
static getScopeForResource(resourcePath, resourceMethod) {
if (!APIClient.spec) {
SwaggerClient.http.withCredentials = true;
APIClient.spec = SwaggerClient.resolve({ url: Utils.getSwaggerURL() });
}
return APIClient.spec.then((resolved) => {
return (
resolved.spec.paths[resourcePath] &&
resolved.spec.paths[resourcePath][resourceMethod] &&
resolved.spec.paths[resourcePath][resourceMethod].security[0].OAuth2Security[0]
);
});
}
static getScopeForResource(resourcePath, resourceMethod) {
if (!APIClient.spec) {
SwaggerClient.http.withCredentials = true;
APIClient.spec = SwaggerClient.resolve({ url: Utils.getSwaggerURL() });
}
return APIClient.spec.then((resolved) => {
return resolved.spec.paths[resourcePath] && resolved.spec.paths[resourcePath][resourceMethod] && resolved.spec.paths[resourcePath][resourceMethod].security[0].OAuth2Security[0];
});
}
static getScopeForResource(resourcePath, resourceMethod) {
if (!APIClient.spec) {
SwaggerClient.http.withCredentials = true;
APIClient.spec = SwaggerClient.resolve({ url: Utils.getSwaggerURL() });
}
return APIClient.spec.then((resolved) => {
return resolved.spec.paths[resourcePath] && resolved.spec.paths[resourcePath][resourceMethod] && resolved.spec.paths[resourcePath][resourceMethod].security[0].OAuth2Security[0];
} );
}