Skip to content

Command-line tool

The typedrest-codegen tool writes the generated client to disk as .cs files.

Installation

Make sure you have the .NET SDK installed and run:

dotnet tool install -g typedrest-codegen

Generating a client

typedrest-codegen generate -f myapi.yml -o myclient/ -s MyService --generate-interfaces --generate-dtos

--file, --output and --service-name are required; the namespaces, interfaces, DTOs and C# language version are optional. See the full reference below.

Unlike the source generator, interfaces and DTOs are opt-in here. Generated endpoints reference the DTO types by name, so without --generate-dtos you have to provide those types yourself.

Inspecting the inferred structure

The pattern command runs only the inference step and writes the result back into the document as an x-typedrest extension:

typedrest-codegen pattern -f myapi.yml -o myapi-annotated.yml

Without --output it overwrites the input file. The spec version and format of the output default to those of the input.

This is useful for two things: seeing what the tool inferred before generating any code, and hand-editing the result. When a document already contains an x-typedrest extension, generate uses it as-is instead of re-running the inference — see Custom code.

Option reference

Command-line option reference

You can also run typedrest-codegen help generate or typedrest-codegen help pattern.

See also