-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Milestone
Description
Hello
I just had my first experience with the SwashBuckle CLI tool and ran into an issue.
I copied the basic example for generating a swagger.json at build time.
<Target Name="SwaggerToFile" AfterTargets="AfterBuild">
<Exec Command="swagger tofile --host http://example.com --output wwwroot/api-docs/v1/swagger.json "$(TargetPath)" v1" EnvironmentVariables="ASPNETCORE_ENVIRONMENT=Development" />
</Target>
It appears the --output
argument directory we can specify has to already exist. This is very counter intuative for an optional argument of a cli tool that generates new content.
Error:
SwasbuckleCliRepro -> D:\repos\SwasbuckleCliRepro\bin\Debug\net6.0\SwasbuckleCliRepro.dll
Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\repos\SwasbuckleCliRepro\wwwroot\api-docs\v1\swagger.json'.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.File.CreateText(String path)
at Swashbuckle.AspNetCore.Cli.Program.<>c.<Main>b__0_4(IDictionary`2 namedArgs) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\Program.cs:line 100
at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:\projects\ahoy\src\Swashbuckle.AspNetCore.Cli\CommandRunner.cs:line 68
D:\repos\SwasbuckleCliRepro\SwasbuckleCliRepro.csproj(14,5): error MSB3073: The command "swagger tofile --host http://example.com --output wwwroot/api-docs/v1/swagger.json "D:\repos\SwasbuckleCliRepro\bin\Debug\net6.0\SwasbuckleCliRepro.dll" v1" exited with code -532462766.
D:\repos\SwasbuckleCliRepro\SwasbuckleCliRepro.csproj(14,5): error MSB3073: The command "swagger tofile --host http://example.com --output wwwroot/api-docs/v1/swagger.json "D:\repos\SwasbuckleCliRepro\bin\Debug\net6.0\SwasbuckleCliRepro.dll" v1" exiBuild FAILED.
Request: Add a "Create directory if it does not exist" step to make cli tool more intuative and add ability to insert variables into output path, like the current ci environment, or the api version.
Would you accept a PR for this?
teauxfu, MathiasReichardt and mosoti02
Metadata
Metadata
Assignees
Labels
No labels