Falco.OpenApi
                             
                            
                                1.1.0
                            
                        
                    dotnet add package Falco.OpenApi --version 1.1.0
NuGet\Install-Package Falco.OpenApi -Version 1.1.0
<PackageReference Include="Falco.OpenApi" Version="1.1.0" />
<PackageVersion Include="Falco.OpenApi" Version="1.1.0" />
<PackageReference Include="Falco.OpenApi" />
paket add Falco.OpenApi --version 1.1.0
#r "nuget: Falco.OpenApi, 1.1.0"
#:package Falco.OpenApi@1.1.0
#addin nuget:?package=Falco.OpenApi&version=1.1.0
#tool nuget:?package=Falco.OpenApi&version=1.1.0
Falco.OpenAPI
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.name "HelloWorld"
            |> OpenApi.summary "This is a summary"
            |> OpenApi.description "This is a test description, which is the long form of the summary."
            |> OpenApi.returnType typeof<string>
    ]
Falco.OpenAPI is a library for generating OpenAPI documentation for Falco applications. It provides a set of combinators for annotating Falco routes with OpenAPI metadata, which can be used to generate OpenAPI documentation.
Key Features
- Generates OpenAPI 3.0 documentation.
- Provides a set of combinators for annotating Falco routes with OpenAPI metadata.
- Generates OpenAPI documentation from metadata associated to Falco routes.
- Allows for customization of the generated OpenAPI documentation.
Design Goals
- Minimalistic and easy to use.
- Explicit, allowing for fine-grained control over the generated OpenAPI documentation.
- Type-safe and to leverage the type system to prevent common mistakes.
- Composable, allowing for the generation of complex OpenAPI documentation.
Getting Started
This guide assumes you have a Falco project setup. If you don't, you can create a new Falco project using the following command:
> dotnet new web -lang F# -o HelloWorld
> cd HelloWorldApp
Install the nuget package:
> dotnet add package Falco
> dotnet add package Falco.OpenApi
Remove any *.fs files created automatically, create a new file named Program.fs and set the contents to the following:
open Falco
open Falco.Routing
open Microsoft.AspNetCore.Builder
let bldr = WebApplication.CreateBuilder()
let wapp = bldr.Build()
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
    ]
wapp.UseRouting()
    .UseFalco(endpoints)
    .Run()
Now, let's incorporate OpenAPI documentation into our Falco application. Update the Program.fs file to the following:
// ..
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.name "HelloWorld"
            |> OpenApi.summary "This is a summary"
            |> OpenApi.description "This is a test description, which is the long form of the summary."
            |> OpenApi.returnType typeof<string>
    ]
// ..
Which produces the following OpenAPI documentation:
{
  "openapi": "x.x.x",
  "info": {
    "title": "HelloWorld",
    "version": "1.0"
  },
  "paths": {
    "/": {
      "get": {
        "tags": [
          "HelloWorld"
        ],
        "summary": "This is a summary",
        "description": "This is a test description, which is the long form of the summary",
        "operationId": "HelloWorld",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": { }
}
Specs
Name (Operation ID)
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.name "HelloWorld"
    ]
Summary
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.summary "This is a summary"
    ]
Description
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.description "This is a description"
    ]
Return Type
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.returns typeof<string>
            // or,
            // |> OpenApi.returns { Return = typeof<string>; ContentType = ["text/plain"]; Status = 200 }
    ]
Route Parameters
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        mapGet "/hello/{name?}"
            (fun route -> route?name.AsString("world"))
            Response.ofPlainText
            |> OpenApi.route [
                { Type = typeof<string>; Name = "name"; Required = false } ]
    ]
Query Parameters
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        mapGet "/hello"
            (fun route ->
                let age = route?age.AsInt(0)
                $"Hello there, your are {age} years old.")
            Response.ofPlainText
            |> OpenApi.route [
                { Type = typeof<int>; Name = "age"; Required = false } ]
    ]
Header Parameters
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/"
            (fun ctx ->
                let headers = Request.getHeaders ctx
                let versionId = headers.GetString "X-Version-ID"
                $"Hello, you are using version {versionId}")
            |> OpenApi.header [
                { Type = typeof<string>; Name = "X-Version-ID"; Required = true } ]
    ]
Tags
open Falco
open Falco.OpenApi
open Falco.Routing
let endpoints =
    [
        get "/" (Response.ofPlainText "Hello World!")
            |> OpenApi.tags [
                "tag1"
                "tag2" ]
    ]
Find a bug?
There's an issue for that.
License
Licensed under Apache License 2.0.
| Product | Versions 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 is compatible. 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. | 
- 
                                                    net8.0- Falco (>= 5.1.0)
- FSharp.Core (>= 9.0.202)
- Microsoft.AspNetCore.OpenApi (>= 8.0.20)
 
- 
                                                    net9.0- Falco (>= 5.1.0)
- FSharp.Core (>= 9.0.202)
- Microsoft.AspNetCore.OpenApi (>= 9.0.9)
 
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 | 
|---|---|---|
| 1.1.0 | 329 | 9/17/2025 | 
| 1.0.0 | 353 | 1/29/2025 | 
| 1.0.0-rc2 | 127 | 1/25/2025 | 
| 1.0.0-rc1 | 128 | 12/17/2024 | 
| 1.0.0-beta1 | 135 | 11/20/2024 | 
| 1.0.0-alpha1 | 126 | 10/17/2024 |