i'm trying to use https://github.com/swagger-api/swagger-js/. However one early issue i ran into is that i wish to use await to wait for the swaggerclient to finish loading the swagger specification.
Instead of having this long dot chain
new SwaggerClient({ spec })
.then(client => client.apis.default.getUserById(...));
I would like do something like
async function getUserById(id) {
const client = await new SwaggerClient({ spec });
const default_api = client.apis.default;
const user_with_id = await default_api.getUserById(...);
}
await getUserById(5)
But await does not seem to work with SwaggerClient my IDE warns me that "await has no effect" and when removed the code just says that default_api is undefined