https://github.com/double-em/restluent
A Fluent client generator for Rest API's
https://github.com/double-em/restluent
fluent-api fluent-interface rest-api restful-api
Last synced: 2 months ago
JSON representation
A Fluent client generator for Rest API's
- Host: GitHub
- URL: https://github.com/double-em/restluent
- Owner: double-em
- Created: 2022-03-20T16:34:45.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-09T21:31:38.000Z (10 months ago)
- Last Synced: 2025-01-19T11:14:20.035Z (4 months ago)
- Topics: fluent-api, fluent-interface, rest-api, restful-api
- Language: C#
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Restluent (Work in progress)
Restluent is supposed to be a Fluent Api Client generator.
The only thing needed is an OpenAPI Standard Schema eg. from Swagger.## Todo (Proof of Concept):
- [x] Example API
- [x] Open API Component parsing from a Json file
- [x] SourceGenerated classes from parsed components
- [x] Fluent Api builder
- [ ] Couple the Api Client with the generated classes
- [ ] HttpClient request handling
- [ ] Unit Tests## Concept
### Schema Example
If given a schema with the following components:
```json
"components": {
"schemas": {
"WeatherForecast": {
"type": "object",
"properties": {
"date": {
"type": "string",
"format": "date-time"
},
"temperatureC": {
"type": "integer",
"format": "int32"
},
"temperatureF": {
"type": "integer",
"format": "int32",
"readOnly": true
},
"summary": {
"type": "string",
"nullable": true
}
},
"additionalProperties": false
}
}
}
```
### Generated Example
There should be generated a class as:
```csharp
// Auto-generated code
using System;namespace Restluent
{
public class WeatherForecast
{
public string date { get; set; }
public int temperatureC { get; set; }
public int temperatureF { get; set; }
public string summary { get; set; }
}
}```
### Usage Example
With a generated class like:
```csharp
public class Customer
{
public Guid Id { get; set; }public string Name { get; set; } = null!;
public bool WithCompanies { get; set; }
}
```Then the usage should be:
```csharp
var customer = RestluentApi.Customers()
.Where(c => c.Name == "tester")
.WithCompanies();var newCustomer = RestluentApi.Customers()
.Add(new CustomerVariables
{
Name = "Test"
});
```