Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

F# SDK

This is the README that tungsten generates for the F# target, shown for a small example API (Swagger's Petstore). Names change with your API; the structure does not.

These recorded examples retain their original generator and runtime versions. Their installation snippets name example generated packages; they are not a current registry installation recipe. See runtime distribution for the verified stable 0.1.2 package versions and matching source routes for the unreleased 0.1.3 candidate.

The F# SDK of the openapi API, generated by tungsten 0.1.3. Do not edit the generated files; put your own code in custom/.

Install

dotnet add package Openapi.Sdk --version 0.1.0

It depends on Tungsten.Runtime.FSharp, the F# layer over the .NET runtime Tungsten.Runtime (net10.0), which carries validation, auth, idempotency, confirmation, retries, pagination, streams and the error envelope.

Use

open Openapi.Sdk
open Tungsten.Runtime

let client = OpenapiClient(ClientOptions(BaseUrl = "https://api.example.com"))

Every operation is a task-based method returning F# Result<'T, Diagnostic>: Ok with the typed value, or Error with the diagnostic envelope (category, remediation, retryable). Optional members are 'T option; optional members that may also be null are Patch<'T> (Absent, Null or Value). Destructive operations need a confirmation token from their Preview...Async method, passed as CallOptions(Confirm = Confirm.Token token).

Operations

OperationMethod
openapi.listPetsPets.ListAsync
openapi.createPetsPets.CreateAsync
openapi.showPetByIdPets.GetAsync