Skip to content

Commit

Permalink
Merge pull request #2068 from microsoft/feature/request-builders-as-p…
Browse files Browse the repository at this point in the history
…roperties

Feature/request builders as properties
  • Loading branch information
samwelkanda authored Dec 14, 2022
2 parents 9ece566 + 92006dd commit d66bbbd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Switched to lazy loading module imports in Python. [#2007](https://github.com/microsoft/kiota/issues/2007)
- Caters for type names being used from System namespace in CSharp generation [#2021](https://github.com/microsoft/kiota/issues/2021)
- Fixed wrong send request method name for collections in Python. [#2057](https://github.com/microsoft/kiota/issues/2057)
- Implemented request builders with no parameters as properties in Python. [#2024](https://github.com/microsoft/kiota/issues/2024)

## [0.8.3] - 2022-12-01

Expand Down
1 change: 1 addition & 0 deletions src/Kiota.Builder/Writers/Python/CodePropertyWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public override void WriteCodeElement(CodeProperty codeElement, LanguageWriter w
*/
switch(codeElement.Kind) {
case CodePropertyKind.RequestBuilder:
writer.WriteLine("@property");
writer.WriteLine($"def {codeElement.Name.ToSnakeCase()}(self) -> {returnType}:");
writer.IncreaseIndent();
conventions.WriteShortDescription(codeElement.Documentation.Description, writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void WritesRequestBuilder() {
property.Documentation.Description = "This is a request builder";
writer.Write(property);
var result = tw.ToString();
Assert.Contains("@property", result);
Assert.Contains("def property_name(", result);
Assert.Contains("This is a request builder", result);
Assert.Contains($"return {TypeName.ToLower()}.{TypeName}(", result);
Expand All @@ -60,6 +61,7 @@ public void WritesQueryParameters() {
property.Kind = CodePropertyKind.QueryParameters;
writer.Write(property);
var result = tw.ToString();
Assert.DoesNotContain("@property", result);
Assert.Contains($"property_name: Optional[{TypeName.ToLower()}.{TypeName}]", result);
}
[Fact]
Expand Down

0 comments on commit d66bbbd

Please sign in to comment.