-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work]
If you attempt to generate an OpenAPI Service Reference when the path to the swagger.json has spaces in it, it will fail to generate the C# code. This is because the path to the swagger.json file is not escaped, so if you have a swagger.json file at "C:\path with spaces\swagger.json", this will run the command "path\to\nswag.exe" /input:C:\path with spaces\swagger.json /output:obj/swagger.cs, which will be interpreted by NSwag as /input:C:\path. Manually copying the command and running it with quotation marks around the input command allows the build to succeed.
Original Comments
Feedback Bot on 1/4/2023, 07:54 PM:
(private comment, text removed)
Original Solutions
Levi Willrich solved on 1/4/2023, 09:27 AM, 0 votes:
It is possible to manually generate the code file by copying the command from the error list into a text editor, which gives you something like this
Severity Code Description Project File Line Suppression State Error MSB3073 The command ""C:\Users\lwillrich\.nuget\packages\nswag.msbuild\13.0.5\build\../tools/Win/NSwag.exe" openapi2csclient /className:WebApi /namespace:<Namespace> /input:E:\Repos\Windows Applications\<solution>\<project>\OpenAPIs\swagger.json /output:obj\swaggerClient.cs " exited with code -1. <Solution> C:\Users\lwillrich\.nuget\packages\nswag.apidescription.client\13.0.5\build\NSwag.ApiDescription.Client.targets 28
From there you can add quotes around the path after /input, copy out the actual command into the command line, and run it.