Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/request builders as properties #2068

Merged
merged 4 commits into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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