Description
The client generated code includes a bit like
// ...fetch data via Axios...
return {
...response,
data: data ?? {},
};
If the API endpoint returns null then the response gets silently coalesced to the empty object {}.
This breaks code that actually expects to handle that null:
const res = await getSomething({ ..., throwOnError: true });
const data: Something | null = res.data;
// This check never actually fails because `null` gets coalesced to `{}`
// which is always truthy.
if (!data) {
return "Something not found!";
}
return `Got ${data.id}.`;
Reproducible example or configuration
Not applicable with the Pet Store API.
To reproduce, you need an endpoint that returns null. This isn't the most common thing in the world (usually you end up returning 404 instead of just 200 with a null response body).
OpenAPI specification (optional)
No response
System information (optional)
No response
Description
The client generated code includes a bit like
If the API endpoint returns
nullthen the response gets silently coalesced to the empty object{}.This breaks code that actually expects to handle that
null:Reproducible example or configuration
Not applicable with the Pet Store API.
To reproduce, you need an endpoint that returns
null. This isn't the most common thing in the world (usually you end up returning 404 instead of just 200 with anullresponse body).OpenAPI specification (optional)
No response
System information (optional)
No response