Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
78ef3ca
fix devcontainer
firefart Apr 6, 2025
d5d2588
remove brackets on return types when there is only one
firefart Apr 6, 2025
9f610d5
replace and remove deprecated extensions
firefart Apr 6, 2025
ea19d2b
use tabs instead of spaces
firefart Apr 6, 2025
762b064
update changelog
firefart Apr 6, 2025
6f4eb4f
add recommended c# devkit extension
firefart Apr 7, 2025
b8e41c5
also add github actions extension
firefart Apr 7, 2025
9d2165d
fix more code
firefart Apr 7, 2025
2c3cba1
more work
firefart Apr 7, 2025
2f83574
fix changelog format
firefart Apr 7, 2025
d1fd88b
remove trailing spaces on comments
firefart Apr 7, 2025
98c5003
fix import ordering
firefart Apr 7, 2025
669d86e
remove dependency
firefart Apr 7, 2025
a446f6a
use a constructor
firefart Apr 7, 2025
50f05e9
add comment
firefart Apr 7, 2025
8af4703
simplify sort
firefart Apr 7, 2025
baa18a5
Merge branch 'main' into fmt
baywet Apr 7, 2025
cfad40c
use correct helper method
firefart Apr 7, 2025
1730ef3
Merge branch 'fmt' of github.com:firefart/kiota into fmt
firefart Apr 7, 2025
f5c02e6
simplify another import statement
firefart Apr 7, 2025
050a088
more import ordering fixes
firefart Apr 7, 2025
a021acd
correctly indent switch statements
firefart Apr 7, 2025
19b4464
fix switch statements
firefart Apr 7, 2025
90be6d0
more formatting tweaks
firefart Apr 7, 2025
009d952
more formatting
firefart Apr 7, 2025
710513b
newline after each func
firefart Apr 7, 2025
dc627cb
more formatting
firefart Apr 7, 2025
77a350c
remove more unneeded ;
firefart Apr 8, 2025
0abfc98
cleanup
firefart Apr 8, 2025
340d287
Merge branch 'main' into fmt
firefart Apr 9, 2025
dcca422
Merge branch 'main' into fmt
firefart Apr 9, 2025
ff5d9f5
Merge branch 'main' into fmt
firefart Apr 10, 2025
53f4507
Merge branch 'main' into fmt
firefart Apr 11, 2025
8375072
Merge branch 'main' into fmt
firefart Apr 14, 2025
8252cd9
Merge branch 'main' into fmt
firefart Apr 24, 2025
e57c890
Merge branch 'main' into fmt
firefart May 1, 2025
d5ae502
Merge branch 'microsoft:main' into fmt
firefart May 4, 2025
b95be2b
the java feature is fixed
firefart May 4, 2025
0ad2747
Merge branch 'main' into fmt
firefart May 8, 2025
f0dd33a
Merge branch 'main' into fmt
firefart May 14, 2025
bc7bc6a
Merge branch 'microsoft:main' into fmt
firefart May 16, 2025
2a20e36
remove more spaces at the end
firefart May 16, 2025
a8804af
fix changelog
firefart May 16, 2025
a4eac14
add integration test
firefart May 16, 2025
2c45bf9
simplify
firefart May 16, 2025
bcc7f64
Merge branch 'main' into fmt
firefart May 19, 2025
e91666e
Update src/Kiota.Builder/Writers/Go/CodeEnumWriter.cs
firefart May 19, 2025
91e5980
start fixing unit tests
firefart May 19, 2025
221b1e1
fix unit tests
firefart May 20, 2025
397d712
Merge branch 'main' into fmt
firefart Jun 27, 2025
5471141
Merge branch 'main' into fmt
firefart Jul 11, 2025
76b117c
Merge branch 'main' into fmt
firefart Jul 31, 2025
da9a4b5
Merge branch 'main' into fmt
firefart Oct 24, 2025
de15a35
Merge remote-tracking branch 'origin/main' into fmt
firefart Dec 1, 2025
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
14 changes: 9 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
"kosunix.guid",
"wix.vscode-import-cost",
"ms-vsliveshare.vsliveshare",
"eg2.vscode-npm-script",
"fknop.vscode-npm",
"ms-vscode.powershell",
"rebornix.ruby",
"Shopify.ruby-lsp",
"visualstudioexptteam.vscodeintellicode",
"streetsidesoftware.code-spell-checker",
"sswg.swift-lang",
"ms-dotnettools.blazorwasm-companion"
"swiftlang.swift-vscode",
"ms-dotnettools.blazorwasm-companion",
"ms-dotnettools.csdevkit",
"github.vscode-github-actions"
]
}
},
Expand All @@ -58,7 +59,10 @@
"ghcr.io/devcontainers-contrib/features/gradle-sdkman:2": {},
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/devcontainers/features/java:1": {},
"ghcr.io/devcontainers/features/java:1": {
// https://github.com/devcontainers/features/issues/1308
"version": "23"
},
"ghcr.io/devcontainers/features/rust:1": {},
// disabled swift & ruby as their are failing for now
"ghcr.io/devcontainers/features/powershell:1": {}
Expand Down
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Fixed a bug where Dart properties casing would change for serialization.
- golang: indent with tabs instead of spaces
- golang: if there is only one return argument, omit the parentheses
- golang: remove trailing spaces on comments
- golang: fix import ordering

