SwaggerProvider

April 16, 2026 ยท View on GitHub

NuGet Version NuGet Downloads License: Unlicense

SwaggerProvider is an F# library of generative Type Providers that auto-generate strongly-typed HTTP client code from OpenAPI 3.0 and Swagger 2.0 schemas โ€” no code generation step required.

๐Ÿ“š Full documentation: https://fsprojects.github.io/SwaggerProvider/

Quick Start

#r "nuget: SwaggerProvider"
open SwaggerProvider

let [<Literal>] Schema = "https://petstore.swagger.io/v2/swagger.json"
type PetStore = OpenApiClientProvider<Schema>

let client = PetStore.Client()
client.GetInventory() |> Async.AwaitTask |> Async.RunSynchronously

Features

  • Compile-Time Types โ€” generated at compile time directly from live or local schema files, no separate codegen step needed
  • Supports OpenAPI 3.0 and Swagger 2.0 schemas in JSON and YAML formats
  • Works Everywhere โ€” F# scripts, .NET projects, and F# Interactive with full IntelliSense and type-checking
  • SSRF Protection โ€” blocks HTTP and private IP addresses by default to prevent server-side request forgery attacks
  • CancellationToken Support โ€” every generated method accepts an optional CancellationToken for cancelling long-running requests
  • Fully Customizable โ€” bring your own HttpClient, DelegatingHandler, or override JSON serialization

Installation

dotnet add package SwaggerProvider

Key Parameters

ParameterDefaultDescription
Schema(required)URL or file path to the OpenAPI/Swagger schema
SsrfProtectiontrueBlock HTTP and private IPs to prevent SSRF attacks
PreferNullablefalseUse Nullable<_> instead of Option<_> for optional fields
PreferAsyncfalseGenerate Async<'T> instead of Task<'T>
IgnoreControllerPrefixtrueGenerate a single client class for all operations
IgnoreOperationIdfalseGenerate method names from paths instead of operation IDs
IgnoreParseErrorsfalseContinue generation even when the parser reports schema warnings

See the full documentation for more details and examples.

Maintainer(s)

The default maintainer account for projects under "fsprojects" is @fsprojectsgit โ€” F# Community Project Incubation Space.