![]() |
VOOZH | about |
dotnet add package Fable.Remoting.OpenAPI --version 0.0.3
NuGet\Install-Package Fable.Remoting.OpenAPI -Version 0.0.3
<PackageReference Include="Fable.Remoting.OpenAPI" Version="0.0.3" />
<PackageVersion Include="Fable.Remoting.OpenAPI" Version="0.0.3" />Directory.Packages.props
<PackageReference Include="Fable.Remoting.OpenAPI" />Project file
paket add Fable.Remoting.OpenAPI --version 0.0.3
#r "nuget: Fable.Remoting.OpenAPI, 0.0.3"
#:package Fable.Remoting.OpenAPI@0.0.3
#addin nuget:?package=Fable.Remoting.OpenAPI&version=0.0.3Install as a Cake Addin
#tool nuget:?package=Fable.Remoting.OpenAPI&version=0.0.3Install as a Cake Tool
👁 NuGet Downloads
👁 NuGet Downloads
👁 NuGet Downloads
OpenAPI generation for Fable.Remoting contracts.
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.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.
open Fable.Remoting.OpenAPI
let document =
OpenApi.options
|> OpenApi.withTitle "My API"
|> OpenApi.withVersion "1.0.0"
|> OpenApi.generate<MySharedApi>
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.yamlYou can still override with OpenApi.withRoutes.
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
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.
The options pipeline exposes two styles of example helpers:
example when no named examples are configured)
OpenApi.withEndpointRequestExampleFor<'Api, 'Input, 'Output>OpenApi.withEndpointResponseExampleFor<'Api, 'Endpoint, 'Output>examples)
OpenApi.withEndpointRequestNamedExampleFor<'Api, 'Input, 'Output>OpenApi.withEndpointResponseNamedExampleFor<'Api, 'Endpoint, 'Output>withEndpointResponseExampleFor and withEndpointResponseNamedExampleFor accept endpoint quotations typed as Expr<'Api -> 'Endpoint>, which means they work for both:
unit -> Async<'Output>'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" }
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.
examples.example.This keeps existing single-example pipelines working while enabling richer multi-example docs.
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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on Fable.Remoting.OpenAPI:
| Package | Downloads |
|---|---|
|
Fable.Remoting.OpenAPI.Giraffe
Package Description |
|
|
Fable.Remoting.OpenAPI.Suave
Package Description |
This package is not used by any popular GitHub repositories.
### Added
- Native OpenAPI example serialization compatibility with Fable.Remoting.Json by reusing the same `FableJsonConverter` semantics used by remoting endpoints.
- OpenAPI schema generation support for discriminated unions modeled after Fable.Remoting.Json wire shapes:
- no-field cases as string values
- field cases as single-property objects keyed by case name
- multi-field payload cases as case-name object property with array payload