Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefh/restease-client-generator
A Visual Studio Extension to generate a RestEase compatible client based on a Swagger / OpenAPI specification files
https://github.com/stefh/restease-client-generator
Last synced: 4 months ago
JSON representation
A Visual Studio Extension to generate a RestEase compatible client based on a Swagger / OpenAPI specification files
- Host: GitHub
- URL: https://github.com/stefh/restease-client-generator
- Owner: StefH
- License: mit
- Created: 2019-12-22T08:37:20.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-25T09:49:43.000Z (about 2 years ago)
- Last Synced: 2024-04-14T05:43:43.372Z (10 months ago)
- Language: C#
- Size: 17.2 MB
- Stars: 24
- Watchers: 3
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RestEase-Client-Generator
Generate a [RestEase](https://github.com/canton7/RestEase) compatible client (Interface & Models) based on a [Swagger / OpenApi](https://swagger.io/specification/) or [RAML](https://raml.org/) specification.## :one: NuGet Package
[](https://www.nuget.org/packages/RestEaseClientGenerator)## :two: dotnet tool
[](https://www.nuget.org/packages/dotnet-resteaseclientgenerator)
#### [Installation & Usage](https://github.com/StefH/RestEase-Client-Generator/wiki/Tool)
## :three: Visual Studio Extension
[](https://marketplace.visualstudio.com/items?itemName=StefHeyenrath.RestEaseClientGenerator)
[](https://marketplace.visualstudio.com/items?itemName=StefHeyenrath.RestEaseClientGenerator)
[](https://marketplace.visualstudio.com/items?itemName=StefHeyenrath.RestEaseClientGenerator)### Features
- Supports Visual Studio 2017 and 2019
- Add New RestEase API Client to a project from an OpenAPI specification URL (e.g https://petstore.swagger.io/v2/swagger.json)
- Define custom namespace for the generated file
- Auto-updating of generated code file when changes are made to the specification file (.json, .yml, .yaml, .raml)
- This Visual Studio Extension will automatically add the required nuget packages that the generated code depends on.#### [Installation & Usage](https://github.com/StefH/RestEase-Client-Generator/wiki/NuGet)
## Options
See https://github.com/StefH/RestEase-Client-Generator/wiki/Options
---
# Demo
[Blazor WebAssembly Demo](https://stefh.github.io/RestEase-Client-Generator/)# Example
### Input Yaml file 'PetStore.yaml'
Excerpt...
``` yml
paths:
/pet:
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: addPet
consumes:
- application/json
- application/xml
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: Pet object that needs to be added to the store
required: true
schema:
$ref: '#/definitions/Pet'
```
([Full example](https://github.com/StefH/RestEase-Client-Generator/blob/master/examples/RestEaseClientGeneratorConsoleApp/petstore.yaml)).### Generate file 'PetStore.cs'
Excerpt...
``` c#
namespace RestEaseClientGeneratorConsoleApp.PetStoreJson.Api
{
public interface IPetStoreApi
{
///
/// Add a new pet to the store
///
/// A pet for sale in the pet store
[Post("/pet")]
Task AddPetAsync([Body] Pet pet);// More methods ...
}
}namespace RestEaseClientGeneratorConsoleApp.PetStoreJson.Models
{
public class Pet
{
public long Id { get; set; }// More properties ...
}
}
```
([Full example](https://github.com/StefH/RestEase-Client-Generator/blob/master/examples/RestEaseClientGeneratorConsoleApp/PetStoreJson/PetStoreJson.cs)).### Create a Client and call methods
``` c#
var petStoreApi = RestClient.For("https://petstore.swagger.io/v2");var findPetsByTags = await petStoreApi.FindPetsByTagsAsync(new[] { "cat" });
```## Screenshots
### Add new specification and generate client code

### Generate client code for existing .json, .yml or .yaml file
## Credits
- Project source code is based on [REST API Client Code Generator](https://github.com/christianhelle/apiclientcodegen)
- Code used from https://raw.githubusercontent.com/andeart/CaseConversions/master/CaseConversions/CaseConversion.cs
- Code used from https://www.codeproject.com/articles/6294/description-enum-typeconverter