Skip to content

Commit

Permalink
- cleans up leave open workaround
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Mar 6, 2024
1 parent 7c97dc9 commit 4c69e6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Kiota.Builder/Kiota.Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.1.8" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.1.4" />
<PackageReference Include="Microsoft.kiota.Serialization.Multipart" Version="1.1.3" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.13" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.14" />
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="0.5.4-preview" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.13" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.14" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="YamlDotNet" Version="15.1.2" />
<ProjectReference Include="..\Kiota.Generated\KiotaGenerated.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,22 +226,19 @@ public async Task<IEnumerable<string>> MigrateFromLockFileAsync(string clientNam
}
var (stream, _) = await openApiDocumentDownloadService.LoadStreamAsync(generationConfiguration.OpenAPIFilePath, generationConfiguration, null, false, cancellationToken).ConfigureAwait(false);
#pragma warning disable CA2007 // Consider calling ConfigureAwait on the awaited task
await using var msForOpenAPIDocument = new MemoryStream(); // openapi.net doesn't honour leave open
await using var ms = new MemoryStream();
#pragma warning restore CA2007 // Consider calling ConfigureAwait on the awaited task
await stream.CopyToAsync(msForOpenAPIDocument, cancellationToken).ConfigureAwait(false);
msForOpenAPIDocument.Seek(0, SeekOrigin.Begin);
await msForOpenAPIDocument.CopyToAsync(ms, cancellationToken).ConfigureAwait(false);
await stream.CopyToAsync(ms, cancellationToken).ConfigureAwait(false);
ms.Seek(0, SeekOrigin.Begin);
msForOpenAPIDocument.Seek(0, SeekOrigin.Begin);
var document = await openApiDocumentDownloadService.GetDocumentFromStreamAsync(msForOpenAPIDocument, generationConfiguration, false, cancellationToken).ConfigureAwait(false);
var document = await openApiDocumentDownloadService.GetDocumentFromStreamAsync(ms, generationConfiguration, false, cancellationToken).ConfigureAwait(false);
if (document is null)
{
Logger.LogError("The client {ClientName} could not be migrated because the OpenAPI document could not be loaded", generationConfiguration.ClientClassName);
clientsGenerationConfigurations.Remove(generationConfiguration);
continue;
}
generationConfiguration.ApiRootUrl = document.GetAPIRootUrl(generationConfiguration.OpenAPIFilePath);
ms.Seek(0, SeekOrigin.Begin);
await descriptionStorageService.UpdateDescriptionAsync(generationConfiguration.ClientClassName, ms, new Uri(generationConfiguration.OpenAPIFilePath).GetFileExtension(), cancellationToken).ConfigureAwait(false);

var clientConfiguration = new ApiClientConfiguration(generationConfiguration);
Expand Down

0 comments on commit 4c69e6d

Please sign in to comment.