Open daniol opened 3 years ago
Workaround: call rapicgen tool in pre-build event
rapicgen openapi swagger.json NameSpaceName ./MyFileName.cs
First of all, thanks for pointing this out @daniol
Another workaround I can suggest is to right click on the OpenAPI spec file in the project and "Run Custom Tool"
You can also open the OpenAPI spec file in Visual Studio and make a trivial whitespace change and press save, then undo the change again.
Anyway, I'm not sure if its possible to handle pre-build events from Visual Studio without tampering with the project file and adding pre-build events. If the Visual Studio SDK supports such or similar events then it might be possible to implement an option to always re-generate the REST API client code before build. This would work really great especially with NSwag as the code gets generated very very quickly. Unfortunately, it would really be a bad experience with AutoRest as this takes a lot of time to generate code, OpenAPI Generator is not that slow but there is a noticeable delay until the operation is completed
If I were to build such an option it would be disabled by default as it would be very opinionated of the tool to just assume that most users want this behavior.
I'll have to investigate deeper for this
Making any changes to the OpenAPI spec file (swagger.json) file with an external tool (outside Visual Studio) does not trigger the re-generation of the client code. Client code is only re-generated when the spec file is opened and modified inside Visual Studio.
Support Key:
2979cf3
To Reproduce Steps to reproduce the behavior:
Expected behavior When the project is built, the plug-in should force the client to be generated again, in order to detect changes that were made outside Visual Studio.
Visual Studio Extension: