Skip to content

Commit fa0ca9b

Browse files
kazrael2119v-jiaodiMaryGao
authored
[sample generation] Fix serilaization name and name inconsistancy for body parameter (#3340)
* [sample gen] Failed to normalize optional parameter name * update ut * Update bodyOptionalParameterName.md * Fix the request body name * update * Update bodyOptionalParameterName.md --------- Co-authored-by: Jiao Di (MSFT) <80496810+v-jiaodi@users.noreply.github.com> Co-authored-by: Mary Gao <yanmeigao1210@gmail.com>
1 parent 33fa6f2 commit fa0ca9b

2 files changed

Lines changed: 447 additions & 4 deletions

File tree

packages/typespec-ts/src/modular/emitSamples.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ function prepareExampleParameters(
323323
}
324324
// required/optional body parameters
325325
const bodyParam = method.operation.bodyParam;
326-
const bodyName = bodyParam?.serializedName;
327-
const bodyExample = parameterMap[bodyName ?? ""];
328-
if (bodyName && bodyExample && bodyExample.value) {
326+
const bodySerializeName = bodyParam?.serializedName;
327+
const bodyExample = parameterMap[bodySerializeName ?? ""];
328+
if (bodySerializeName && bodyExample && bodyExample.value) {
329329
if (
330330
isSpreadBodyParameter(bodyParam) &&
331331
bodyParam.type.kind === "model" &&
@@ -348,7 +348,7 @@ function prepareExampleParameters(
348348
} else {
349349
result.push(
350350
prepareExampleValue(
351-
bodyName,
351+
bodyParam.name,
352352
bodyExample.value,
353353
bodyParam.optional,
354354
bodyParam.onClient

0 commit comments

Comments
 (0)