Skip to content

Commit

Permalink
Update sdk-tweak-model.ts (#1317)
Browse files Browse the repository at this point in the history
* Update sdk-tweak-model.ts

For head API, the response should be 204

* Update sdk-tweak-model.ts
  • Loading branch information
dolauli committed Mar 11, 2024
1 parent ba17668 commit c33b901
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions powershell/plugins/sdk-tweak-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ async function tweakOperation(state: State) {
respCountWithBody = schemas.size + specialBinaryResponse;
const isHead = operation.requests && operation.requests[0].protocol.http?.method === 'head';
if (isHead) {
initializeResponseBody = '_result.Body = (_statusCode == System.Net.HttpStatusCode.OK);';
const succeedCode = operation.responses.filter(r => (<string>r.protocol.http?.statusCodes[0]).startsWith('2'))[0].protocol.http?.statusCodes[0];
initializeResponseBody = `_result.Body = (_statusCode == System.Net.HttpStatusCode.${(<any>StatusCodes)[succeedCode]});`;
}
const responses = operation.responses.filter(r => (<any>r).schema);
const hasHeaderResponse = operation.responses.some(r => (<any>r).protocol.http.headers);
Expand Down Expand Up @@ -469,4 +470,4 @@ export async function tweakSdkModelPlugin(service: Host) {
}
throw E;
}
}
}

0 comments on commit c33b901

Please sign in to comment.