swaggger_csharp_refit# Swagger Codegen for the CSharpRefitCodegen library
This is a generator for building C# Refit based REST API clinet libraries from swagger.json files.
The existing Swagger code generators use RestSharp which is great, but I personally find bloated. I prefer the lightweight Refit approach. The existing Swagger code generators for C# do not handle snake_case object names used by non-C# languages in their swagger.json.
The goal of Swagger� is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
Check out OpenAPI-Spec for additional information about the Swagger project, including additional libraries with support for other languages and more.
Clone this repository.
Once inside the repository folder clone the submodule:
git submodule init
git submodule update
and then in the swagger-csharp-refit folder run (you will need Java + Maven installed):
build.cmd
or
mvn clean package
This will generate the codge generator
target/CSharpRefitCodegen-swagger-codegen-1.0.0.jar
First build the generator, see above. Then download the Swagger Codegen Cli into the.\tools folder. Then run:
gen_client.cmd -i {url_or_path_to_swagger_json} -o clients/{client_name}
or
java -cp target/CSharpRefitCodegen-swagger-codegen-1.0.0.jar;tools/swagger-codegen-cli-2.2.3.jar io.swagger.codegen.SwaggerCodegen generate -l csharprefit -i {url_or_path_to_swagger_json} -o clients/{client_name}
Download the latest jar
.\gen_client_bitbucket20.cmd gives an example of a more feature rich call.
The starting point was the existing CSharp generator code in swagger, this was extracted and applied over the top of a custom generator started using the Making your own codegen modules process.
It was tested against the Bitbucket swagger.json