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

Aligns naming of sliced OpenAPI description generated by plugin add #4598

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Aligns naming of sliced OpenAPI description generated by `plugin add` should be named `<plugin-name>-openapi.json|yml`

## [1.14.0] - 2024-05-02

### Added
Expand Down
7 changes: 4 additions & 3 deletions src/Kiota.Builder/Plugins/PluginsGenerationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@
}
private static readonly OpenAPIRuntimeComparer _openAPIRuntimeComparer = new();
private const string ManifestFileNameSuffix = ".json";
private const string DescriptionRelativePath = "openapi.yml";
private const string DescriptionPathSuffix = "openapi.yml";
public async Task GenerateManifestAsync(CancellationToken cancellationToken = default)
{
// write the description
var descriptionFullPath = Path.Combine(Configuration.OutputPath, DescriptionRelativePath);
var descriptionRelativePath = $"{Configuration.ClientClassName.ToLowerInvariant()}-{DescriptionPathSuffix}";
var descriptionFullPath = Path.Combine(Configuration.OutputPath, descriptionRelativePath);
var directory = Path.GetDirectoryName(descriptionFullPath);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
Directory.CreateDirectory(directory);
Expand All @@ -64,16 +65,16 @@
switch (pluginType)
{
case PluginType.Microsoft:
var pluginDocument = GetManifestDocument(DescriptionRelativePath);
var pluginDocument = GetManifestDocument(descriptionRelativePath);
pluginDocument.Write(writer);
break;
case PluginType.APIManifest:
var apiManifest = new ApiManifestDocument("application"); //TODO add application name

Check warning on line 72 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
// pass empty cong hash so that its not included in this manifest.
apiManifest.ApiDependencies.AddOrReplace(Configuration.ClientClassName, Configuration.ToApiDependency(string.Empty, TreeNode?.GetRequestInfo().ToDictionary(static x => x.Key, static x => x.Value) ?? [], WorkingDirectory));
apiManifest.Write(writer);
break;
case PluginType.OpenAI://TODO add support for OpenAI plugin type generation

Check warning on line 77 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
// intentional drop to the default case
default:
throw new NotImplementedException($"The {pluginType} plugin is not implemented.");
Expand Down Expand Up @@ -106,7 +107,7 @@
{
SchemaVersion = "v2",
NameForHuman = OAIDocument.Info?.Title.CleanupXMLString(),
// TODO name for model ???

Check warning on line 110 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
DescriptionForHuman = descriptionForHuman,
DescriptionForModel = descriptionForModel,
ContactEmail = OAIDocument.Info?.Contact?.Email,
Expand Down Expand Up @@ -147,7 +148,7 @@
.Union(pathItem.Parameters.Where(static x => x.In is ParameterLocation.Path))
.Where(static x => x.Schema?.Type is not null && scalarTypes.Contains(x.Schema.Type))
.ToArray();
//TODO add request body

Check warning on line 151 in src/Kiota.Builder/Plugins/PluginsGenerationService.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

functions.Add(new Function
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ public async Task GeneratesManifest()
Assert.Equal(OpenApiFileName, resultingManifest.Document.Runtimes.OfType<OpenApiRuntime>().First().Spec.Url);
}
private const string ManifestFileName = "client-microsoft.json";
private const string OpenApiFileName = "openapi.yml";
private const string OpenApiFileName = "client-openapi.yml";
}
Loading