Reputation: 43
I have a REST API which generates a swagger through /swagger endpoint. I need to generate a .net core client SDK for consumers so they can easily use it to connect to the service from .net core code. The REST service itself is not developed in .net core, but in Node.js.
Is there a tool that will read the swagger definitions and generate a .net core sdk bindings ?
Options already evaluated(with no success): a. openapi-generator (only generates .Net Framework code, not compatible with .net core) b. NSwag (could not generate any useful code out of it)
Use any standard swagger and try to generate sdk for .net core. e.g. https://petstore.swagger.io/v2/swagger.json
I am expecting a client side sdk project that will build on .net core.
Upvotes: 2
Views: 2507
Reputation: 10817
Please try OpenAPI Generator (which supports both OpenAPI spec v2, v3) to generate C# .NET Core API client in 3 steps:
1) Download the Java JAR (http://central.maven.org/maven2/org/openapitools/openapi-generator-cli/4.0.3/openapi-generator-cli-4.0.3.jar)
2) Rename the JAR as "openapi-generator-cli.jar"
3) Run the following command to generate a C# .NET Core API client for the Petstore API (https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml):
Mac/Linux:
Windows:
Upvotes: 3
Reputation: 840
You could use AutoRest to generate .net code client.
https://github.com/Azure/autorest
Install with npm and lauch cmd
example :
autorest --input-file=https://petstore.swagger.io/v2/ --output-folder=c:\petstore --namespace=Petstore --csharp
Upvotes: 2