## [1.25.1] - 2025-04-03

### Changed

- Fixed a bug with http client generation where query parameters were being processed incorrectly. [#6268](https://github.com/microsoft/kiota/issues/6268)

### Added

- Extracted and created an npm package from the VS Code - Kiota interop module. [#6172](https://github.com/microsoft/kiota/pull/6172)

- Added support for generating function capabilities in plugin manifest from x-ai-capabilities OpenApi extension. [#6369](https://github.com/microsoft/kiota/issues/6369)
- Added support for generating function capabilities in plugin manifest from x-ai-capabilities OpenApi extension. [#6369](https://github.com/microsoft/kiota/issues/6369)

- Added a comment on top of every golang file to indicate the file is machine generated so it can be excluded from various tools. [#6363](https://github.com/microsoft/kiota/issues/6363)

Expand Down Expand Up @@ -131,7 +137,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Python error when a class inherits from a base class and implements an interface. [#5637](https://github.com/microsoft/kiota/issues/5637)
- Fixed a bug where one/any schemas with single schema entries would be missing properties. [#5808](https://github.com/microsoft/kiota/issues/5808)
- Fixed anyOf/oneOf generation in TypeScript. [5353](https://github.com/microsoft/kiota/issues/5353)
- Fixed invalid code in Php caused by "*/*/" in property description. [5635](https://github.com/microsoft/kiota/issues/5635)
- Fixed invalid code in Php caused by `"*/*/"` in property description. [5635](https://github.com/microsoft/kiota/issues/5635)
- Fixed a bug where discriminator property name lookup could end up in an infinite loop. [#5771](https://github.com/microsoft/kiota/issues/5771)
- Fixed TypeScript generation error when generating usings from shaken serializers. [#5634](https://github.com/microsoft/kiota/issues/5634)
- Multiple fixed and improvements in OpenAPI description generation for plugins. [#5806](https://github.com/microsoft/kiota/issues/5806)
Expand Down Expand Up @@ -272,7 +278,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added uri-form encoded serialization for PHP. [#2074](https://github.com/microsoft/kiota/issues/2074)
- Added information message with base URL in the CLI experience. [#4635](https://github.com/microsoft/kiota/issues/4635)
- Added optional parameter --disable-ssl-validation for generate, show, and download commands. [#4176](https://github.com/microsoft/kiota/issues/4176)
- For *Debug* builds of kiota, the `--log-level` / `--ll` option is now observed if specified explicitly on the command line. It still defaults to `Debug` for *Debug* builds and `Warning` for *Release* builds. [#4739](https://github.com/microsoft/kiota/pull/4739)
- For _Debug_ builds of kiota, the `--log-level` / `--ll` option is now observed if specified explicitly on the command line. It still defaults to `Debug` for _Debug_ builds and `Warning` for _Release_ builds. [#4739](https://github.com/microsoft/kiota/pull/4739)

### Changed

Expand Down Expand Up @@ -874,7 +880,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Removed unused generated import for PHP Generation.
- Fixed a bug where long namespaces would make Ruby packaging fail.
- Fixed a bug where classes with namespace names are generated outside namespace in Python. [#2188](https://github.com/microsoft/kiota/issues/2188)
- Changed signature of escaped reserved names from {x}*escaped to {x}* in line with Python style guides.
- Changed signature of escaped reserved names from `{x}*escaped` to `{x}*` in line with Python style guides.
- Add null checks in generated Shell language code.
- Fixed a bug where Go indexers would fail to pass the index parameter.
- Fixed a bug where path segments with parameters could be missing words. [#2209](https://github.com/microsoft/kiota/issues/2209)
Expand Down Expand Up @@ -1623,5 +1629,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Initial GitHub release


8 changes: 4 additions & 4 deletions it/go/app.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package integrationtest

import (
c "integrationtest/client"
"context"
"fmt"
azidentity "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
a "github.com/microsoft/kiota-authentication-azure-go"
r "github.com/microsoft/kiota-http-go"
"fmt"
"context"
c "integrationtest/client"
)

func main() {
Expand All @@ -33,4 +33,4 @@ func main() {
}
client := c.NewApiClient(adapter)
fmt.Printf("Message: %v\n", client)
}
}
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Writers/Go/CodeFileDeclarationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public override void WriteCodeElement(CodeFileDeclaration codeElement, LanguageW
.Where(static x => x.Declaration != null && x.Declaration.IsExternal)
.Select(static x => new Tuple<string, string>(x.Name.StartsWith('*') ? x.Name[1..] : x.Declaration!.Name.GetNamespaceImportSymbol(), x.Declaration!.Name))
.Distinct())
.OrderBy(static x => x.Item2.Count(static y => y == '/'))
.ThenBy(static x => x)
.OrderBy(static x => x.Item2)
.ThenBy(static x => x.Item2.Count(static y => y == '/'))
.ToList();
if (importSegments.Count != 0)
{
Expand Down
24 changes: 16 additions & 8 deletions src/Kiota.Builder/Writers/Go/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,6 @@ private void WriteSerializerBodyForIntersectionModel(CodeClass parentClass, Lang

private void WriteMethodPrototype(CodeMethod code, CodeElement parentBlock, LanguageWriter writer, string returnType, bool writePrototypeOnly)
{
var returnTypeAsyncSuffix = code.IsAsync ? "error" : string.Empty;
if (!string.IsNullOrEmpty(returnType) && code.IsAsync)
returnTypeAsyncSuffix = $", {returnTypeAsyncSuffix}";
var isConstructor = code.IsOfKind(CodeMethodKind.Constructor, CodeMethodKind.ClientConstructor, CodeMethodKind.RawUrlConstructor);
var methodName = code.Kind switch
{
Expand All @@ -454,7 +451,7 @@ private void WriteMethodPrototype(CodeMethod code, CodeElement parentBlock, Lang
var parameters = string.Join(", ", code.Parameters.OrderBy(x => x, ParameterOrderComparer).Select(p => conventions.GetParameterSignature(p, parentBlock)).ToList());
var classType = conventions.GetTypeString(new CodeType { Name = parentBlock.Name, TypeDefinition = parentBlock }, parentBlock);
var associatedTypePrefix = isConstructor || code.IsStatic || writePrototypeOnly ? string.Empty : $"(m {classType}) ";
var finalReturnType = isConstructor ? classType : $"{returnType}{returnTypeAsyncSuffix}";
var finalReturnType = isConstructor ? classType : returnType;
var errorDeclaration = code.IsOfKind(CodeMethodKind.ClientConstructor,
CodeMethodKind.Constructor,
CodeMethodKind.Getter,
Expand All @@ -469,11 +466,22 @@ private void WriteMethodPrototype(CodeMethod code, CodeElement parentBlock, Lang
CodeMethodKind.ErrorMessageOverride) || code.IsAsync ?
string.Empty :
"error";
if (!string.IsNullOrEmpty(finalReturnType) && !string.IsNullOrEmpty(errorDeclaration))
finalReturnType += ", ";
var openingBracket = writePrototypeOnly ? string.Empty : " {";
var funcPrefix = writePrototypeOnly ? string.Empty : "func ";
writer.WriteLine($"{funcPrefix}{associatedTypePrefix}{methodName}({parameters})({finalReturnType}{errorDeclaration}){openingBracket}");
var returnTypeString = (code, finalReturnType, errorDeclaration) switch
{
_ when code.IsAsync && !string.IsNullOrEmpty(finalReturnType) => $"({finalReturnType}, error)",
_ when !string.IsNullOrEmpty(finalReturnType) && !string.IsNullOrEmpty(errorDeclaration) => $"({finalReturnType}, {errorDeclaration})",
_ when string.IsNullOrEmpty(finalReturnType) && !string.IsNullOrEmpty(errorDeclaration) => errorDeclaration,
_ when !string.IsNullOrEmpty(finalReturnType) && string.IsNullOrEmpty(errorDeclaration) => finalReturnType,
_ => string.Empty
};
var openingBracket = (writePrototypeOnly, returnTypeString) switch
{
_ when writePrototypeOnly => string.Empty,
_ when string.IsNullOrEmpty(returnTypeString) => "{", // no leading space in this case
_ => " {",
};
writer.WriteLine($"{funcPrefix}{associatedTypePrefix}{methodName}({parameters}) {returnTypeString}{openingBracket}");
}
private void WriteGetterBody(CodeMethod codeElement, LanguageWriter writer, CodeClass parentClass)
{
Expand Down
15 changes: 11 additions & 4 deletions src/Kiota.Builder/Writers/Go/GoConventionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Kiota.Builder.CodeDOM;
using Kiota.Builder.Extensions;
using Kiota.Builder.Refiners;
using Microsoft.VisualBasic;

namespace Kiota.Builder.Writers.Go;
public class GoConventionService : CommonLanguageConventionService
Expand All @@ -14,7 +15,7 @@ public class GoConventionService : CommonLanguageConventionService

public override string VoidTypeName => string.Empty;

public override string DocCommentPrefix => "// ";
public override string DocCommentPrefix => "//";
public override string ParseNodeInterfaceName => "ParseNode";
#pragma warning disable CA1822 // Method should be static
public string AbstractionsHash => "i2ae4187f7daee263371cb1c977df639813ab50ffa529013b7437480d1ec0158f";
Expand Down Expand Up @@ -186,14 +187,20 @@ public override bool WriteShortDescription(IDocumentedElement element, LanguageW
public void WriteGeneratorComment(LanguageWriter writer)
{
ArgumentNullException.ThrowIfNull(writer);
writer.WriteLine($"{DocCommentPrefix}Code generated by Microsoft Kiota - DO NOT EDIT.");
writer.WriteLine($"{DocCommentPrefix}Changes may cause incorrect behavior and will be lost if the code is regenerated.");
writer.WriteLine($"{DocCommentPrefix} Code generated by Microsoft Kiota - DO NOT EDIT.");
writer.WriteLine($"{DocCommentPrefix} Changes may cause incorrect behavior and will be lost if the code is regenerated.");
writer.WriteLine(string.Empty);
}
public void WriteDescriptionItem(string description, LanguageWriter writer)
{
ArgumentNullException.ThrowIfNull(writer);
writer.WriteLine($"{DocCommentPrefix}{description}");
// account for a trailing whitespace on comments then the description is empty
var comment = description switch
{
_ when string.IsNullOrEmpty(description) => DocCommentPrefix,
_ => $"{DocCommentPrefix} {description}",
};
writer.WriteLine(comment);
}
public void WriteLinkDescription(CodeDocumentation documentation, LanguageWriter writer)
{
Expand Down
22 changes: 21 additions & 1 deletion src/Kiota.Builder/Writers/Go/GoWriter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Kiota.Builder.PathSegmenters;
using System;
using System.Linq;
using Kiota.Builder.PathSegmenters;

namespace Kiota.Builder.Writers.Go;
public class GoWriter : LanguageWriter
Expand All @@ -16,4 +18,22 @@ public GoWriter(string rootPath, string clientNamespaceName, bool excludeBackwar
AddOrReplaceCodeElementWriter(new CodeFileBlockEndWriter());
AddOrReplaceCodeElementWriter(new CodeFileDeclarationWriter(conventionService));
}

// Override the Ident functions as golang indents with tabs instead of spaces
private int currentIndent;
private static readonly string indentString = Enumerable.Repeat("\t", 1000).Aggregate(static (x, y) => x + y);
public override void IncreaseIndent(int factor = 1)
{
currentIndent += 1;
}

public override void DecreaseIndent()
{
currentIndent -= 1;
}

public override string GetIndent()
{
return indentString[..Math.Max(0, currentIndent)];
}
}
6 changes: 3 additions & 3 deletions src/Kiota.Builder/Writers/LanguageWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public IPathSegmenter? PathSegmenter
}

private readonly Stack<int> factorStack = new();
public void IncreaseIndent(int factor = 1)
public virtual void IncreaseIndent(int factor = 1)
{
factorStack.Push(factor);
currentIndent += IndentSize * factor;
}

public void DecreaseIndent()
public virtual void DecreaseIndent()
{
var popped = factorStack.TryPop(out var factor);
currentIndent -= IndentSize * (popped ? factor : 1);
}

public string GetIndent()
public virtual string GetIndent()
{
return indentString[..Math.Max(0, currentIndent)];
}
Expand Down