Fable.Remoting.OpenAPI.Giraffe 0.0.3

dotnet add package Fable.Remoting.OpenAPI.Giraffe --version 0.0.3
                    
NuGet\Install-Package Fable.Remoting.OpenAPI.Giraffe -Version 0.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fable.Remoting.OpenAPI.Giraffe" Version="0.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fable.Remoting.OpenAPI.Giraffe" Version="0.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Fable.Remoting.OpenAPI.Giraffe" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fable.Remoting.OpenAPI.Giraffe --version 0.0.3
                    
#r "nuget: Fable.Remoting.OpenAPI.Giraffe, 0.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fable.Remoting.OpenAPI.Giraffe@0.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fable.Remoting.OpenAPI.Giraffe&version=0.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Fable.Remoting.OpenAPI.Giraffe&version=0.0.3
                    
Install as a Cake Tool

Fable.Remoting.OpenAPI

NuGet Downloads NuGet Downloads NuGet Downloads

OpenAPI generation for Fable.Remoting contracts.

Packages

  • Fable.Remoting.OpenAPI: Core document generation and customization APIs.
  • Fable.Remoting.OpenAPI.Giraffe: Giraffe docs handlers and remoting composition.
  • Fable.Remoting.OpenAPI.Suave: Suave docs webpart helpers and composition.

Highlights

  • OpenAPI 3.0.3 JSON and YAML generation from shared API contracts.
  • Typed endpoint metadata helpers via quotations.
  • Remoting-aware route generation (uses active route builder).
  • Defaults docs routes from route builder and API type name.
  • Deterministic output suitable for snapshot-style tests.
  • Native Fable.Remoting.Json-compatible example serialization.
  • Discriminated union schema modeling aligned with Fable.Remoting JSON wire shapes.

This project was instantiated by AI agents and was not fully reviewed by humans at the time of this commit. It was done to quickly deviler a working prototype of the intended functionality.

Core Usage

open Fable.Remoting.OpenAPI

let document =
    OpenApi.options
    |> OpenApi.withTitle "My API"
    |> OpenApi.withVersion "1.0.0"
    |> OpenApi.generate<MySharedApi>

Giraffe Integration

open Fable.Remoting.Server
open Fable.Remoting.Giraffe
open Fable.Remoting.OpenAPI

let docsOptions =
    OpenApi.options
    |> OpenApi.withTitle "My API"
    |> OpenApi.withVersion "1.0.0"

let webApp =
    Remoting.createApi ()
    |> Remoting.withRouteBuilder (fun typeName methodName -> sprintf "/api/%s/%s" typeName methodName)
    |> Remoting.fromValue apiImplementation
    |> OpenAPI.withDocs docsOptions

By default, the docs routes follow the same remoting route base:

  • /api/<TypeName>/docs
  • /api/<TypeName>/docs/openapi.json
  • /api/<TypeName>/docs/openapi.yaml

You can still override with OpenApi.withRoutes.

Suave Integration

open Fable.Remoting.OpenAPI
open Fable.Remoting.OpenAPI.Suave

let document =
    OpenApi.options
    |> OpenApi.withTitle "My API"
    |> OpenAPI.withDocs remotingOptions

let app =
    OpenApiSuave.withDocsWebPart document remotingWebPart

Type-safe Endpoint Metadata

open Fable.Remoting.OpenAPI

let docs =
    OpenApi.options
    |> OpenApi.withEndpointDocsFor<MyApi, CreateOrder -> Async<OrderId>>
        <@ fun api -> api.createOrder @>
        { OpenApiDefaults.endpointDocumentation with Summary = Some "Create order" }
    |> OpenApi.withEndpointRequestExampleFor<MyApi, CreateOrder, OrderId>
        <@ fun api -> api.createOrder @>
        { customerId = "c-1"; amount = 12.5m }
    |> OpenApi.withEndpointRequestNamedExampleFor<MyApi, CreateOrder, OrderId>
        <@ fun api -> api.createOrder @>
        {
            Name = "bulk"
            Summary = Some "Bulk order example"
            Description = Some "Example payload for batch processing"
            ExternalValue = None
        }
        { customerId = "c-2"; amount = 42m }
    |> OpenApi.withEndpointResponseNamedExampleFor<MyApi, CreateOrder -> Async<OrderId>, OrderId>
        <@ fun api -> api.createOrder @>
        {
            Name = "created"
            Summary = Some "Successful response"
            Description = Some "Order id returned when creation succeeds"
            ExternalValue = None
        }
        { value = "order-123" }

Named example helpers emit OpenAPI examples objects (multiple examples with metadata like summary and description) in request and response media types.

Endpoint Example APIs

The options pipeline exposes two styles of example helpers:

  • Single-example helpers (emit OpenAPI example when no named examples are configured)
    • OpenApi.withEndpointRequestExampleFor<'Api, 'Input, 'Output>
    • OpenApi.withEndpointResponseExampleFor<'Api, 'Endpoint, 'Output>
  • Named example helpers (emit OpenAPI examples)
    • OpenApi.withEndpointRequestNamedExampleFor<'Api, 'Input, 'Output>
    • OpenApi.withEndpointResponseNamedExampleFor<'Api, 'Endpoint, 'Output>

Response Helper Expression Type

withEndpointResponseExampleFor and withEndpointResponseNamedExampleFor accept endpoint quotations typed as Expr<'Api -> 'Endpoint>, which means they work for both:

  • unit-input endpoints, for example: unit -> Async<'Output>
  • non-unit endpoints, for example: 'Input -> Async<'Output>

For non-unit endpoints, pass the function type as 'Endpoint in the generic argument list:

|> OpenApi.withEndpointResponseNamedExampleFor<MyApi, CreateOrder -> Async<OrderId>, OrderId>
        <@ fun api -> api.createOrder @>
        {
                Name = "created"
                Summary = Some "Successful response"
                Description = Some "Order id returned when creation succeeds"
                ExternalValue = None
        }
        { value = "order-123" }

Example Metadata Shape

Named helpers use OpenApiExampleMetadata:

type OpenApiExampleMetadata = {
        Name: string
        Summary: string option
        Description: string option
        ExternalValue: string option
}

This maps to OpenAPI example object fields (summary, description, value, externalValue) as described by Swagger/OpenAPI documentation.

Rendering Behavior

  • If named examples exist for a request or response media type, output uses examples.
  • If no named examples exist, the legacy single-example value is emitted as example.
  • For Fable.Remoting request bodies, request example values are normalized to array payload shape.

This keeps existing single-example pipelines working while enabling richer multi-example docs.

Development

Solution files used by CI and local workflows:

  • Fable.Remoting.OpenApi.sln for restore/build/test.
  • Release.sln for restore/pack of publishable packages only.

Typical local commands:

dotnet restore ./Fable.Remoting.OpenApi.sln
dotnet test ./Fable.Remoting.OpenApi.sln
dotnet restore ./Release.sln
dotnet pack ./Release.sln -c Release --no-restore -o artifacts

See CONTRIBUTING.md for full setup and contribution guidance.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.3 140 3/17/2026
0.0.2 51 3/16/2026
0.0.1 42 3/16/2026
0.0.0 46 3/16/2026

- Updated Core version to 0.0.3 for discriminate union support and OpenAPI example serialization compatibility with Fable.Remoting.Json.

### Changed

- Updated Core version to 0.0.3 for new example metadata features and endpoint expression support.