Skip to content

Commit

Permalink
docs: Updated README.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 10, 2024
1 parent 71c6999 commit fd3e9e0
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,22 @@ Inspired by [NSwag](https://github.com/RicoSuter/NSwag) ❤️.
- Supports OneOf/AnyOf/AllOf/Not schemas
- Supports Enums for System.Text.Json

## 🚀Quick start🚀
# 🚀Quick start🚀
## CLI(Recommended)
You can use the CLI to generate the code.
```bash
dotnet tool install --global openapigenerator.cli --prerelease
rm -rf Generated
oag generate openapi.yaml \
--namespace Namespace \
--clientClassName YourApi \
--targetFramework net8.0 \
--output Generated
```
It will generate the code in the "Generated" subdirectory.
It also will include polyfills for .Net Framework/.Net Standard TargetFrameworks.

## Source generator
- Install the package
```bash
dotnet add package OpenApiGenerator
Expand Down Expand Up @@ -49,16 +64,8 @@ dotnet add package OpenApiGenerator
- It's all! Now you can build your project and use the generated code. You also can use IDE to see the generated code in any moment, this is a example for Rider:
![rider_show_generated_code.png](assets/rider_show_generated_code.png)

## CLI
You can use the CLI to generate the code.
```bash
dotnet tool install --global openapigenerator.cli --prerelease
oag --help
oag generate openapi.yaml
```
It will generate the code in the "openapi" subdirectory.

## Trimming support
# Trimming support
## Source generator
Since there are two source generators involved, we will have to create a second project so that the generator for the JsonSerializerContext will “see” our models
- Create new project for your models. And disable methods/constructors generation:
```xml
Expand Down Expand Up @@ -101,4 +108,5 @@ internal sealed partial class SourceGenerationContext : JsonSerializerContext;
- It's all! Now you can build your project and use the generated code with full trimming/nativeAOT support.

## 📚Examples of use in real SDKs📚
- https://github.com/tryAGI/OpenAI
- https://github.com/tryAGI/Ollama

0 comments on commit fd3e9e0

Please sign in to comment.