Suave.Swagger


Rest module

This small module contains helpers for JSON and XML serialization.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
open Suave.Swagger
open Rest
open FunnyDsl
open Swagger

[<CLIMutable>]
type PetCategory = 
  { Id:int
    Name:string }

Route returning a PetCategory as JSON:

1: 
let r1 = GET >=> path "/cat" >=> JSON { Id=45; Name="category 45" }

Route returning a PetCategory as XML:

1: 
let r2 = GET >=> path "/cat" >=> XML { Id=45; Name="category 45" }

Most REST API response formats depend on "Accept" header sent in the request

The MODEL helper will do it.

1: 
let r2 = GET >=> path "/cat" >=> MODEL { Id=45; Name="category 45" }

We can also simply read the body stream as JSON serialized object

1: 
2: 
3: 
4: 
let r2 =  
  POST 
    >=> path "/cat" 
    >=> JsonBody<PetCategory>(fun model -> MODEL { model with Id=(Random().Next()) })
namespace System
namespace Suave
module Operators

from Suave
module Filters

from Suave
module Writers

from Suave
module Successful

from Suave
namespace Suave.Swagger
module Rest

from Suave.Swagger
module FunnyDsl

from Suave.Swagger
Multiple items
module Swagger

from Suave.Swagger

--------------------
namespace Suave.Swagger
Fork me on GitHub