Skip to content

Commit

Permalink
Merge pull request #144 from microsoft/bugfix/prefixed-properties
Browse files Browse the repository at this point in the history
bugfix/prefixed properties
  • Loading branch information
baywet authored Apr 30, 2021
2 parents 1483450 + 7a0f701 commit 1c2ddde
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deterministic ordering of properties/methods/indexers/subclasses
- Deterministic import of sub path request builders
- Stopped generating phantom indexer methods for TypeScript and Java
- Fixed a bug where prefixed properties would be missing their prefix for serialization

## [0.0.3] - 2021-04-25

Expand Down
2 changes: 1 addition & 1 deletion samples
Submodule samples updated 48 files
+2 −2 msgraph-mail/dotnet/Users/InferenceClassification/Overrides/OverridesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/ChildFolders/ChildFoldersResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/MailFoldersResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/MessageRules/MessageRulesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/Messages/Attachments/AttachmentsResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/Messages/Extensions/ExtensionsResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/Messages/MessagesResponse.cs
+2 −2 ...mail/dotnet/Users/MailFolders/Messages/MultiValueExtendedProperties/MultiValueExtendedPropertiesResponse.cs
+2 −2 ...il/dotnet/Users/MailFolders/Messages/SingleValueExtendedProperties/SingleValueExtendedPropertiesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/MultiValueExtendedProperties/MultiValueExtendedPropertiesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/MailFolders/SingleValueExtendedProperties/SingleValueExtendedPropertiesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/Messages/Attachments/AttachmentsResponse.cs
+2 −2 msgraph-mail/dotnet/Users/Messages/Extensions/ExtensionsResponse.cs
+2 −2 msgraph-mail/dotnet/Users/Messages/MessagesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/Messages/MultiValueExtendedProperties/MultiValueExtendedPropertiesResponse.cs
+2 −2 msgraph-mail/dotnet/Users/Messages/SingleValueExtendedProperties/SingleValueExtendedPropertiesResponse.cs
+2 −2 ...tilities/src/main/java/graphjavav4/utilities/users/inferenceClassification/overrides/OverridesResponse.java
+2 −2 msgraph-mail/java/utilities/src/main/java/graphjavav4/utilities/users/mailFolders/MailFoldersResponse.java
+2 −2 ...java/utilities/src/main/java/graphjavav4/utilities/users/mailFolders/childFolders/ChildFoldersResponse.java
+2 −2 ...java/utilities/src/main/java/graphjavav4/utilities/users/mailFolders/messageRules/MessageRulesResponse.java
+2 −2 ...ph-mail/java/utilities/src/main/java/graphjavav4/utilities/users/mailFolders/messages/MessagesResponse.java
+2 −2 ...ilities/src/main/java/graphjavav4/utilities/users/mailFolders/messages/attachments/AttachmentsResponse.java
+2 −2 ...utilities/src/main/java/graphjavav4/utilities/users/mailFolders/messages/extensions/ExtensionsResponse.java
+2 −2 ...utilities/users/mailFolders/messages/multiValueExtendedProperties/MultiValueExtendedPropertiesResponse.java
+2 −2 ...ilities/users/mailFolders/messages/singleValueExtendedProperties/SingleValueExtendedPropertiesResponse.java
+2 −2 ...phjavav4/utilities/users/mailFolders/multiValueExtendedProperties/MultiValueExtendedPropertiesResponse.java
+2 −2 ...javav4/utilities/users/mailFolders/singleValueExtendedProperties/SingleValueExtendedPropertiesResponse.java
+2 −2 msgraph-mail/java/utilities/src/main/java/graphjavav4/utilities/users/messages/MessagesResponse.java
+2 −2 ...mail/java/utilities/src/main/java/graphjavav4/utilities/users/messages/attachments/AttachmentsResponse.java
+2 −2 ...h-mail/java/utilities/src/main/java/graphjavav4/utilities/users/messages/extensions/ExtensionsResponse.java
+2 −2 ...graphjavav4/utilities/users/messages/multiValueExtendedProperties/MultiValueExtendedPropertiesResponse.java
+2 −2 ...aphjavav4/utilities/users/messages/singleValueExtendedProperties/SingleValueExtendedPropertiesResponse.java
+2 −2 msgraph-mail/typescript/src/users/inferenceClassification/overrides/overridesResponse.ts
+2 −2 msgraph-mail/typescript/src/users/mailFolders/childFolders/childFoldersResponse.ts
+2 −2 msgraph-mail/typescript/src/users/mailFolders/mailFoldersResponse.ts
+2 −2 msgraph-mail/typescript/src/users/mailFolders/messageRules/messageRulesResponse.ts
+2 −2 msgraph-mail/typescript/src/users/mailFolders/messages/attachments/attachmentsResponse.ts
+2 −2 msgraph-mail/typescript/src/users/mailFolders/messages/extensions/extensionsResponse.ts
+2 −2 msgraph-mail/typescript/src/users/mailFolders/messages/messagesResponse.ts
+2 −2 ...escript/src/users/mailFolders/messages/multiValueExtendedProperties/multiValueExtendedPropertiesResponse.ts
+2 −2 ...cript/src/users/mailFolders/messages/singleValueExtendedProperties/singleValueExtendedPropertiesResponse.ts
+2 −2 ...-mail/typescript/src/users/mailFolders/multiValueExtendedProperties/multiValueExtendedPropertiesResponse.ts
+2 −2 ...ail/typescript/src/users/mailFolders/singleValueExtendedProperties/singleValueExtendedPropertiesResponse.ts
+2 −2 msgraph-mail/typescript/src/users/messages/attachments/attachmentsResponse.ts
+2 −2 msgraph-mail/typescript/src/users/messages/extensions/extensionsResponse.ts
+2 −2 msgraph-mail/typescript/src/users/messages/messagesResponse.ts
+2 −2 ...aph-mail/typescript/src/users/messages/multiValueExtendedProperties/multiValueExtendedPropertiesResponse.ts
+2 −2 ...h-mail/typescript/src/users/messages/singleValueExtendedProperties/singleValueExtendedPropertiesResponse.ts
1 change: 1 addition & 0 deletions src/Kiota.Builder/CodeDOM/CodeProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public CodeProperty(CodeElement parent): base(parent)
public CodeTypeBase Type {get;set;}
public string DefaultValue {get;set;}
public string Description {get; set;}
public string SerializationName { get; set; }
}
}
2 changes: 2 additions & 0 deletions src/Kiota.Builder/KiotaBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ private CodeProperty CreateProperty(string childIdentifier, string childType, Co
PropertyKind = kind,
Description = typeSchema?.Description,
};
if(propertyName != childIdentifier)
prop.SerializationName = childIdentifier;
var typeName = childType;
var isExternal = false;
if("string".Equals(typeName, StringComparison.OrdinalIgnoreCase) && "date-time".Equals(typeSchema?.Format, StringComparison.OrdinalIgnoreCase)) {
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Writers/CSharpWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override void WriteProperty(CodeProperty code)
.OrderBy(x => x.Name)) {
WriteLine("{");
IncreaseIndent();
WriteLine($"\"{otherProp.Name.ToFirstCharacterLowerCase()}\", (o,n) => {{ o.{otherProp.Name.ToFirstCharacterUpperCase()} = n.{GetDeserializationMethodName(otherProp.Type)}(); }}");
WriteLine($"\"{otherProp.SerializationName ?? otherProp.Name.ToFirstCharacterLowerCase()}\", (o,n) => {{ o.{otherProp.Name.ToFirstCharacterUpperCase()} = n.{GetDeserializationMethodName(otherProp.Type)}(); }}");
DecreaseIndent();
WriteLine("},");
}
Expand Down Expand Up @@ -216,7 +216,7 @@ public override void WriteMethod(CodeMethod code)
.OfType<CodeProperty>()
.Where(x => x.PropertyKind == CodePropertyKind.Custom)
.OrderBy(x => x.Name)) {
WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(\"{otherProp.Name.ToFirstCharacterLowerCase()}\", {otherProp.Name.ToFirstCharacterUpperCase()});");
WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(\"{otherProp.SerializationName ?? otherProp.Name.ToFirstCharacterLowerCase()}\", {otherProp.Name.ToFirstCharacterUpperCase()});");
}
if(additionalDataProperty != null)
WriteLine($"writer.WriteAdditionalData({additionalDataProperty.Name});");
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Writers/JavaWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public override void WriteMethod(CodeMethod code)
.OfType<CodeProperty>()
.Where(x => x.PropertyKind == CodePropertyKind.Custom)
.OrderBy(x => x.Name)) {
WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(\"{otherProp.Name.ToFirstCharacterLowerCase()}\", {otherProp.Name.ToFirstCharacterLowerCase()});");
WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(\"{otherProp.SerializationName ?? otherProp.Name.ToFirstCharacterLowerCase()}\", {otherProp.Name.ToFirstCharacterLowerCase()});");
}
if(additionalDataProperty != null)
WriteLine($"writer.writeAdditionalData(this.{additionalDataProperty.Name.ToFirstCharacterLowerCase()});");
Expand All @@ -159,7 +159,7 @@ public override void WriteMethod(CodeMethod code)
fieldToSerialize
.OrderBy(x => x.Name)
.Select(x =>
$"fields.put(\"{x.Name.ToFirstCharacterLowerCase()}\", (o, n) -> {{ (({parentClass.Name.ToFirstCharacterUpperCase()})o).{x.Name.ToFirstCharacterLowerCase()} = {GetDeserializationMethodName(x.Type)}; }});")
$"fields.put(\"{x.SerializationName ?? x.Name.ToFirstCharacterLowerCase()}\", (o, n) -> {{ (({parentClass.Name.ToFirstCharacterUpperCase()})o).{x.Name.ToFirstCharacterLowerCase()} = {GetDeserializationMethodName(x.Type)}; }});")
.ToList()
.ForEach(x => WriteLine(x));
WriteLine("return fields;");
Expand Down
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Writers/TypeScriptWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public override void WriteMethod(CodeMethod code)
.OfType<CodeProperty>()
.Where(x => x.PropertyKind == CodePropertyKind.Custom)
.OrderBy(x => x.Name)) {
WriteLine($"[\"{otherProp.Name.ToFirstCharacterLowerCase()}\", (o, n) => {{ o.{otherProp.Name.ToFirstCharacterLowerCase()} = n.{GetDeserializationMethodName(otherProp.Type)}; }}],");
WriteLine($"[\"{otherProp.SerializationName ?? otherProp.Name.ToFirstCharacterLowerCase()}\", (o, n) => {{ o.{otherProp.Name.ToFirstCharacterLowerCase()} = n.{GetDeserializationMethodName(otherProp.Type)}; }}],");
}
DecreaseIndent();
WriteLine("]);");
Expand All @@ -297,7 +297,7 @@ public override void WriteMethod(CodeMethod code)
.OfType<CodeProperty>()
.Where(x => x.PropertyKind == CodePropertyKind.Custom)
.OrderBy(x => x.Name)) {
WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(\"{otherProp.Name.ToFirstCharacterLowerCase()}\", this.{otherProp.Name.ToFirstCharacterLowerCase()});");
WriteLine($"writer.{GetSerializationMethodName(otherProp.Type)}(\"{otherProp.SerializationName ?? otherProp.Name.ToFirstCharacterLowerCase()}\", this.{otherProp.Name.ToFirstCharacterLowerCase()});");
}
if(additionalDataProperty != null)
WriteLine($"writer.writeAdditionalData(this.{additionalDataProperty.Name.ToFirstCharacterLowerCase()});");
Expand Down

0 comments on commit 1c2ddde

Please sign in to comment.