Skip to content

Commit

Permalink
Merge pull request #3597 from microsoft/bugfix/ts-object-props
Browse files Browse the repository at this point in the history
- fixes a serialization bug in typescript
  • Loading branch information
baywet authored Oct 31, 2023
2 parents 0f1d34e + 307a41f commit bf5f5a4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The lock file now contains the relative path to the description in case of local path. [#3151](https://github.com/microsoft/kiota/issues/3151)
- Fixes a bug where query parameters would be missing in CSharp for ebc clients. [#3583](https://github.com/microsoft/kiota/issues/3583)
- Fixed bug where base64url and decimal types would not be generated properly in Java.
- Fixed a bug where object properties would not be serialized in TypeScript. [#3596](https://github.com/microsoft/kiota/issues/3596)
- Fixed bug where symbol name cleanup would not work on forward single quotes characters [#3426](https://github.com/microsoft/kiota/issues/3426).
- Fixed a bug where a "models" API path segment in the description would derail generation. [#3400](https://github.com/microsoft/kiota/issues/3400)
- Changes to the configuration of RequestInformation are preserved instead of being overwritten. [#3401](https://github.com/microsoft/kiota/pull/3401).
Expand Down
5 changes: 3 additions & 2 deletions src/Kiota.Builder/Writers/TypeScript/CodeFunctionWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ private string GetFactoryMethodName(CodeTypeBase targetClassType, CodeMethod cur

private string? getSerializerAlias(CodeType propType, CodeFunction codeFunction, string propertySerializerName)
{
if (propType.TypeDefinition?.Parent is not CodeNamespace parentNameSpace) return string.Empty;
var serializationFunction = parentNameSpace.FindChildByName<CodeFunction>(propertySerializerName);
if (propType.TypeDefinition?.GetImmediateParentOfType<CodeFile>() is not CodeFile parentFile ||
parentFile.FindChildByName<CodeFunction>(propertySerializerName, false) is not CodeFunction serializationFunction)
return string.Empty;
return conventions.GetTypeString(new CodeType { TypeDefinition = serializationFunction }, codeFunction, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public async Task WritesSerializerBody()
Assert.Contains("writeStringValue", result);
Assert.Contains("writeCollectionOfPrimitiveValues", result);
Assert.Contains("writeCollectionOfObjectValues", result);
Assert.Contains("serializeSomeComplexType", result);
Assert.Contains("writeEnumValue", result);
Assert.Contains($"writer.writeAdditionalData", result);
Assert.Contains("definedInParent", result, StringComparison.OrdinalIgnoreCase);
Expand Down

0 comments on commit bf5f5a4

Please sign in to comment.