You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So when I call client.apis.rfc.calendarlist(opts, {}) I get TypeError: client.apis.rfc is undefined.
To reproduce...
Steps to reproduce the behavior:
Make your yaml file invalid
Expected behavior
If the yaml file could not be parsed correctly then SwaggerClient should never have entered the first then providing a broken (client), it should throw so it can be handled/logged in the catch.
I expect that the .then((client) =>{}) should not be called. The .catch((err)=>{}) should be called instead with a message about why the client could not be created.
Screenshots
Additional context or thoughts
If the client is not perfectly created then it should fail.
Additional information: if the (client) => {throw new Error('help!')} or TypeError from the failed client then .catch(err => { err is {} } which is unhelpful. The exception/error is consumed.
My workaround is:
.then(
(client) => {
// https://github.com/swagger-api/swagger-js/issues/2953
try {
return clientCall(client)
} catch (err) {
console.error(err)
throw err // exception is consumed but don't know what else to do with it!
}
}
).then(
(response) => {
/// normal stuff
}
).catch(
(err) => {
console.log('API-E:' + debug + ':error: ' + JSON.stringify(err, null, 4)) // err is always {}
if (err.response === undefined) {
return { error: true, type: 'CLIENT', message: 'Client side error', payload: null }
}
}
)
As you can see, there is a lot of stuff that shouldn't really be there and it has a bad code smell.
The text was updated successfully, but these errors were encountered:
Q&A (please complete the following information)
Content & configuration
Swagger/OpenAPI definition. This is an example of the malformed document. It invalidated the whole client.
Swagger-Client usage:
Describe the bug you're encountering
When the yaml spec is incorrect/malformed/invalid (in my case I had 2 parameter sections by mistake), the client is created but is empty like this:
So when I call
client.apis.rfc.calendarlist(opts, {})
I getTypeError: client.apis.rfc is undefined
.To reproduce...
Steps to reproduce the behavior:
Expected behavior
If the yaml file could not be parsed correctly then SwaggerClient should never have entered the first
then
providing a broken(client)
, it should throw so it can be handled/logged in thecatch
.I expect that the
.then((client) =>{})
should not be called. The.catch((err)=>{})
should be called instead with a message about why the client could not be created.Screenshots
Additional context or thoughts
If the client is not perfectly created then it should fail.
Additional information: if the
(client) => {throw new Error('help!')}
orTypeError
from the failed client then.catch(err => { err is {} }
which is unhelpful. The exception/error is consumed.My workaround is:
As you can see, there is a lot of stuff that shouldn't really be there and it has a bad code smell.
The text was updated successfully, but these errors were encountered: