Apollo3zehn.OpenApiClientGenerator 1.0.0-beta.10

This is a prerelease version of Apollo3zehn.OpenApiClientGenerator.
dotnet add package Apollo3zehn.OpenApiClientGenerator --version 1.0.0-beta.10
NuGet\Install-Package Apollo3zehn.OpenApiClientGenerator -Version 1.0.0-beta.10
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Apollo3zehn.OpenApiClientGenerator" Version="1.0.0-beta.10" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Apollo3zehn.OpenApiClientGenerator --version 1.0.0-beta.10
#r "nuget: Apollo3zehn.OpenApiClientGenerator, 1.0.0-beta.10"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Apollo3zehn.OpenApiClientGenerator as a Cake Addin
#addin nuget:?package=Apollo3zehn.OpenApiClientGenerator&version=1.0.0-beta.10&prerelease

// Install Apollo3zehn.OpenApiClientGenerator as a Cake Tool
#tool nuget:?package=Apollo3zehn.OpenApiClientGenerator&version=1.0.0-beta.10&prerelease


GitHub Actions NuGet

  • This project provides an OpenAPI client generator, i.e. it takes an openapi.json file as input and generates the corresponding output.
  • The generator code has been tested on three different projects but is not yet fully generic, so it might not lead to perfect results in your case. Please file an issue if you run into problems.
  • The generated C# code makes heavy use of C# 10 Record types .
  • Both types of clients (C# and Python) will be generated with sync and async support.
  • All types are strongly-typed, i.e. JSON data will be serialized and deserialized as required.

Sample usage (taken from https://github.com/Apollo3zehn/hsds-api):

dotnet add package Apollo3zehn.OpenApiClientGenerator --prerelease

using Apollo3zehn.OpenApiClientGenerator;
using Microsoft.OpenApi.Readers;

namespace Hsds.ClientGenerator;

public static class Program
    public static async Task Main(string[] args)
        // read open API document
        var client = new HttpClient();
        var response = await client.GetAsync("https://raw.githubusercontent.com/HDFGroup/hdf-rest-api/master/openapi.yaml");


        var openApiJsonString = await response.Content.ReadAsStringAsync();

        // TODO: workaround (OpenAPI version 3.1.0 is not yet supported)
        openApiJsonString = openApiJsonString.Replace("3.1.0", "3.0.3");

        var document = new OpenApiStringReader()
            .Read(openApiJsonString, out var diagnostic);

        // generate clients
        var basePath = Assembly.GetExecutingAssembly().Location;

        // TODO: remove when https://github.com/HDFGroup/hdf-rest-api/issues/10 is resolved
        var pathToMethodNameMap = new Dictionary<string, string>()
            ["/"] = "Domain",
            ["Post:/groups"] = "Group",
            ["Get:/groups"] = "Groups",
            ["/groups/{id}"] = "Group",
            ["/groups/{id}/links"] = "Links",
            ["/groups/{id}/links/{linkname}"] = "Link",
            ["Post:/datasets"] = "Dataset",
            ["Get:/datasets"] = "Datasets",
            ["/datasets/{id}"] = "Dataset",
            ["/datasets/{id}/shape"] = "Shape",
            ["/datasets/{id}/type"] = "DataType",
            ["/datasets/{id}/value"] = "Values",
            ["/datatypes"] = "DataType",
            ["/datatypes/{id}"] = "Datatype",
            ["/{collection}/{obj_uuid}/attributes"] = "Attributes",
            ["/{collection}/{obj_uuid}/attributes/{attr}"] = "Attribute",
            ["/acls"] = "AccessLists",
            ["/acls/{user}"] = "UserAccess",
            ["/groups/{id}/acls"] = "GroupAccessLists",
            ["/groups/{id}/acls/{user}"] = "GroupUserAccess",
            ["/datasets/{id}/acls"] = "DatasetAccessLists",
            ["/datatypes/{id}/acls"] = "DataTypeAccessLists"

        var settings = new GeneratorSettings(
            Namespace: "Hsds.Api",
            ClientName: "Hsds",
            TokenFolderName: default!, /* Apollo3zehn-specific option */
            ConfigurationHeaderKey: default!, /* Apollo3zehn-specific option */
            ExceptionType: "HsdsException",
            ExceptionCodePrefix: "H",
            GetOperationName: (path, type, _) => {
                if (!pathToMethodNameMap.TryGetValue($"{type}:{path}", out var methodName))
                    methodName = pathToMethodNameMap[path];

                return $"{type}{methodName}";
            Special_WebAssemblySupport: false, /* Apollo3zehn-specific option */
            Special_AccessTokenSupport: false, /* Apollo3zehn-specific option */
            Special_NexusFeatures: false); /* Apollo3zehn-specific option */

        // generate C# client
        var csharpGenerator = new CSharpGenerator(settings);
        var csharpCode = csharpGenerator.Generate(document);
        File.WriteAllText("my_csharp_code.cs", csharpcode)

        // generate Python client
        var pythonGenerator = new PythonGenerator(settings);
        var pythonCode = pythonGenerator.Generate(document);
        File.WriteAllText("my_python_code.py", pythonCode)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-beta.10 144 3/5/2024
1.0.0-beta.9 47 3/5/2024
1.0.0-beta.8 76 2/28/2024
1.0.0-beta.7 42 2/28/2024
1.0.0-beta.6 172 7/13/2023
1.0.0-beta.5 264 3/15/2023
1.0.0-beta.4 77 3/15/2023
1.0.0-beta.3 73 3/15/2023
1.0.0-beta.2 74 3/15/2023
1.0.0-beta.1 124 3/14/2023