using NSwag console to generate code from OpenAPI endpoint

 

To generate code from an Open API endpoint, you can use the nswag cli. The following are easy steps to do the code generations.

The source here is swagger.json. 

The /classname is the name of your class that will be generated and the same applies to 

/namespace and 

/output

dotnet new tool-manifest

dotnet tool install NSwag.ConsoleCore --version 13.10.9

curl -o swagger.json http://localhost:5199/swagger/v1/swagger.json

dotnet nswag swagger2csclient /input:swagger.json /classname:PartnerService
/namespace:ExternalAPI /output:PartnerService.cs


For more options, please refer to this link here

https://github.com/RicoSuter/NSwag/wiki/CommandLine/ce950c5aea7bf52a85ec6e517ad8ea96762181ed


Comments

Popular posts from this blog

gemini cli getting file not defined error

NodeJS: Error: spawn EINVAL in window for node version 20.20 and 18.20

vllm : Failed to infer device type