Skip to content

Commit

Permalink
Merge pull request #4521 from microsoft/bugfix/ts-deserialization-casing
Browse files Browse the repository at this point in the history
- fixes casing issue in deserialization of response content in TypeScript
  • Loading branch information
andrueastman authored Apr 19, 2024
2 parents 345d080 + 0f0b9dc commit 3987aae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Fixed a bug where TypeScript deserialization would fail on Uppercase properties.[#4479](https://github.com/microsoft/kiota/issues/4479)
- Changed URI template generation to reuse templates when required templates are absent across operations.
- Updated reserved name providers for Java and Php so that "object" can be escaped.
- Do not generate CS8603 warnings when enabling backing store in CSharp generation.
- Updated reserved name providers for Java and Php so that "object" can be escaped.
- Do not generate CS8603 warnings when enabling backing store in CSharp generation.

## [1.13.0] - 2024-04-04

Expand Down
7 changes: 3 additions & 4 deletions src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,13 @@ private void WriteDeserializerFunction(CodeFunction codeFunction, LanguageWriter

foreach (var otherProp in properties)
{
var keyName = !string.IsNullOrWhiteSpace(otherProp.SerializationName) ? otherProp.SerializationName.ToFirstCharacterLowerCase() : otherProp.Name.ToFirstCharacterLowerCase();
var suffix = otherProp.Name.Equals(primaryErrorMappingKey, StringComparison.Ordinal) ? primaryErrorMapping : string.Empty;
if (keyName.Equals(BackingStoreEnabledKey, StringComparison.Ordinal))
writer.WriteLine($"\"{keyName}\": n => {{ {param.Name.ToFirstCharacterLowerCase()}.{otherProp.Name.ToFirstCharacterLowerCase()} = true;{suffix} }},");
if (otherProp.Kind is CodePropertyKind.BackingStore)
writer.WriteLine($"\"{BackingStoreEnabledKey}\": n => {{ {param.Name.ToFirstCharacterLowerCase()}.{otherProp.Name.ToFirstCharacterLowerCase()} = true;{suffix} }},");
else
{
var defaultValueSuffix = GetDefaultValueLiteralForProperty(otherProp) is string dft && !string.IsNullOrEmpty(dft) ? $" ?? {dft}" : string.Empty;
writer.WriteLine($"\"{keyName}\": n => {{ {param.Name.ToFirstCharacterLowerCase()}.{otherProp.Name.ToFirstCharacterLowerCase()} = n.{GetDeserializationMethodName(otherProp.Type, codeFunction)}{defaultValueSuffix};{suffix} }},");
writer.WriteLine($"\"{otherProp.WireName}\": n => {{ {param.Name.ToFirstCharacterLowerCase()}.{otherProp.Name.ToFirstCharacterLowerCase()} = n.{GetDeserializationMethodName(otherProp.Type, codeFunction)}{defaultValueSuffix};{suffix} }},");
}
}

Expand Down

0 comments on commit 3987aae

Please sign in to comment.