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
An author may write the API Method: var result = await someServiceMethod(); if(result == null) { retrun Ok(); } return Ok(result);
When the Client Dev uses Nswag to generate a proxy, the if statement for that API Method would be: if (status_ == 200) { var objectResponse_ = await ReadObjectResponseAsync<SomeMethodResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new SomeAPIException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); } return objectResponse_.Object; }
BUT it is not an error my proposal is this:
return default: if (status_ == 200) { var objectResponse_ = await ReadObjectResponseAsync<SomeMethodResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { **return default;** } return objectResponse_.Object; }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
An author may write the API Method:
var result = await someServiceMethod(); if(result == null) { retrun Ok(); } return Ok(result);
When the Client Dev uses Nswag to generate a proxy, the if statement for that API Method would be:
if (status_ == 200) { var objectResponse_ = await ReadObjectResponseAsync<SomeMethodResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new SomeAPIException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); } return objectResponse_.Object; }
BUT it is not an error
my proposal is this:
return default:
if (status_ == 200) { var objectResponse_ = await ReadObjectResponseAsync<SomeMethodResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { **return default;** } return objectResponse_.Object; }
Beta Was this translation helpful? Give feedback.
All reactions