dotnet-openapi-generator 6.0.0-preview.6

This is a prerelease version of dotnet-openapi-generator.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet tool install --global dotnet-openapi-generator --version 6.0.0-preview.6
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dotnet-openapi-generator --version 6.0.0-preview.6
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-openapi-generator&version=6.0.0-preview.6&prerelease
nuke :add-package dotnet-openapi-generator --version 6.0.0-preview.6

openapi-generator for C#

Generates simple C# code based on the OpenAPI specification.

OAuth clients can be generated to easily set up calling a secured api.

Constructors will be added to initialize required or non-nullable properties defined in your schema.

If you your schema contains allOf properties and thus supports Inheritance, the classes will correctly inherit from each other and implement the base constructors. Since allOf technically is an array in the swagger document, you may get weird results in the generated code if there's more than one present, as this is not supported in the .NET framework.

Installation

Major and Minor version numbers always dictate the dotnet version being used.

dotnet 5.0 generator installation

dotnet tool install dotnet-openapi-generator -g --version 5.0.0-preview.6

dotnet 6.0 generator installation

dotnet tool install dotnet-openapi-generator -g --version 6.0.0-preview.6

dotnet 7.0 generator installation

dotnet tool install dotnet-openapi-generator -g --version 7.0.0-preview.6

Getting started

C:\Git > openapi-generator --help
openapi-generator 7.0.0-preview.6
Steven Thuriot

  -n, --namespace                 (Default: Project name) The namespace used for the generated files

  -d, --directory                 (Default: Current Directory) The directory to place the files in

  -m, --modifier                  (Default: Public) The modifier for the generated files. Can be Public or Internal

  -c, --clean-directory           (Default: false) Delete folder before generating

  -f, --filter                    (Default: No filter) Only generate Clients that match the supplied regex filter

  --client-modifier               (Default: -m) The modifier for the generated clients; Useful when generating with
                                  interfaces. Can be Public or Internal

  -s, --tree-shake                (Default: false) Skip generating unused models

  --json-constructor-attribute    (Default: System.Text.Json.Serialization.JsonConstructor) Json Constructor Attribute.
                                  Constructors are generated when the class contains required properties.

  -j, --json-source-generators    (Default: false) Include dotnet 7.0+ Json Source Generators

  --stringbuilder-pool-size       (Default: 50) StringBuilder pool size for building query params. If 0, a simple string
                                  concat is used instead.

  --oauth-type                    (Default: None) Includes an OAuth Client. Can be ClientCredentials, TokenExchange or
                                  CachedTokenExchange

  -i, --interfaces                (Default: false) Generate interfaces for the clients

  -p, --no-project                (Default: false) Do not generate project

  -o, --no-obsolete               (Default: false) Do not generate obsolete endpoints

  -a, --additional-document       Location of additional swagger document, used to merge into the main one. Can be both
                                  an http location or a local one and can be used multiple times.

  --help                          Display this help screen.

  --version                       Display version information.

  value pos. 0                    Required. Name of the project

  value pos. 1                    Required. Location of the swagger document. Can be both an http location or a local
                                  one

Registration

In your Program.cs, add the following or one of its overloads:

ApiRegistration registration = new();
builder.Services.RegisterApiClients(registration);

In case you included --oauth-type during generation, you will have to supply some token information to the ApiRegistration constructor:

TokenOptions options = new(authorityUrl, clientId, clientSecret, scopes);
ApiRegistration registration = new(options);
builder.Services.RegisterApiClients(registration);
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
8.0.0-preview.15 92 4/22/2024
8.0.0-preview.14 178 2/29/2024
7.0.0-preview.15 43 4/22/2024
7.0.0-preview.14 55 2/29/2024
7.0.0-preview.13 179 10/3/2023
7.0.0-preview.12 87 9/7/2023
7.0.0-preview.11 105 7/14/2023
7.0.0-preview.10 87 7/2/2023
7.0.0-preview.9 76 7/2/2023
7.0.0-preview.8 102 6/30/2023
7.0.0-preview.7 119 3/7/2023
7.0.0-preview.6 123 2/2/2023
7.0.0-preview.5 143 1/24/2023
7.0.0-preview.4 115 1/23/2023
6.0.0-preview.15 49 4/22/2024
6.0.0-preview.14 52 2/29/2024
6.0.0-preview.13 87 10/3/2023
6.0.0-preview.12 66 9/7/2023
6.0.0-preview.11 85 7/14/2023
6.0.0-preview.10 86 7/2/2023
6.0.0-preview.9 82 7/2/2023
6.0.0-preview.8 80 6/30/2023
6.0.0-preview.7 99 3/7/2023
6.0.0-preview.6 125 2/2/2023
6.0.0-preview.5 129 1/24/2023
6.0.0-preview.4 118 1/23/2023
5.0.0-preview.15 39 4/22/2024
5.0.0-preview.14 57 2/29/2024
5.0.0-preview.13 67 10/3/2023
5.0.0-preview.12 66 9/7/2023
5.0.0-preview.11 79 7/14/2023
5.0.0-preview.10 77 7/2/2023
5.0.0-preview.9 72 7/2/2023
5.0.0-preview.8 72 6/30/2023
5.0.0-preview.7 99 3/7/2023
5.0.0-preview.6 118 2/2/2023
5.0.0-preview.5 134 1/24/2023
5.0.0-preview.4 122 1/23/2023
2.1.0-preview.15 47 4/22/2024
2.1.0-preview.14 42 2/29/2024
2.1.0-preview.13 69 10/3/2023
2.1.0-preview.12 62 9/7/2023
2.1.0-preview.11 81 7/14/2023
2.0.0-preview.15 50 4/22/2024
2.0.0-preview.14 47 2/29/2024
2.0.0-preview.13 69 10/3/2023
2.0.0-preview.12 62 9/7/2023
2.0.0-preview.11 83 7/14/2023