Skip to content

Commit

Permalink
Adds support for manifest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Omondi committed Apr 18, 2024
1 parent 691a588 commit a065bde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Kiota.Builder/Plugins/PluginsGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public async Task GenerateManifestAsync(CancellationToken cancellationToken = de
{
// write the decription
var descriptionFullPath = Path.Combine(Configuration.OutputPath, DescriptionRelativePath);
var directory = Path.GetDirectoryName(descriptionFullPath);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
Directory.CreateDirectory(directory);
#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var descriptionStream = File.Create(descriptionFullPath, 4096);
await using var fileWriter = new StreamWriter(descriptionStream);
Expand All @@ -50,9 +53,6 @@ public async Task GenerateManifestAsync(CancellationToken cancellationToken = de
foreach (var pluginType in Configuration.PluginTypes)
{
var manifestOutputPath = Path.Combine(Configuration.OutputPath, $"{Configuration.ClientClassName.ToLowerInvariant()}-{pluginType.ToString().ToLowerInvariant()}{ManifestFileNameSuffix}");
var directory = Path.GetDirectoryName(manifestOutputPath);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
Directory.CreateDirectory(directory);
#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var fileStream = File.Create(manifestOutputPath, 4096);
await using var writer = new Utf8JsonWriter(fileStream, new JsonWriterOptions { Indented = true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public async Task GeneratesManifest()
info:
title: test
version: 1.0
servers:
- url: http://localhost/
description: There's no place like home
paths:
/test:
get:
Expand All @@ -49,8 +52,9 @@ public async Task GeneratesManifest()
{
OutputPath = outputDirectory,
OpenAPIFilePath = "openapiPath",
PluginTypes = [PluginType.Microsoft],
PluginTypes = [PluginType.Microsoft, PluginType.APIManifest],
ClientClassName = "client",
ApiRootUrl = "http://localhost/", //Kiota builder would set this for us
};
var (openAPIDocumentStream, _) = await openAPIDocumentDS.LoadStreamAsync(simpleDescriptionPath, generationConfiguration, null, false);
var openApiDocument = await openAPIDocumentDS.GetDocumentFromStreamAsync(openAPIDocumentStream, generationConfiguration);
Expand All @@ -60,6 +64,7 @@ public async Task GeneratesManifest()
await pluginsGenerationService.GenerateManifestAsync();

Assert.True(File.Exists(Path.Combine(outputDirectory, "client-microsoft.json")));
Assert.True(File.Exists(Path.Combine(outputDirectory, "client-apimanifest.json")));
Assert.True(File.Exists(Path.Combine(outputDirectory, "openapi.yml")));
}
}

0 comments on commit a065bde

Please sign in to comment.