Skip to content

Commit

Permalink
fix: do not erase the declarative copilot entries if any
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet committed Jul 4, 2024
1 parent 285db9f commit 9e9b816
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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
15 changes: 14 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,8 @@ 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; } = [];
}

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

internal class DeclarativeCopilot
{
public string? Id
{
get; set;
}
public string? File
{
get; set;
}
}
11 changes: 11 additions & 0 deletions tests/Kiota.Builder.Tests/Plugins/PluginsGenerationServiceTests.cs
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

0 comments on commit 9e9b816

Please sign in to comment.