RESTCLIENT.NET
Menu
EN
↗ GitHub

RESTCLIENT.NET / API REFERENCE

RestClient.Net.OpenApiGenerator.OpenApiCodeGenerator

All API types · RestClient.Net.OpenApiGenerator · View source

public static class OpenApiCodeGenerator

Generates C# extension methods from OpenAPI specifications. This uses the Microsoft.OpenApi library to parse OpenAPI documents and generate code https://github.com/microsoft/OpenAPI.NET. See the tests here https://github.com/microsoft/OpenAPI.NET/tree/main/test/Microsoft.OpenApi.Tests to see how the API works.

Members

Generate

public static Outcome.Result<GeneratorResult, string> Generate(string openApiContent, string @namespace, string className, string outputPath, string? baseUrlOverride = null, string jsonNamingPolicy = "camelCase", bool caseInsensitive = true);

Generates code from an OpenAPI document.

Parameter Type Default Description
openApiContent string Required The OpenAPI document content (JSON or YAML).
namespace string Required The namespace for generated code.
className string Required The class name for extension methods.
outputPath string Required The directory path where generated files will be saved.
baseUrlOverride string? null Optional base URL override. Use this when the OpenAPI spec has a relative server URL.
jsonNamingPolicy string "camelCase" JSON naming policy (camelCase, PascalCase, snake_case).
caseInsensitive bool true Enable case-insensitive JSON deserialization.

Returns: A Result containing either the generated code or an error message with exception details.

View source: RestClient.Net.OpenApiGenerator/OpenApiCodeGenerator.cs:21