How to use the swagger-client.resolve function in swagger-client

To help you get started, we’ve selected a few swagger-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / devportal / source / src / app / data / APIClient.jsx View on Github external
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();
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / store-new / source / src / app / data / APIClient.jsx View on Github external
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];
            }
        )
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.publisher.feature / src / main / resources / publisher-new / source / src / app / data / APIClient.js View on Github external
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);
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.publisher.feature / src / main / resources / publisher / source / src / app / data / APIClient.js View on Github external
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]
            );
        });
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / store / source / src / app / data / APIClient.jsx View on Github external
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);
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.admin.feature / src / main / resources / admin / source / src / app / data / APIClient.js View on Github external
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);
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.publisher.feature / src / main / resources / publisher / source / src / app / components / Apis / Details / Resources / Resources.jsx View on Github external
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);
        });
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.publisher.feature / src / main / resources / publisher-new / source / src / app / data / APIClient.js View on Github external
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]
            );
        });
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / store / source / src / app / data / APIClient.jsx View on Github external
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];
        });
    }
github wso2 / carbon-apimgt / features / apimgt / org.wso2.carbon.apimgt.store.feature / src / main / resources / devportal / source / src / app / data / APIClient.jsx View on Github external
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];
        } );
    }