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/
#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- 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
dotnet add package SwaggerProvider| Parameter | Default | Description |
|---|---|---|
Schema |
(required) | URL or file path to the OpenAPI/Swagger schema |
SsrfProtection |
true |
Block HTTP and private IPs to prevent SSRF attacks |
PreferNullable |
false |
Use Nullable<_> instead of Option<_> for optional fields |
PreferAsync |
false |
Generate Async<'T> instead of Task<'T> |
IgnoreControllerPrefix |
true |
Generate a single client class for all operations |
IgnoreOperationId |
false |
Generate method names from paths instead of operation IDs |
IgnoreParseErrors |
false |
Continue generation even when the parser reports schema warnings |
See the full documentation for more details and examples.
The default maintainer account for projects under "fsprojects" is @fsprojectsgit — F# Community Project Incubation Space.