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

fix: do not erase the declarative copilot entries if any #4937

Merged
merged 2 commits into from
Jul 5, 2024
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 @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Implemented partial class model declarations. [4894](https://github.com/microsoft/kiota/issues/4894)
- Fixed a bug where the Go file names were too long
- Fixed a bug where the declarative copilot information would be erased if any. [#4935](https://github.com/microsoft/kiota/issues/4935)
- Fixes bug with model names in Go generated from camel case namespace. [https://github.com/microsoftgraph/msgraph-sdk-go/issues/721]
- Plugins OpenAPI extensions are only added when generating plugins to reduce the risk of parsing errors. [#4834](https://github.com/microsoft/kiota/issues/4834)
- TypeScript imports are now using ES6 imports with the .js extension.
Expand Down
17 changes: 16 additions & 1 deletion src/Kiota.Builder/Plugins/Models/AppManifestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ public string? Outline

internal class CopilotExtensions
{
public IList<Plugin> Plugins { get; set; } = new List<Plugin>();
public IList<Plugin> Plugins { get; set; } = [];
public IList<DeclarativeCopilot> DeclarativeCopilots { get; set; } = [];
baywet marked this conversation as resolved.
Show resolved Hide resolved
[JsonExtensionData]
public Dictionary<string, Object> AdditionalData { get; set; } = new();
}

internal class Plugin
Expand All @@ -158,3 +161,15 @@ public string? File
get; set;
}
}

internal class DeclarativeCopilot
{
public string? Id
{
get; set;
}
public string? File
{
get; set;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ public async Task GeneratesManifestAndUpdatesExistingAppManifestWithExistingPlug
""id"": ""client"",
""file"": ""dummyFile.json""
}
],
""declarativeCopilots"": [
{
""id"": ""client"",
""file"": ""dummyFile.json""
}
]
}
}";
Expand All @@ -612,6 +618,9 @@ public async Task GeneratesManifestAndUpdatesExistingAppManifestWithExistingPlug
Assert.NotNull(originalAppManifestModelObject.CopilotExtensions);
Assert.Single(originalAppManifestModelObject.CopilotExtensions.Plugins);//one plugin present
Assert.Equal("dummyFile.json", originalAppManifestModelObject.CopilotExtensions.Plugins[0].File); // no plugins present
Assert.Single(originalAppManifestModelObject.CopilotExtensions.DeclarativeCopilots);// one declarative copilot present
Assert.Equal("dummyFile.json", originalAppManifestModelObject.CopilotExtensions.DeclarativeCopilots[0].File); // no plugins present


// Run the plugin generation
var pluginsGenerationService = new PluginsGenerationService(openApiDocument, urlTreeNode, generationConfiguration, workingDirectory);
Expand All @@ -629,6 +638,8 @@ public async Task GeneratesManifestAndUpdatesExistingAppManifestWithExistingPlug
Assert.Equal("Test Name", originalAppManifestModelObject.Developer.Name); // developer name is same
Assert.Equal("client", appManifestModelObject.CopilotExtensions.Plugins[0].Id);
Assert.Equal(ManifestFileName, appManifestModelObject.CopilotExtensions.Plugins[0].File);// file name is updated
Assert.Single(appManifestModelObject.CopilotExtensions.DeclarativeCopilots);// we didn't erase the existing declarative copilots
Assert.Equal("dummyFile.json", appManifestModelObject.CopilotExtensions.DeclarativeCopilots[0].File); // no plugins present
}
[Fact]
public async Task GeneratesManifestAndCleansUpInputDescription()
Expand Down
Loading